Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚚 SpringBoot Logistics β€” Full-Stack Load & Booking Management System

A modern freight logistics platform connecting Shippers (who post cargo loads) with Transporters (who bid on jobs). Built with Spring Boot backend and React + Tailwind CSS frontend featuring live GPS tracking, role-based access control, and a glassmorphic dark UI.


✨ Features

πŸ” Authentication & Roles

  • JWT-based authentication with secure token management
  • Role selection at registration β€” Shipper, Transporter, or Admin
  • JWT tokens contain user profile (firstname, role) for client-side gating
  • Show/hide password toggle on login/register forms

πŸ“¦ Load Management

  • Shippers/Admins can post new loads with full details:
    • Origin & destination cities
    • Product type, truck type (dropdown), truck count, weight
    • Loading & unloading dates
    • GPS coordinates β€” auto-detected from city name via OpenStreetMap Nominatim geocoder
    • Comments & special instructions
  • All loads display as cards with route, details, status badge, shipment tracker, and live map
  • Soft-delete loads (Shippers can delete own loads only; Admins can delete any)

🀝 Booking / Proposal System

  • Transporters/Admins can submit proposals (proposed rate + terms) on POSTED loads
  • Shippers/Admins can accept or reject proposals from the Bookings Management tab
  • Accepting a booking auto-updates the load status to BOOKED
  • Admins can remove bookings entirely

πŸ“Š Analytics Dashboard

  • Real-time metrics: Total Loads, Active/Unbooked, Dispatched, Secured Revenue (β‚Ή)
  • Fulfillment percentage ring gauge
  • Recent bookings activity feed with color-coded status dots

πŸ—ΊοΈ Live Map Tracking

  • Each load card renders an interactive Leaflet/OpenStreetMap map
  • GPS marker pinned at the load's origin coordinates
  • CartoDB Dark tiles matching the UI theme

πŸ”’ Role-Based UI Gating

Action 🟑 Shipper πŸ”΅ Transporter 🟒 Admin
Post a Load βœ… ❌ βœ…
Submit Proposal ❌ βœ… βœ…
Delete Load βœ… own only ❌ βœ… any
View Bookings tab βœ… ❌ βœ…
Accept/Reject Booking βœ… ❌ βœ…
Remove Booking ❌ ❌ βœ…

πŸ› οΈ Tech Stack

Backend

  • Framework: Spring Boot 3, Spring Data JPA, Spring Security
  • Database: PostgreSQL (Neon DB cloud)
  • Auth: JWT (access + refresh tokens)
  • Caching: Caffeine (in-memory)
  • Docs: springdoc-openapi (Swagger UI)
  • Build: Maven Wrapper

Frontend

  • Framework: React 19 + Vite
  • Styling: Tailwind CSS v4 (glassmorphism dark theme)
  • Maps: React-Leaflet + OpenStreetMap
  • Geocoding: Nominatim (free, no API key)
  • Font: Google Fonts β€” Outfit

βš™οΈ Setup & Run

Prerequisites

  • Java 17+
  • Node.js 18+
  • PostgreSQL (or use the configured Neon DB connection)

1. Clone the repository

git clone https://github.com/Adityarajj23/SpringBoot-Logistics.git
cd SpringBoot-Logistics

2. Configure Database

Edit src/main/resources/application.yml with your PostgreSQL credentials, or use the default Neon DB config.

3. Start Backend (Terminal 1)

.\mvnw.cmd spring-boot:run     # Windows
./mvnw spring-boot:run          # Mac/Linux

Backend runs on: http://localhost:8081

4. Start Frontend (Terminal 2)

cd frontend
npm install
npm run dev

Frontend runs on: http://localhost:5173

5. Open the App

Navigate to http://localhost:5173 in your browser.


πŸ”Ή API Endpoints

Base URL: http://localhost:8081

Swagger UI: http://localhost:8081/swagger-ui.html

πŸ”‘ Auth (/api/auth)

Method Endpoint Description
POST /api/auth/register Register a new user (with role)
POST /api/auth/authenticate Login and receive JWT token

πŸ“¦ Load Management (/api/loads)

