A full-stack web application for managing military/logistics convoys with real-time route optimization, vehicle tracking, and convoy merging suggestions.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Documentation
- Project Structure
- Usage Guide
- Contributing
- License
- โ Create and manage multiple convoys with detailed information
- โ Add vehicles to existing convoys without re-entering convoy details
- โ Real-time convoy tracking and status updates
- โ Priority-based convoy organization (Critical, High, Medium, Low)
- โ Source and destination route visualization
- โ Add, edit, and remove vehicles from convoys
- โ Track vehicle details: type, registration, driver, load capacity
- โ Support for multiple vehicle types (Truck, Van, Jeep, Ambulance, Tanker)
- โ Load type categorization (Medical, Supplies, Ammunition, Fuel, Personnel)
- โ Automatic geocoding of location names using Nominatim
- โ OSRM-based route calculation and optimization
- โ Visual route display on interactive maps
- โ Distance and duration estimation
- โ
Convoy Merge Suggestions: Intelligent algorithm to suggest merging convoys based on:
- Destination proximity
- Available capacity
- Route detour analysis
- Fuel savings calculation
- โ Interactive dashboard with convoy statistics
- โ Real-time convoy filtering by priority
- โ Responsive design for mobile and desktop
- โ JWT-based authentication and authorization
- โ Password hashing with bcrypt
- โ Protected API endpoints
- โ User-specific convoy data
- Framework: FastAPI (Python)
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcrypt
- Geocoding: Nominatim API
- Routing: OSRM (Open Source Routing Machine)
- Framework: React 18
- Build Tool: Vite
- Routing: React Router v6
- Styling: Tailwind CSS
- Maps: Leaflet.js
- Icons: Lucide React
- HTTP Client: Fetch API
Before you begin, ensure you have the following installed:
- Python: 3.8 or higher
- Node.js: 16.x or higher
- npm: 8.x or higher
- PostgreSQL: 12 or higher
- Git: For version control
git clone https://github.com/yourusername/smart-convoy-final.git
cd smart-convoy-finalcd backend
python -m venv .venv
# Activate virtual environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activate
# Install dependencies
pip install fastapi uvicorn psycopg2-binary python-jose passlib bcrypt python-multipart requests pydantic- Create PostgreSQL Database:
psql -U postgres
CREATE DATABASE convoy_db;
\q- Run Schema:
psql -U postgres -d convoy_db -f schema.sqlOr refer to POSTGRES_SETUP_GUIDE.md for detailed instructions.
cd convoy-frontend
npm installCreate a .env file in the backend directory:
# Database
DATABASE_URL=postgresql://postgres:your_password@localhost:5432/convoy_db
# JWT Secret (generate a secure random string)
SECRET_KEY=your-super-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Server
HOST=0.0.0.0
PORT=8000The frontend is configured to connect to http://localhost:8000 by default. If your backend runs on a different port, update the API URLs in the frontend source files.
cd backend
source .venv/bin/activate # Activate virtual environment
uvicorn main:app --reload --host 0.0.0.0 --port 8000The backend will be available at: http://localhost:8000
API documentation: http://localhost:8000/docs
cd convoy-frontend
npm run devThe frontend will be available at: http://localhost:5173
POST /api/auth/signup
Content-Type: application/json
{
"username": "john_doe",
"email": "john@example.com",
"password": "secure_password"
}POST /api/auth/login
Content-Type: application/x-www-form-urlencoded
username=john_doe&password=secure_passwordPOST /api/convoys/create
Authorization: Bearer <token>
Content-Type: application/json
{
"convoy_name": "Medical Supply Alpha",
"source_place": "New Delhi, India",
"destination_place": "Mumbai, India",
"priority": "high",
"vehicles": [
{
"vehicle_type": "truck",
"registration_number": "DL-01-AB-1234",
"load_type": "medical",
"load_weight_kg": 500,
"capacity_kg": 1000,
"driver_name": "Raj Kumar"
}
]
}GET /api/convoys/list
Authorization: Bearer <token>GET /api/convoys/{convoy_id}
Authorization: Bearer <token>POST /api/convoys/add-vehicle/{convoy_id}
Authorization: Bearer <token>
Content-Type: application/json
{
"vehicle_type": "van",
"registration_number": "DL-02-CD-5678",
"load_type": "supplies",
"load_weight_kg": 300,
"capacity_kg": 800,
"driver_name": "Amit Singh",
"current_status": "pending"
}POST /api/convoys/suggest_merge
Content-Type: application/json
{
"convoy_a_id": 1,
"convoy_b_id": 2,
"max_extra_minutes": 30.0,
"same_dest_radius_km": 5.0
}smart-convoy-final/
โโโ backend/
โ โโโ main.py # FastAPI application entry point
โ โโโ db_connection.py # Database connection handler
โ โโโ schema.sql # Database schema
โ โโโ auth/
โ โ โโโ auth.py # Authentication routes
โ โโโ models/
โ โ โโโ convoy.py # Convoy and vehicle models
โ โ โโโ user.py # User model
โ โโโ routers/
โ โ โโโ convoy_routes.py # Convoy API endpoints
โ โโโ utils/
โ โโโ auth_utils.py # JWT utilities
โ โโโ hashing.py # Password hashing
โ
โโโ convoy-frontend/
โ โโโ src/
โ โ โโโ pages/
โ โ โ โโโ Dashboard.jsx # Main dashboard
โ โ โ โโโ CreateConvoy.jsx # Create convoy form
โ โ โ โโโ ConvoyHistory.jsx # Convoy list with add vehicle
โ โ โ โโโ ViewRoute.jsx # Route visualization
โ โ โ โโโ Login.jsx # Login page
โ โ โ โโโ Signup.jsx # Registration page
โ โ โโโ components/
โ โ โ โโโ Navbar.jsx # Navigation bar
โ โ โ โโโ Sidebar.jsx # Sidebar navigation
โ โ โ โโโ ConvoyMap.jsx # Map component
โ โ โ โโโ RouteMap.jsx # Route display
โ โ โโโ App.jsx # Main app component
โ โ โโโ main.jsx # Entry point
โ โโโ package.json
โ โโโ vite.config.js
โ
โโโ .gitignore
โโโ README.md
โโโ POSTGRES_SETUP_GUIDE.md
- Navigate to the signup page
- Create an account with username, email, and password
- Login with your credentials
- Click "New Convoy" from the dashboard
- Enter convoy name and priority
- Add source and destination (e.g., "New Delhi, India")
- Add vehicle details (registration, driver, load, capacity)
- Click "Create Convoy"
- Go to "Convoy History" page
- Find your convoy in the list
- See the route displayed: Source โ Destination
- Click "Add Vehicle" button
- Fill in vehicle details
- Submit to add the vehicle
- Click on any convoy name to view its route
- Interactive map shows the optimized route
- View all vehicle details and load information
- From the dashboard, use the Merge Suggestion panel
- Select two convoys (Convoy A and Convoy B)
- Click "Suggest Merge"
- System analyzes:
- Destination proximity
- Available capacity
- Route detour time
- Fuel savings potential
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Sreeya Chand
- Samyukthaa M
- Prapti
- Aniksha Anithan
- OpenStreetMap for map data
- OSRM for routing engine
- Nominatim for geocoding services
- Leaflet.js for map visualization
- FastAPI community
- React community
For support, open an issue on GitHub.
Made with โค๏ธ for efficient convoy management by Team Delusion