Skip to content

DevPanchal2610/LogiTrack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚚 LogiTrack β€” Supply Chain & Shipment Tracking System

Java Spring Boot Spring Security MySQL React JWT

A full-stack, AI-powered shipment tracking platform with real-time notifications, role-based access control, and live data sync across all user sessions.


πŸ“Œ What is LogiTrack?

LogiTrack is a production-grade supply chain management system that allows Admins, Vendors, and Customers to manage and track shipments in real time. It features an AI support chatbot that understands your shipment data, live push notifications using Server-Sent Events (SSE), automated email alerts on status changes, and a complete audit trail for every shipment lifecycle event.


✨ Key Features

Feature Description
πŸ” JWT Authentication Stateless, token-based auth with BCrypt password hashing
πŸ‘₯ Role-Based Access Control Separate dashboards and permissions for Admin, Vendor, Customer
πŸ“¦ Shipment Lifecycle Management Full status-transition tracking from CREATED β†’ DELIVERED
πŸ€– AI Support Chatbot Powered by Spring AI + Groq API β€” answers questions using live DB data
πŸ“‘ Real-Time SSE Sync All pages auto-refresh across every logged-in session without manual reload
πŸ”” Live Notifications Role-specific push notifications with click-through navigation
πŸ“§ Email Notifications Async email alerts to vendor and customer on every status update
πŸ—‚οΈ Audit Trail Every status change is recorded with timestamp, location, and actor
πŸ›‘οΈ Shipment Authorization Users can only access shipments they own β€” 403 on unauthorized access
πŸ“Š Admin Analytics Live charts showing delivery rates, vendor performance, monthly trends

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    React Frontend                       β”‚
β”‚   Dashboard β”‚ Shipments β”‚ Track β”‚ Admin Panel β”‚ Chatbot β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚ REST API + SSE
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 Spring Boot Backend                     β”‚
β”‚                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Auth      β”‚  β”‚  Shipment    β”‚  β”‚  Notification  β”‚  β”‚
β”‚  β”‚ Controller  β”‚  β”‚  Controller  β”‚  β”‚   Controller   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                β”‚                  β”‚           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Auth      β”‚  β”‚  Shipment    β”‚  β”‚  Notification  β”‚  β”‚
β”‚  β”‚  Service    β”‚  β”‚  Service     β”‚  β”‚   Service      β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                β”‚                  β”‚           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚              Spring Data JPA / Hibernate           β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                            β”‚                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚  Spring Security + JWT Filter Chain                 β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     MySQL Database                      β”‚
β”‚   users β”‚ shipments β”‚ shipment_status_history           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ€– AI Chatbot β€” How It Works

The chatbot is not a generic assistant. Every time a user sends a message, the backend:

  1. Fetches live shipment data from the database for that specific user
  2. Builds a context-aware system prompt injecting real tracking numbers, statuses, and locations
  3. Sends it to Groq API (LLaMA 3.3 70B) via Spring AI
  4. Returns a role-specific, data-aware response
User: "Where is my package?"
         ↓
ChatController β†’ ChatService
         ↓
Fetch shipments from DB for this user
         ↓
Build system prompt with live data
         ↓
Groq API (LLaMA 3.3) β†’ generates response
         ↓
"Your shipment LGT-A1B2C3 is currently IN TRANSIT at Surat Hub, Gujarat."

πŸ“‘ Real-Time Architecture (SSE)

Admin updates shipment status
         ↓
ShipmentService.updateStatus()
         ↓
NotificationService.sendToUser(customerId)   ← Customer gets notified
NotificationService.sendToUser(vendorId)     ← Vendor gets notified  
NotificationService.sendToAll()              ← Admins get notified
         ↓
Server-Sent Events push to all open browser tabs
         ↓
React NotifContext receives event
         ↓
All pages auto-refresh + bell icon updates instantly

πŸ—„οΈ Database Schema

users
β”œβ”€β”€ id, email, password, full_name, phone, role, created_at

shipments
β”œβ”€β”€ id, tracking_number (UNIQUE), description
β”œβ”€β”€ origin_address, destination_address, weight_kg
β”œβ”€β”€ current_status, vendor_id (FK), customer_id (FK)
β”œβ”€β”€ created_at, estimated_delivery, actual_delivery

shipment_status_history   ← Full audit trail
β”œβ”€β”€ id, shipment_id (FK), status, location
β”œβ”€β”€ remarks, updated_by (FK), changed_at

πŸ”„ Shipment Lifecycle

CREATED β†’ PICKED_UP β†’ IN_TRANSIT β†’ OUT_FOR_DELIVERY β†’ DELIVERED
                                                     β†˜ FAILED_DELIVERY β†’ RETURNED β†’ CANCELLED

