This is a RESTful API for a real estate application built using Node.js with TypeScript and PostgreSQL. The API allows users to manage properties, projects, areas, and cities.
Note: you should have Docker installed
git clone https://github.com/Hossam-H22/Real-Estate-API.git
cd Real-Estate-API docker-compose up --build docker-compose down - Node.js with TypeScript
- PostgreSQL with TypeORM
- Zod for validation
- bcrypt for security
- Cloudinary for image uploads
- Express.js for routing and middleware
- Authentication & Authorization middleware for securing endpoints
- Error Handling middleware for consistent API responses
- Validation middleware using Zod
- Pagination, Filtering, Sorting, and Selection using the
ApiFeaturesclass - CRUD Operations for all entities
src/
database/
middleware/
modules/
each module/
moduleName.entity.ts
moduleName.route.ts
moduleName.controller.ts
moduleName.service.ts
moduleName.validation.ts
moduleName.roles.ts
utils/
{
"_id": "UUID",
"name": "string",
"email": "string",
"password": "string",
"phone": "string",
"role": "enum('admin', 'buyer', 'agent')",
"createdAt": "Date",
"favorites": ["UUID (references properties)"],
}{
"_id": "UUID",
"name": "string",
"createdBy": "UUID (references users)",
"createdAt": "Date"
}{
"_id": "UUID",
"name": "string",
"cityId": "UUID (references cities)",
"createdBy": "UUID (references users)",
"createdAt": "Date"
}{
"_id": "UUID",
"name": "string",
"description": "string",
"areaId": "UUID (references areas)",
"createdBy": "UUID (references users)",
"createdAt": "Date"
}{
"_id": "UUID",
"title": "string",
"description": "string",
"price": "number",
"type": "enum('house', 'apartment', 'land', 'commercial')",
"status": "enum('available', 'sold', 'rented')",
"bedrooms": "number",
"bathrooms": "number",
"squareFeet": "number",
"images": ["array of strings (URLs)"],
"createdBy": "UUID (references users)",
"projectId": "UUID (references projects)",
"createdAt": "Date"
}Each module includes four endpoints:
GET /user- Get all usersGET /user/:id- Get a specific userPOST /user- Create a new userPUT /user/:id- Update a user
GET /city- Get all citiesGET /city/:id- Get a specific cityPOST /city- Create a new cityPUT /city/:id- Update a cityDelete /city/:id- Delete a city
GET /area- Get all areasGET /area/:id- Get a specific areaPOST /area- Create a new areaPUT /area/:id- Update an areaDelete /area/:id- Delete an area
GET /project- Get all projectsGET /project/:id- Get a specific projectPOST /project- Create a new projectPUT /project/:id- Update a projectDelete /project/:id- Delete a project
GET /property- Get all propertiesGET /property/:id- Get a specific propertyPOST /property- Create a new propertyPUT /property/:id- Update a propertyPatch /property/:id/favorite- Toggle property on favorite list of UserDelete /property/:id- Delete a property
- Pagination:
?page=1&size=10 - Sorting:
?sort=-createdAt(Descending),?sort=price(Ascending) - Fields Selection:
?fields=name,description,price - Details Selection:
?details=createdBy,projectId - Filtering:
?price[gte]=50000&status=available - Search:
?search=apartment
- User authentication is implemented using JWT.
- Middleware ensures role-based access control.
- Passwords are securely hashed using bcrypt.
- Cloudinary is used to store images.
- The
propertiesmodule allows uploading images via Cloudinary.
- All errors are handled using a centralized middleware.
- Standard response format for errors.
Postman - link
This API provides a comprehensive real estate management system with authentication, authorization, validation, and data management features.