Project containing three parts:
api— Express API server (Prisma + MongoDB connection)client— React + Vite frontendsocket— Socket.IO server for real-time messaging
Overview
The API serves REST endpoints on port 8800 and requires environment variables for the database, JWT secret, and the client URL. The client runs with Vite (default port 5174). The socket server listens on port 4000 and accepts connections from the client.
This project is a small real-estate marketplace and messaging platform. Key features include:
- User registration and authentication using JWT.
- Profile management.
- Create, edit, and delete property listings.
- Upload images and rich-text descriptions for properties.
- Browse listings with filtering, search, and map views.
- View detailed property information.
- Real-time chat and messaging between users via Socket.IO.
AgileProject/
├── api/ # Express API + Prisma + MongoDB
├── client/ # React + Vite frontend
└── socket/ # Socket.IO real-time server
- Express.js
- Prisma ORM
- MongoDB
- JWT Authentication
- React
- Vite
- Socket.IO
Before running the project, make sure you have:
- Node.js (version 18 or later)
- npm or Yarn
- Access to a MongoDB database
Create a file named api/.env and add the following variables:
DATABASE_URL="mongodb+srv://<username>:<password>@cluster0.example.mongodb.net/estate?retryWrites=true&w=majority&appName=Cluster0"
JWT_SECRET_KEY=your_jwt_secret_here
CLIENT_URL=http://localhost:5174| Variable | Description |
|---|---|
DATABASE_URL |
MongoDB connection string |
JWT_SECRET_KEY |
Secret key used to sign JWT tokens |
CLIENT_URL |
Frontend URL allowed by CORS |
Important: Never commit
.envfiles to version control. If credentials are exposed, rotate them immediately.
Install dependencies for each service:
# API
cd api
npm install
# Client
cd ../client
npm install
# Socket Server
cd ../socket
npm installStart each service in a separate terminal.
Runs on http://localhost:8800
cd api
node app.js
# Or with automatic reload
npx nodemon app.jsRuns on http://localhost:4000
cd socket
node app.js
# Or with automatic reload
npx nodemon app.jsRuns on http://localhost:5174
cd client
npm run dev- API Test Endpoint:
http://localhost:8800/api/test - Client Application:
http://localhost:5174 - Socket Server:
http://localhost:4000
The API provides endpoints for:
- Authentication
- Users
- Property Posts
- Chats
- Messages
- Ensure the MongoDB connection string is valid before starting the API.
- Run all three services simultaneously for full functionality.
- The socket server handles real-time chat and online user tracking.
- Vite may use a different port if
5174is already in use.