RESTful API for JUP Propiedades - Modern real estate platform backend
Website β’ Report Bug β’ Request Feature
- About the Project
- Features
- Technologies
- Project Structure
- API Endpoints
- Getting Started
- Environment Variables
- Usage
- Docker
- Deployment
- License
JUP Real Estate Backend is a RESTful API built with Node.js, Express, and MongoDB that powers the JUP Propiedades real estate platform. It provides comprehensive endpoints for property management, search functionality, and featured property handling, with robust authentication and authorization.
This backend provides:
- Property Management: Complete CRUD operations for property listings with validation
- Advanced Search: Filter properties by type, operation, region, price range, and more
- Authentication: Secure user authentication and authorization using Clerk
- Featured Properties: Special management for highlighted property listings
- Email Integration: Communication capabilities using Resend
- Type Safety: Built with TypeScript for robust and maintainable code
- CRUD Operations: Create, read, update, and delete properties
- Detailed Information: Comprehensive property data including:
- Title, description, and type (casa, departamento, parcela, etc.)
- Operation type (En Arriendo, En Venta)
- Price, address, and location (region, city area)
- Specifications (dorms, bathrooms, parking spaces, area)
- Status tracking (disponible, vendida, pendiente)
- Multiple image URLs (minimum 4 images required)
- Condominium designation
- Search by Name: Find properties by partial title matching
- Chilean Regions: Full support for all 16 regions of Chile
- Filter by Type: casa, departamento, parcela, sitio, oficina, comercial
- Filter by Operation: En Arriendo (rent) or En Venta (sale)
- Filter by Region: All 16 Chilean regions supported
- Price Range: Min/max price filtering
- Area Range: Min/max area filtering
- Multiple Criteria: Combine filters for precise results
- Highlight Management: Mark properties as featured
- Dedicated Endpoints: Separate API for featured property listings
- CRUD Operations: Full management of featured property designations
- Clerk Integration: Secure authentication using Clerk
- Role-Based Access: Admin-only routes for property management
- Optional Auth: Public access for viewing, protected routes for modifications
- Input Validation: Comprehensive validation using express-validator
- Email Integration: Resend service for email communications
- CORS Configuration: Secure cross-origin resource sharing
- Request Logging: Morgan middleware for detailed request logging
- Error Handling: Robust error handling and validation
- Node.js 20 - JavaScript runtime
- Express 4.21 - Web application framework
- TypeScript 5.7 - Type safety and better developer experience
- MongoDB - NoSQL database
- Mongoose 8.9 - MongoDB object modeling
- Clerk - User authentication and management
- bcrypt - Password hashing
- jsonwebtoken - JWT token management
- express-validator - Request validation
- cors - Cross-origin resource sharing
- morgan - HTTP request logger
- dotenv - Environment variable management
- Resend - Modern email API
- Nodemailer - Email sending library
JUP-RealEstate_Backend/
βββ src/
β βββ config/ # Configuration files
β β βββ cors.ts # CORS configuration
β β βββ db.ts # MongoDB connection
β β βββ resend.ts # Email service configuration
β β
β βββ controllers/ # Request handlers
β β βββ FeaturedController.ts # Featured property logic
β β βββ PropertyController.ts # Property CRUD logic
β β βββ SearchController.ts # Search logic
β β
β βββ models/ # Database schemas
β β βββ Featured.ts # Featured property model
β β βββ Property.ts # Property model
β β
β βββ routes/ # API routes
β β βββ featuredRouter.ts # Featured property routes
β β βββ propertyRouter.ts # Property routes
β β βββ searchRouter.ts # Search routes
β β
β βββ middleware/ # Custom middleware
β β βββ auth.ts # Authentication middleware
β β βββ validation.ts # Input validation middleware
β β
β βββ emails/ # Email templates (if applicable)
β β
β βββ server.ts # Express app configuration
β βββ index.ts # Application entry point
β
βββ types/ # TypeScript type definitions
βββ Dockerfile # Docker container configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Dependencies and scripts
βββ .gitignore # Git ignore patterns
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/properties |
Get all properties | No |
| GET | /api/properties/:id |
Get property by ID | No |
| GET | /api/properties/name/:searchTerm |
Search properties by name | No |
| POST | /api/properties/create |
Create new property | Yes (Admin) |
| PATCH | /api/properties/edit/:id |
Update property | Yes (Admin) |
| DELETE | /api/properties/delete/:id |
Delete property | Yes (Admin) |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/search |
Search with filters | No |
Query Parameters:
type: casa, departamento, parcela, sitio, oficina, comercialoperation: En Arriendo, En Ventaregion: Chilean region nameminPrice: Minimum pricemaxPrice: Maximum priceminArea: Minimum area (mΒ²)maxArea: Maximum area (mΒ²)
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/featured |
Get all featured properties | No |
| POST | /api/featured/create |
Create featured property | Yes (Admin) |
| DELETE | /api/featured/delete/:id |
Remove featured property | Yes (Admin) |
- Node.js 20 or higher
- MongoDB instance (local or cloud)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/Thomas465xd/JUP-RealEstate_Backend.git cd JUP-RealEstate_Backend -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory (see Environment Variables) -
Start the development server
npm run dev
The server will start on
http://localhost:4000(or your configured PORT)
Create a .env file in the root directory with the following variables:
# Server Configuration
PORT=4000
# Database
DATABASE_URL=mongodb://localhost:27017/jup-realestate
# OR for MongoDB Atlas:
# DATABASE_URL=mongodb+srv://<username>:<password>@cluster.mongodb.net/jup-realestate
# Clerk Authentication
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
# Email Service (Resend)
RESEND_API_KEY=your_resend_api_key
# CORS (Optional - Frontend URL)
FRONTEND_URL=http://localhost:3000DATABASE_URL: MongoDB connection stringCLERK_PUBLISHABLE_KEY: Clerk publishable key for authenticationCLERK_SECRET_KEY: Clerk secret key for authenticationRESEND_API_KEY: Resend API key for email functionality
PORT: Server port (defaults to 4000)FRONTEND_URL: Frontend application URL for CORS configuration
# Start development server with hot reload
npm run dev
# The API will be available at http://localhost:4000# Build TypeScript to JavaScript
npm run build
# The compiled code will be in the dist/ directory
# Start production server
node dist/index.jsYou can test the API using tools like:
- Postman: Import and test endpoints
- cURL: Command-line testing
- Frontend Application: Connect your frontend
Example cURL request:
# Get all properties
curl http://localhost:4000/api/properties
# Search properties
curl "http://localhost:4000/api/search?type=casa&operation=En%20Venta®ion=Metropolitana%20de%20Santiago"docker build -t jup-realestate-backend .docker run -p 4000:4000 \
-e DATABASE_URL=your_mongodb_url \
-e CLERK_PUBLISHABLE_KEY=your_key \
-e CLERK_SECRET_KEY=your_secret \
-e RESEND_API_KEY=your_key \
jup-realestate-backendThis application is deployed on Render, a modern cloud platform that provides seamless deployment for web services.
- Automatic Deployments: Connected to the GitHub repository for automatic builds on push
- Environment Variables: Securely configured through Render's dashboard
- Managed Database: MongoDB Atlas integration for production database
- SSL Certificates: Automatic HTTPS with free SSL certificates
- Health Checks: Automatic service health monitoring
- Zero Downtime: Rolling deployments ensure continuous availability
The application is configured for Render deployment with:
- Build Command:
npm install && npm run build - Start Command:
node dist/index.js - Environment: Node.js 20
- Health Check Path:
/api/properties(returns 200 for healthy service)
To deploy your own instance:
- Create a new Web Service on Render
- Connect your GitHub repository
- Configure the service:
- Name:
jup-realestate-backend - Environment: Node
- Build Command:
npm install && npm run build - Start Command:
node dist/index.js
- Name:
- Add Environment Variables:
DATABASE_URLCLERK_PUBLISHABLE_KEYCLERK_SECRET_KEYRESEND_API_KEYFRONTEND_URL(optional)
- Deploy: Render will automatically build and deploy your application
The production API is available at your Render service URL (e.g., https://your-service-name.onrender.com)
This project is private and belongs to JUP Propiedades. All rights reserved.
For use, distribution, or modification of this code, please contact the owner directly.
Made with β€οΈ for JUP Propiedades
Providing robust backend services for Chile's modern real estate platform