πŸ› οΈ Tech Stack

Backend

  • Java 17 + Spring Boot 3.2
  • Spring Security 6.2 β€” JWT stateless authentication
  • Spring Data JPA + Hibernate β€” ORM and DB interactions
  • Spring AI β€” AI chatbot integration
  • Spring Mail β€” Async email notifications
  • Server-Sent Events (SSE) β€” Real-time push to frontend
  • MySQL 8 β€” Relational database

Frontend

  • React 18 + React Router v6
  • Vite β€” Build tool with dev proxy
  • Axios β€” API calls with JWT interceptor
  • EventSource API β€” SSE connection for live sync

AI & External

  • Groq API (LLaMA 3.3 70B) β€” Free, fast AI inference
  • Spring AI β€” Provider-agnostic AI abstraction layer

πŸš€ Getting Started

Prerequisites

  • Java 17+
  • MySQL 8+
  • Node.js 18+

Backend Setup

# 1. Clone the repository
git clone https://github.com/DevPanchal2610/LogiTrack.git
cd LogiTrack/logitrack

# 2. Create MySQL database
mysql -u root -p
CREATE DATABASE logitrack_db;
exit

# 3. Configure application.properties
spring.datasource.username=your_mysql_username
spring.datasource.password=your_mysql_password
groq.api.key=your_groq_api_key     # Free at console.groq.com
spring.mail.username=your_email
spring.mail.password=your_app_password

# 4. Run
./mvnw spring-boot:run

Frontend Setup

cd LogiTrack/logitrack-frontend

npm install
npm run dev

App runs at http://localhost:3000 β€” backend at http://localhost:8080


πŸ“‹ API Reference

Auth (Public)

Method Endpoint Description
POST /api/auth/register Register (ADMIN / VENDOR / CUSTOMER)
POST /api/auth/login Login β†’ returns JWT token

Shipments

Method Endpoint Role Description
POST /api/shipments/create Vendor, Admin Create shipment
PUT /api/shipments/{id}/status Vendor, Admin Update status
GET /api/shipments/track/{trackingNo} Public Track by tracking number
GET /api/shipments/my All Get my shipments
GET /api/shipments/{id} Owner only Get shipment detail

AI Chat

Method Endpoint Description
POST /api/chat/message Send message β†’ AI response with live DB context

Real-Time

Method Endpoint Description
GET /api/notifications/subscribe Open SSE stream for live notifications

Admin Only

Method Endpoint Description
GET /api/admin/shipments All shipments
GET /api/admin/users All users
GET /api/admin/analytics System analytics

πŸ‘₯ Roles & Permissions

Feature Admin Vendor Customer
View all shipments βœ… ❌ ❌
Create shipment βœ… βœ… ❌
Update shipment status βœ… βœ… ❌
View own shipments βœ… βœ… βœ…
Track by tracking number βœ… βœ… βœ…
Manage users βœ… ❌ ❌
View analytics βœ… ❌ ❌
AI Chatbot βœ… βœ… βœ…

πŸ“ Project Structure

logitrack/
β”œβ”€β”€ src/main/java/com/logitrack/
β”‚   β”œβ”€β”€ config/          # Security configuration
β”‚   β”œβ”€β”€ controller/      # REST controllers + SSE
β”‚   β”œβ”€β”€ dto/             # Request/Response DTOs
β”‚   β”œβ”€β”€ entity/          # JPA entities
β”‚   β”œβ”€β”€ enums/           # Role, ShipmentStatus
β”‚   β”œβ”€β”€ exception/       # Global exception handler
β”‚   β”œβ”€β”€ repository/      # Spring Data repositories
β”‚   β”œβ”€β”€ security/        # JWT filter + utils
β”‚   └── service/         # Business logic
β”‚       └── impl/
└── src/main/resources/
    └── application.properties

logitrack-frontend/
└── src/
    β”œβ”€β”€ components/      # Sidebar, Topbar, AI Chatbot
    β”œβ”€β”€ context/         # AuthContext, NotifContext (SSE)
    β”œβ”€β”€ hooks/           # useDataSync (live refresh)
    β”œβ”€β”€ pages/           # Dashboard, Shipments, Admin, Track
    └── services/        # Axios API + SSE stream

πŸ™‹ Author

Dev Panchal


⭐ If you found this project useful, please give it a star!

About

LogiTrack is a full-stack web application for managing and tracking shipments in real-time. It provides comprehensive logistics management with user authentication, shipment tracking, and admin analytics.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors