Welcome to the backend repository of the Logistics Management System. This system is designed to manage vehicles, items, orders, and customers for a logistics company.
This backend repository contains the server code for the Logistics Management System. It's built using the MERN (MongoDB, Express, React, Node.js) stack and provides APIs for managing items, customers, delivery vehicles, and orders.
-
Clone the repository:
git clone https://github.com/siimrann17/VectorDrive
-
Navigate to the project directory:
cd view
-
Install backend dependencies:
npm install
-
Install frontend dependencies:
cd view npm install
-
Start the backend server:
npm server
The backend server will run on http://localhost:8000.
-
Start the frontend development server:
cd view npm start
The frontend development server will run on http://localhost:3000.
-
Backend:
- Node.js
- Express.js
- MongoDB (or your chosen database)
- Bcrypt.js (for user authentication)
- JWT (JSON Web Tokens) for secure user sessions
-
Frontend:
- React
- React Router (for routing)
- Redux (for state management)
- Axios (for API requests)
Create a .env
file in your backend project's root directory and add the following environment variables:
MongoDB_URL = YOUR_MONDO_DB_URL
PORT = 8000
MongoDB_URL
: MongoDB connection URL.PORT
: Port number for the backend server.
POST /api/users/register
: Register a new user.POST /api/users/login
: Log in and obtain a JWT token for authentication.
GET /api/items
: Retrieve a list of all items.GET /api/items/:id
: Retrieve details of a specific item.POST /api/items
: Create a new item.PUT /api/items/:id
: Update an existing item.DELETE /api/items/:id
: Delete an item.
GET /api/customers
: Retrieve a list of all customers.GET /api/customers/:id
: Retrieve details of a specific customer.POST /api/customers
: Create a new customer.PUT /api/customers/:id
: Update an existing customer.DELETE /api/customers/:id
: Delete a customer.
GET /api/delivery-vehicles
: Retrieve a list of all delivery vehicles.GET /api/delivery-vehicles/:id
: Retrieve details of a specific delivery vehicle.POST /api/delivery-vehicles
: Create a new delivery vehicle.PUT /api/delivery-vehicles/:id
: Update an existing delivery vehicle.DELETE /api/delivery-vehicles/:id
: Delete a delivery vehicle.
GET /api/orders
: Retrieve a list of all orders.GET /api/orders/:id
: Retrieve details of a specific order.POST /api/orders
: Create a new order.PUT /api/orders/:id
: Update an existing order.DELETE /api/orders/:id
: Delete an order.PUT /api/orders/:id/mark-delivered
: Mark an order as delivered.
For protected routes, include the JWT token in the Authorization
header.
This backend uses token-based authentication with JSON Web Tokens (JWT). To access protected routes, include a valid JWT token in the Authorization
header.
To obtain a token, use the /users/login
route with valid credentials. The response will include a token that should be included in subsequent requests.
This backend logs HTTP requests using the morgan
middleware. Logs are written to an access.log
file.
The backend includes basic error handling for API routes. Errors are returned in a standardized format with appropriate HTTP status codes.