Property Module - API Documentation
Overview
CRUD APIs for managing Property and PropertyUnit entities with nested routing.
API Endpoints
Property (/properties)
All endpoints require JWT authentication.
- POST
/properties- Create property (with optional nested units) - GET
/properties- List all active properties - GET
/properties/:id- Get single property - PATCH
/properties/:id- Update property - DELETE
/properties/:id- Soft delete property
Property Unit (/properties/:propertyId/units)
All endpoints require JWT authentication.
- POST
/properties/:propertyId/units- Create unit for property - GET
/properties/:propertyId/units- List all units for property - GET
/properties/:propertyId/units/:unitId- Get single unit - PATCH
/properties/:propertyId/units/:unitId- Update unit - DELETE
/properties/:propertyId/units/:unitId- Soft delete unit
Key Features
Auto-Approval: Properties are auto-approved on creation
property_approved=trueproperty_approved_at= current timestamp
Nested Creation: Create properties with multiple units in one request
Soft Deletes: All deletions set is_active = false
Authentication: landlord_id automatically set from authenticated user
Example Usage
Create Property with Units
POST /properties
{
"alias_name": "Sunshine Apartments",
"property_type": "apartment",
"pin_code": 411001,
"district": "Pune",
"city": "Pune",
"state": "Maharashtra",
"property_units": [
{
"unit_name": "Flat 101",
"room_type": "2bhk",
"furnishing_type": "semi_furnished",
"area_sqft": 1200,
"floor_number": 1
}
]
}Create Property Unit
POST /properties/1/units
{
"unit_name": "Flat 102",
"room_type": "3bhk",
"furnishing_type": "fully_furnished",
"area_sqft": 1500
}Architecture
Pattern: Controller → Service → QueryBuilder → Database
Module Structure:
PropertyModule- Dependency injection configurationPropertyController,PropertyUnitController- HTTP request handlersPropertyService,PropertyUnitService- Business logic- DTOs - Request validation using class-validator
Database Abstraction: Uses QueryBuilderFactory for ORM-agnostic operations