A backend API for managing real estate properties and their related contracts. This is a RESTful API built with Node.js, Express, and Supabase.
- Property management (create, read, update, delete properties)
- Contract tracking with tenant information
- Document and image storage using Supabase Storage
- Dashboard with portfolio metrics and analytics
- Standardized RESTful API with consistent response formats
- Node.js
- Express.js
- JavaScript
- Supabase (for database and storage)
- JWT Authentication
The API uses Supabase with the following tables:
- Users
- Properties
- Contracts
- Documents
- Images
- Node.js (v18 or newer)
- Supabase account and project
- Clone the repository
- Install dependencies:
npm install
-
Create a Supabase project at https://supabase.com
-
Update the
.envfile with your Supabase credentials (see.env.example) -
Start the server:
For the JavaScript version with Supabase support:
npm run demo:supabase
To start the development server:
npm run dev
POST /api/auth/login- Authenticate userPOST /api/auth/register- Register a new userPOST /api/auth/logout- End user session
GET /api/properties- List all propertiesPOST /api/properties- Create new propertyGET /api/properties/:id- Get property detailsPUT /api/properties/:id- Update propertyDELETE /api/properties/:id- Delete propertyPOST /api/properties/:id/images- Upload property imageGET /api/properties/:id/images- Get property images
GET /api/contracts- List all contractsPOST /api/contracts- Create new contractGET /api/contracts/property/:propertyId- Get contracts for a specific propertyGET /api/contracts/:id- Get contract detailsPUT /api/contracts/:id- Update contractDELETE /api/contracts/:id- Delete contract
POST /api/documents- Upload documentGET /api/documents/property/:propertyId- Get documents for propertyGET /api/documents/contract/:contractId- Get documents for contractGET /api/documents/:id/download- Download document
GET /api/dashboard/summary- Get portfolio summary stats
Create a .env file with the following variables (see .env.example):
# Server Configuration
PORT=3000
NODE_ENV=development
# Supabase Configuration
SUPABASE_URL=your_supabase_url
SUPABASE_API_KEY=your_supabase_api_key
# JWT Configuration
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=24h
The API uses Supabase Auth for authentication. Include the token in the Authorization header:
Authorization: Bearer your_token_here
Required tables in your Supabase project:
- properties
- contracts
- documents
- images
The schema should match the models used in the API. You can use the example Supabase schema in src/db/supabase-schema.sql.
This project is licensed under the MIT License - see the LICENSE file for details.