This is the complete RESTful API for the GesTaxi SaaS platform, a B2B corporate taxi management system. Built with Node.js and Express, it serves as the central brain for the entire ecosystem.
It handles business logic, database management (PostgreSQL), and secure authentication (JWT) for both the Admin Panel and the Employee Mobile App.
This project is the backend service for a complete full-stack application.
- Node.js
- Express.js (for routing and middleware)
- PostgreSQL (for the database)
- node-postgres (pg) (for database connection)
- JWT (jsonwebtoken) (for secure authentication)
- bcrypt (for password hashing)
- CORS (for cross-origin resource sharing)
- dotenv (for environment management)
- Dual Authentication System: Separate, secure login endpoints (
/auth/admin/loginand/auth/login) for Administrators and Employees. - Protected Routes: All business logic routes are protected by a JWT authentication middleware.
- Ride Management (Dispatch Logic):
- Employees can
POSTnew ride requests, including scheduled rides. - Backend validates business logic (e.g., must be 1 hour in advance).
- Admins can
GETrides with filters (e.g.,?status=pending). - Admins can
PUTupdates to rides (e.g., assign adriver_idand changestatusto 'accepted').
- Employees can
- CRUD for Core Entities: Full Create, Read, Update & Delete operations for:
DriversCompaniesEmployees
- Admin Management: Secure endpoints for admins to change their own passwords.
To run this server locally, follow these steps:
-
Clone the repository:
git clone [https://github.com/Digao075/Taxi_Saas_Backend.git](https://github.com/Digao075/Taxi_Saas_Backend.git) cd Taxi_Saas_Backend -
Install dependencies:
npm install
-
Set up your Environment (.env) file: Create a
.envfile in the root of the project and add your configuration:PORT=3333 DB_HOST=localhost DB_PORT=5432 DB_USER=your_postgres_user DB_PASSWORD=your_postgres_password DB_DATABASE=taxiservice JWT_SECRET=gestaxiapi
-
Set up the PostgreSQL Database:
- Ensure you have PostgreSQL running.
- Create the
taxiservicedatabase. - Run the necessary
CREATE TABLEscripts foradmins,companies,drivers,employees, andrides. - Note: You must manually insert at least one admin to be able to log in. (Or run the
create-admin.jsscript we built).
-
Run the server:
npm run dev
The server will be running on
http://localhost:3333.