This application is a platform that connects shippers and truckers, allowing shippers to post loads and truckers to bid on them. The system includes real-time tracking, financial management, and a benefits system for truckers with eligibility criteria.
- ✅ Load Posting System: Shippers can post loads with detailed information
- ✅ Bidding Mechanism: Truckers can bid on loads that match their criteria
- ✅ Eligibility Criteria for Truckers: Verification system for truckers based on predefined criteria
- ✅ Load Tracking: Real-time tracking of loads with status updates and map visualization
- ✅ Financial Management: Transaction ledger for both shippers and truckers
- ✅ Benefits System: Discount and benefit management for eligible truckers
- ✅ SuperAdmin Dashboard: For system administrators to manage users and operations
- Next.js: React framework for building the user interface
- Tailwind CSS: For styling components
- Axios: For making API requests to the backend
- React Context API: For state management
- Node.js: JavaScript runtime
- Express.js: Web framework for building the API
- MongoDB: NoSQL database with Mongoose ODM
- JWT: For authentication and authorization
- Socket.io: For real-time updates (would be implemented for production)
The application follows a MERN stack architecture with the addition of Next.js on the frontend:
- Models: MongoDB schema definitions for Users, Shippers, Truckers, Loads, Bids, etc.
- Controllers: Handle business logic and database operations
- Routes: Define API endpoints
- Middleware: Authentication, authorization, and error handling
- Frontend Pages: Next.js pages for different views
- Components: Reusable React components
- Context: State management with React Context API
- Node.js (v14 or higher)
- MongoDB
- npm or yarn package manager
- Clone the repository
git clone https://github.com/Lovjeet1233/Trucking-Platform.git
cd Trucking-Platform- Install backend dependencies
cd backend
npm install-
Set up environment variables
- Copy
.env.exampleto.envand update the values with your own
cp .env.example .env
- Update the MongoDB URI, JWT secret, and other required values
- Copy
-
Install frontend dependencies
cd ../frontend
npm install-
Run the application
- Backend:
cd backend npm run dev- Frontend:
cd frontend npm run dev -
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/api/v1
The API is built around RESTful principles. Here are the main endpoints:
POST /api/v1/auth/register- Register a new userPOST /api/v1/auth/login- Login userGET /api/v1/auth/me- Get current userGET /api/v1/auth/logout- Logout user
POST /api/v1/shippers- Create shipper profileGET /api/v1/shippers/profile- Get shipper profilePUT /api/v1/shippers/profile- Update shipper profile
POST /api/v1/truckers- Create trucker profileGET /api/v1/truckers/profile- Get trucker profilePUT /api/v1/truckers/profile- Update trucker profilePUT /api/v1/truckers/location- Update trucker location
POST /api/v1/loads- Create a new loadGET /api/v1/loads- Get all loadsGET /api/v1/loads/:id- Get a single loadPUT /api/v1/loads/:id- Update a loadDELETE /api/v1/loads/:id- Delete a loadGET /api/v1/loads/shipper/me- Get shipper's loadsGET /api/v1/loads/available- Get available loads for truckers
POST /api/v1/bids- Place a bidGET /api/v1/bids/load/:loadId- Get bids for a loadGET /api/v1/bids/trucker/me- Get trucker's bidsPUT /api/v1/bids/:id/withdraw- Withdraw a bidPUT /api/v1/bids/:id/accept- Accept a bidPUT /api/v1/bids/:id/reject- Reject a bid
POST /api/v1/tracking- Create tracking updateGET /api/v1/tracking/load/:loadId- Get tracking updates for a loadGET /api/v1/tracking/load/:loadId/latest- Get latest tracking updatePOST /api/v1/tracking/load/:loadId/issue- Report an issue
GET /api/v1/financial/user/me- Get user's transactionsGET /api/v1/financial/:id- Get a transaction
GET /api/v1/benefits- Get all benefitsPOST /api/v1/benefits/:id/claim- Claim a benefitGET /api/v1/benefits/claims/me- Get trucker's claimed benefits
The system uses several MongoDB models to represent the data:
- User: Base user model with authentication details
- Shipper: Extended user model for shipper-specific details
- Trucker: Extended user model for trucker-specific details, including eligibility criteria
- Load: Represents a load posted by a shipper
- Bid: Represents a bid placed by a trucker on a load
- LoadTracking: Stores tracking updates for loads
- Transaction: Financial transactions between parties
- Benefit: Available benefits for truckers
- BenefitClaim: Claims made by truckers for benefits
Throughout the development process, I utilized several AI tools to assist with various aspects of the project:
- Purpose: Used for generating code structures, architectural planning, and debugging complex issues
- Pros:
- Excellent for generating comprehensive code solutions
- Good understanding of MERN stack architecture
- Helpful for explaining complex concepts
- Cons:
- Occasionally generates code that needs adjustments
- Limited understanding of some newer Next.js features
- Purpose: Used for code completion and suggestions during implementation
- Pros:
- Speeds up coding by suggesting completions
- Context-aware suggestions based on project codebase
- Good for repetitive patterns
- Cons:
- Sometimes suggests deprecated methods
- Quality varies depending on context
- Purpose: Used for troubleshooting specific issues and generating smaller code snippets
- Pros:
- Quick solutions for specific error messages
- Good for generating small, focused code segments
- Cons:
- Less comprehensive for full architecture planning
- Occasionally provides outdated solutions
-
Challenge: Setting up proper authentication with JWT Solution: Implemented custom middleware for token verification and used HTTP-only cookies for added security
-
Challenge: Real-time tracking implementation Solution: Created a tracking system with regular updates and map visualization; a full Socket.io implementation would be added for production
-
Challenge: Modeling complex relationships between entities Solution: Designed MongoDB schemas with proper references and population strategies
-
Challenge: Role-based access control Solution: Implemented custom middleware to check user roles and permissions for each route
-
Challenge: Handling bidding logic and lowest bid selection Solution: Created a sorting mechanism for bids and automated processes for accepting/rejecting bids
-
Challenge: Handling CORS issues between frontend and backend Solution: Properly configured CORS middleware on the backend and API requests on the frontend
- Real-time updates: Basic polling is implemented, but Socket.io would be used for production
- Advanced filtering: Basic filtering is available, but advanced geolocation-based filtering would be enhanced
- Payment processing: The system models transactions but doesn't integrate with payment gateways
- Advanced analytics: Basic stats are available but detailed analytics would be added
- Real-time notifications using Socket.io
- Mobile applications for truckers to update tracking on the go
- Advanced analytics dashboard for business intelligence
- Integration with payment gateways for financial transactions
- Integration with map services for route optimization
- Document verification system for trucker eligibility
Trucking-Platform/
├── backend/
│ ├── config/ # Configuration files
│ ├── controllers/ # Route controllers
│ ├── middleware/ # Custom middleware
│ ├── models/ # Mongoose models
│ ├── routes/ # API routes
│ ├── utils/ # Utility functions
│ └── server.js # Entry point
├── frontend/
│ ├── components/ # React components
│ │ ├── auth/ # Authentication components
│ │ ├── bids/ # Bidding components
│ │ ├── layout/ # Layout components
│ │ ├── loads/ # Load management components
│ │ ├── shipper/ # Shipper-specific components
│ │ ├── tracking/ # Tracking components
│ │ └── ui/ # UI components
│ ├── context/ # React context for state management
│ ├── pages/ # Next.js pages
│ ├── public/ # Static assets
│ ├── styles/ # CSS styles
│ └── utils/ # Utility functions
└── .env.example # Example environment variables
A video demonstration of the application can be found at:(https://drive.google.com/file/d/1b9QgZF2JK1C2DlPPX_S76x4L8eVzHbcp/view?usp=drive_link)
This project is licensed under the MIT License.