FleetLink is a full-stack MERN (MongoDB, Express.js, React, Node.js) application for managing vehicle bookings in a logistics company. The system allows users to add vehicles to the fleet, search for available vehicles based on date ranges, and book vehicles for specific periods.
(fleetlink%20image.png)
- Add vehicles to the fleet with details
- Search for available vehicles based on start and end dates
- Book vehicles for specific date ranges
- MongoDB for data persistence
- RESTful API design
- Docker containerization for easy deployment
- React frontend with responsive UI
- Node.js and npm installed on your machine
- Docker and Docker Compose installed (optional, for containerized setup)
- MongoDB (either local installation or Docker container)
FleetLink/
├── backend/ # Node.js/Express backend server
│ ├── controllers/ # Request handlers
│ ├── models/ # MongoDB data models
│ ├── routes/ # API route definitions
│ ├── config/ # Database configuration
│ └── tests/ # Jest test files
├── Frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── api/ # API client configuration
│ │ └── assets/ # Static assets
└── nginx/ # Nginx configuration for production
GET /api/vehicles- Get all vehiclesPOST /api/vehicles- Add a new vehicleGET /api/vehicles/available- Search for available vehicles
GET /api/bookings- Get all bookingsPOST /api/bookings- Create a new booking
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Create a
.envfile with your MongoDB connection string:MONGO_URI=mongodb://localhost:27017/fleetlink PORT=5000 -
Run the backend server:
npm start
or for development with auto-restart:
npm run dev
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Run the frontend application:
npm run dev
To run both backend and frontend using Docker Compose, run the following command from the root directory:
docker-compose upThis will start all services defined in the docker-compose.yml file:
- MongoDB database
- Backend Node.js server
- Frontend React application served through Nginx
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
Run backend tests with Jest:
cd backend
npm testMONGO_URI=mongodb://localhost:27017/fleetlink
PORT=5000
-
Frontend API calls returning 404 errors:
- Ensure the backend is running on port 5000
- Check that the baseURL in
Frontend/src/api/axiosConfig.jsis set tohttp://localhost:5000/api
-
Database connection errors:
- Verify MongoDB is running and accessible
- Check the MONGO_URI in the backend
.envfile
-
CORS errors:
- The backend should have CORS configured to allow requests from the frontend origin
- The backend runs on port 5000 by default
- The frontend runs on port 5173 in development mode
- All API endpoints are prefixed with
/api - Docker setup serves the frontend through Nginx on port 3000
For any issues or questions, please contact @ rajatsinghtomarofficial@gmail.com.