Method Endpoint Description
POST /api/loads Create a new load
GET /api/loads Get loads (filter by shipperId, productType, truckType)
GET /api/loads/{loadId} Get a specific load
PUT /api/loads/{loadId} Update a load
DELETE /api/loads/{loadId} Soft-delete a load

🚚 Booking Management (/api/bookings)

Method Endpoint Description
POST /api/bookings Create a booking proposal
GET /api/bookings Get bookings (filter by transporterId, proposedRate)
GET /api/bookings/{id} Get a specific booking
PUT /api/bookings/{id} Update a booking (status change β†’ ACCEPTED triggers load BOOKED)
DELETE /api/bookings/{id} Soft-delete a booking

πŸ“œ Data Models

Load

{
  "id": "UUID",
  "shipperId": "String",
  "productType": "String",
  "truckType": "FLATBED | OPEN_BODY | REEFER | CONTAINER | TANKER | TRAILER",
  "noOfTrucks": "int",
  "weight": "double",
  "comment": "String",
  "status": "POSTED | BOOKED | CANCELLED",
  "currentLat": "Double",
  "currentLng": "Double",
  "facility": {
    "loadPoint": "String",
    "unloadingPoint": "String",
    "loadingDate": "ISO-8601",
    "unloadingDate": "ISO-8601"
  }
}

Booking

{
  "id": "UUID",
  "loadId": "UUID",
  "transporterId": "String",
  "proposedRate": "Double",
  "comment": "String",
  "status": "PENDING | ACCEPTED | REJECTED"
}

πŸ“‚ Project Structure

SpringBoot-Logistics/
β”œβ”€β”€ src/main/java/com/sdeintern1/Logistics/
β”‚   β”œβ”€β”€ Controller/        # REST controllers (LoadController, BookingController)
β”‚   β”œβ”€β”€ DTO/               # Request/Response DTOs
β”‚   β”œβ”€β”€ Entity/            # JPA entities (Load, Booking, User)
β”‚   β”œβ”€β”€ Mapper/            # MapStruct mappers
β”‚   β”œβ”€β”€ Repository/        # Spring Data JPA repositories
β”‚   β”œβ”€β”€ Security/          # JWT auth, filters, config
β”‚   β”œβ”€β”€ Service/           # Business logic
β”‚   └── Specification/     # JPA Specifications for filtering
β”œβ”€β”€ src/main/resources/
β”‚   └── application.yml    # Config (DB, JWT, caching)
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Auth.jsx          # Login/Register with role picker
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx     # Analytics dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ LoadBoard.jsx     # Load cards + Bookings management
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateLoadModal.jsx    # Post load form (with geocoding)
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateBookingModal.jsx # Submit proposal form
β”‚   β”‚   β”‚   β”œβ”€β”€ LiveMap.jsx       # Leaflet map component
β”‚   β”‚   β”‚   └── ShipmentTracker.jsx    # Visual progress tracker
β”‚   β”‚   β”œβ”€β”€ App.jsx         # Main app with JWT auth & routing
β”‚   β”‚   └── index.css       # Tailwind + custom theme
β”‚   └── package.json
└── README.md

πŸ§ͺ Testing Workflow

  1. Register as Shipper (alice@test.com) β†’ Post 2 loads with GPS
  2. Register as Transporter (bob@test.com) β†’ Submit proposals on loads
  3. Register as Admin (admin@test.com) β†’ Accept/reject proposals, verify load status updates
  4. Dashboard β†’ Check real-time analytics (revenue, fulfillment %)

All passwords: use any password you choose (min length enforced).


🧠 Key Design Decisions

  • JWT with embedded claims: firstname and role are encoded in the token, eliminating extra API calls for profile data
  • Frontend role gating: UI buttons/tabs are conditionally rendered based on decoded JWT β€” no backend round-trips
  • Auto-geocoding: City names are resolved to GPS coordinates via free Nominatim API (no API key needed)
  • 204 handling: Backend returns 204 No Content for empty lists; frontend handles gracefully
  • Soft deletes: Both loads and bookings use @SQLDelete for audit-safe deletion

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages