Prerequisites
Before you begin, ensure you have the following installed:- Node.js 18+ and npm
- PostgreSQL 14+ running locally or remotely
- Git for cloning the repository
Installation
Install Dependencies
Install all required npm packages:This will install NestJS, TypeORM, Socket.IO, and all other dependencies defined in
package.json.Configure Environment Variables
Copy the example environment file and configure your settings:Edit
.env with your database credentials and configuration:.env
Generate secure random strings for
JWT_ACCESS_SECRET and JWT_REFRESH_SECRET in production:Database Setup
The application will automatically create the database if it doesn’t exist (thanks to
DatabaseInitService).If you have DB_SYNCHRONIZE=true, TypeORM will auto-create tables on startup.Verify Installation
Once the server is running, verify everything is working:Check API Health
The API runs on port 3000 by default with/api prefix:
Access Swagger Documentation
Open your browser and navigate to:The API documentation is auto-generated from controller decorators and DTOs
Make Your First API Call
Let’s create a trip estimate to test the API:Login and Get Access Token
Authenticate to receive JWT tokens:Response:
Save the
accessToken to use in subsequent authenticated requestsDevelopment Commands
Here are useful commands for development:WebSocket Connection
The backend provides real-time updates via Socket.IO:WebSocket scripts are available in the
scripts/ directory for testing real-time featuresCommon Issues
Database connection failed
Database connection failed
Error:
Error: connect ECONNREFUSED 127.0.0.1:5432Solution:- Ensure PostgreSQL is running:
sudo service postgresql start - Check DB_HOST, DB_PORT, DB_USER, and DB_PASSWORD in
.env - Verify the user has permissions to create databases
Port already in use
Port already in use
Error:
Error: listen EADDRINUSE: address already in use :::3000Solution:- Change the PORT in
.envto a different value (e.g., 3001) - Or kill the process using port 3000:
JWT token errors
JWT token errors
Error:
JsonWebTokenError: invalid signatureSolution:- Ensure JWT_ACCESS_SECRET and JWT_REFRESH_SECRET are set in
.env - Regenerate tokens after changing secrets
- Don’t use the example secrets in production
CORS errors from frontend
CORS errors from frontend
Error:
Access to fetch blocked by CORS policySolution:- Add your frontend URL to CORS_ORIGINS in
.env: - Multiple origins should be comma-separated
Next Steps
Now that you have the API running:Explore the Architecture
Learn about the system design and module organization
API Reference
Browse detailed endpoint documentation
Configuration Guide
Learn about environment configuration
Authentication Guide
Understand the JWT authentication flow
WebSocket Guide
Learn about real-time communication
