Skip to content

amanxdeep/route-mind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

37 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšš RouteMind

Overview

RouteMind is an intermediate delivery integration microservice designed for e-commerce web applications. It provides a unified API to interact with multiple delivery providers (BlueDart, DTDC, FedEx), enabling seamless order creation, tracking, serviceability checks, and cost estimation. This service acts as a middleware layer, abstracting the complexities of different provider APIs and offering a consistent interface for e-commerce platforms.

As a computer science graduate seeking an internship, this project demonstrates proficiency in Java, Spring Boot, microservices architecture, API integration, database management, and software design patterns.

โœจ Features

Core Functionality

  • ๐Ÿ“ฆ Order Management: Create and retrieve orders with external order IDs for integration with e-commerce platforms.
  • ๐Ÿ“ Shipment Tracking: Real-time tracking of shipments across multiple providers with historical event logging.
  • ๐Ÿ” Serviceability Checks: Verify if delivery is possible between pickup and delivery locations, providing available options.
  • ๐Ÿ’ฐ Cost Estimation: Calculate shipping costs based on weight, distance, service type, and COD charges using provider rate cards.
  • ๐Ÿข Multi-Provider Support: Integrated adapters for BlueDart, DTDC, and FedEx with extensible architecture for additional providers.
  • ๐Ÿ”— Webhook Integration: Receive real-time status updates from providers via webhooks and update internal tracking events.

Technical Features

  • ๐ŸŒ RESTful API: Well-structured REST endpoints with consistent response formats.
  • ๐Ÿ“š API Documentation: Swagger/OpenAPI documentation for easy API exploration and testing.
  • ๐Ÿ—„๏ธ Database Integration: JPA-based persistence with MySQL for orders, shipments, tracking events, and rate cards.
  • ๐Ÿ”„ Object Mapping: MapStruct for type-safe and performant object-to-object mapping.
  • ๐Ÿ›ก๏ธ Error Handling: Comprehensive exception handling with custom error responses.
  • ๐Ÿ“ Logging: Structured logging throughout the application for debugging and monitoring.
  • โœ… Validation: Input validation using Bean Validation annotations.
  • ๐Ÿ”„ Transaction Management: Proper transaction handling for data consistency.

๐Ÿ› ๏ธ Tech Stack

  • โ˜• Language: Java 21
  • ๐ŸŒฑ Framework: Spring Boot 4.0.1
  • ๐Ÿ—„๏ธ Database: MySQL
  • ๐Ÿ”จ Build Tool: Maven
  • ๐Ÿ“– Documentation: SpringDoc OpenAPI (Swagger)
  • ๐Ÿ”„ Object Mapping: MapStruct
  • ๐ŸŒ HTTP Client: Retrofit with OkHttp
  • โš›๏ธ Reactive Programming: Spring WebFlux (WebClient)
  • ๐Ÿ“š Other Libraries:
    • Lombok (for reducing boilerplate code)
    • Spring Boot Starter Web (for REST APIs)
    • Spring Boot Starter Data JPA (for database operations)
    • Spring Boot Starter Validation (for input validation)
    • Spring Boot Starter Actuator (for monitoring and health checks)

Technology Stack Diagram

graph TB
    subgraph Language["Language & Runtime"]
        Java["Java 21"]
    end
    
    subgraph Framework["Framework & Web"]
        SpringBoot["Spring Boot 4.0.1"]
        SpringWeb["Spring Web"]
        SpringJPA["Spring Data JPA"]
        SpringValidation["Spring Validation"]
        SpringActuator["Spring Actuator"]
    end
    
    subgraph Database["Database"]
        MySQL["MySQL Database"]
        JPA["JPA ORM"]
    end
    
    subgraph ApiIntegration["API Integration"]
        Retrofit["Retrofit HTTP Client"]
        OkHttp["OkHttp"]
        WebClient["Spring WebClient"]
    end
    
    subgraph Utilities["Utilities & Libraries"]
        Lombok["Lombok"]
        MapStruct["MapStruct"]
        Swagger["SpringDoc OpenAPI<br/>Swagger UI"]
    end
    
    Java -->|runs| SpringBoot
    SpringBoot -->|uses| SpringWeb
    SpringBoot -->|uses| SpringJPA
    SpringBoot -->|uses| SpringValidation
    SpringBoot -->|uses| SpringActuator
    SpringJPA -->|access| JPA
    JPA -->|connect| MySQL
    SpringBoot -->|uses| Retrofit
    Retrofit -->|uses| OkHttp
    SpringBoot -->|uses| WebClient
    SpringBoot -->|uses| Lombok
    SpringBoot -->|uses| MapStruct
    SpringBoot -->|documents| Swagger
Loading

Project Structure

src/
โ”œโ”€โ”€ main/
โ”‚   โ”œโ”€โ”€ java/
โ”‚   โ”‚   โ””โ”€โ”€ com/example/RouteMind/
โ”‚   โ”‚       โ”œโ”€โ”€ RouteMindApplication.java          # Main Spring Boot application class
โ”‚   โ”‚       โ”œโ”€โ”€ adapter/                           # Adapter pattern for provider integrations
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ DeliveryProviderAdapter.java  # Interface for provider adapters
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ implementation/                # Concrete adapter implementations
โ”‚   โ”‚       โ”‚       โ”œโ”€โ”€ BlueDartAdapter.java
โ”‚   โ”‚       โ”‚       โ”œโ”€โ”€ DtdcAdapter.java
โ”‚   โ”‚       โ”‚       โ””โ”€โ”€ FedexAdapter.java
โ”‚   โ”‚       โ”œโ”€โ”€ client/                            # External API clients
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ fedex/
โ”‚   โ”‚       โ”‚       โ”œโ”€โ”€ FedexApiClient.java       # Retrofit-based FedEx API client
โ”‚   โ”‚       โ”‚       โ””โ”€โ”€ dto/                       # Data transfer objects for FedEx API
โ”‚   โ”‚       โ”œโ”€โ”€ config/                            # Configuration classes
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ClientConfiguration.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ FedexProperties.java
โ”‚   โ”‚       โ”œโ”€โ”€ constants/                         # Application constants
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ApiConstants.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ MapperConstants.java
โ”‚   โ”‚       โ”œโ”€โ”€ controller/                        # REST controllers
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ OrderController.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ServiceabilityController.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ TrackingController.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ WebhookController.java
โ”‚   โ”‚       โ”œโ”€โ”€ dto/                               # Data transfer objects
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Request/                       # Request DTOs
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ Response/                      # Response DTOs
โ”‚   โ”‚       โ”œโ”€โ”€ entity/                            # JPA entities
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ DeliveryProvider.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Order.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ OrderDimensions.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ RateCard.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Serviceability.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ Shipment.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ TrackingEvent.java
โ”‚   โ”‚       โ”œโ”€โ”€ enums/                             # Enumeration classes
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ DeliveryStatus.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ PaymentMode.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProductCategory.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProviderCode.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProviderTag.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ServiceType.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ TransportMode.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ WeightUnit.java
โ”‚   โ”‚       โ”œโ”€โ”€ exception/                         # Custom exceptions
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ GlobalExceptionHandling.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ OrderNotFoundException.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ProviderException.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ RouteMindException.java
โ”‚   โ”‚       โ”œโ”€โ”€ factory/                           # Factory pattern for adapters
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ ProviderFactory.java
โ”‚   โ”‚       โ”œโ”€โ”€ mapper/                            # Object mapping utilities using MapStruct
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ AppModelMapper.java
โ”‚   โ”‚       โ”œโ”€โ”€ repository/                        # JPA repositories
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ DeliveryProviderRepository.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ OrderRepository.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ RateCardRepository.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ServiceabilityRepository.java
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ ShipmentRepository.java
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ TrackingEventRepository.java
โ”‚   โ”‚       โ””โ”€โ”€ service/                           # Business logic services
โ”‚   โ”‚           โ”œโ”€โ”€ EstimationService.java
โ”‚   โ”‚           โ”œโ”€โ”€ OrderDataAccessService.java
โ”‚   โ”‚           โ”œโ”€โ”€ OrderService.java
โ”‚   โ”‚           โ”œโ”€โ”€ ServiceabilityService.java
โ”‚   โ”‚           โ””โ”€โ”€ TrackingService.java
โ”‚   โ””โ”€โ”€ resources/
โ”‚       โ””โ”€โ”€ application.yml                        # Application configuration
โ””โ”€โ”€ test/
    โ””โ”€โ”€ java/
        โ””โ”€โ”€ com/example/RouteMind/
            โ””โ”€โ”€ RouteMindApplicationTests.java     # Basic test class

Architecture

RouteMind follows a layered architecture with clear separation of concerns:

  1. Controller Layer: Handles HTTP requests and responses, delegates to services.
  2. Service Layer: Contains business logic, orchestrates operations across multiple components.
  3. Repository Layer: Manages data persistence using Spring Data JPA.
  4. Adapter Layer: Implements the Adapter pattern for integrating with different delivery providers.
  5. Client Layer: Contains HTTP clients for external API integrations (e.g., FedEx API).

Design Patterns Used

  • Adapter Pattern: For provider-specific integrations
  • Factory Pattern: For creating provider adapters dynamically
  • Repository Pattern: For data access abstraction
  • DTO Pattern: For data transfer between layers
  • Builder Pattern: For constructing complex objects

System Architecture Diagram

graph TB
    subgraph Client["Client Layer"]
        WebApp["E-Commerce Web Application"]
    end
    
    subgraph API["API Gateway Layer"]
        REST["REST API Endpoints"]
    end
    
    subgraph Controllers["Controller Layer"]
        OrderCtrl["OrderController"]
        ServiceCtrl["ServiceabilityController"]
        TrackCtrl["TrackingController"]
        WebhookCtrl["WebhookController"]
    end
    
    subgraph Services["Business Logic Layer"]
        OrderSvc["OrderService"]
        ServiceabilitySvc["ServiceabilityService"]
        TrackingSvc["TrackingService"]
        EstimationSvc["EstimationService"]
        DataAccessSvc["OrderDataAccessService"]
    end
    
    subgraph Adapters["Adapter Pattern Layer"]
        AdapterInterface["DeliveryProviderAdapter<br/>Interface"]
        BlueDartImpl["BlueDartAdapter"]
        DtdcImpl["DtdcAdapter"]
        FedexImpl["FedexAdapter"]
    end
    
    subgraph ExternalAPIs["External APIs"]
        BlueDartAPI["BlueDart API"]
        DtdcAPI["DTDC API"]
        FedexAPI["FedEx API"]
    end
    
    subgraph Persistence["Data Persistence Layer"]
        Repos["Repository Layer<br/>JPA Repositories"]
        MySQL["MySQL Database"]
    end
    
    WebApp -->|HTTP| REST
    REST --> Controllers
    
    OrderCtrl --> OrderSvc
    ServiceCtrl --> ServiceabilitySvc
    TrackCtrl --> TrackingSvc
    WebhookCtrl --> TrackingSvc
    
    OrderSvc --> AdapterInterface
    ServiceabilitySvc --> AdapterInterface
    TrackingSvc --> AdapterInterface
    EstimationSvc --> Repos
    DataAccessSvc --> Repos
    
    AdapterInterface --> BlueDartImpl
    AdapterInterface --> DtdcImpl
    AdapterInterface --> FedexImpl
    
    BlueDartImpl --> BlueDartAPI
    DtdcImpl --> DtdcAPI
    FedexImpl --> FedexAPI
    
    OrderSvc --> DataAccessSvc
    TrackingSvc --> DataAccessSvc
    Repos --> MySQL
Loading

Multi-Provider Adapter Pattern

graph TB
    subgraph Client["Service Layer"]
        OrderService["OrderService<br/>ServiceabilityService<br/>TrackingService"]
    end
    
    subgraph AdapterPattern["Adapter Pattern Implementation"]
        AdapterInterface["<<Interface>><br/>DeliveryProviderAdapter<br/>---<br/>+ checkServiceability()<br/>+ calculateRate()<br/>+ createShipment()<br/>+ trackShipment()<br/>+ cancelShipment()"]
        
        subgraph Implementations["Concrete Implementations"]
            BlueDart["BlueDartAdapter<br/>---<br/>+ getProviderCode()<br/>+ checkServiceability()<br/>+ calculateRate()<br/>+ createShipment()<br/>+ trackShipment()"]
            Dtdc["DtdcAdapter<br/>---<br/>+ getProviderCode()<br/>+ checkServiceability()<br/>+ calculateRate()<br/>+ createShipment()<br/>+ trackShipment()"]
            Fedex["FedexAdapter<br/>---<br/>+ getProviderCode()<br/>+ checkServiceability()<br/>+ calculateRate()<br/>+ createShipment()<br/>+ trackShipment()"]
        end
    end
    
    subgraph Factory["Factory Pattern"]
        ProviderFactory["ProviderFactory<br/>---<br/>+ getAdapter(ProviderCode)<br/>Returns appropriate adapter<br/>based on provider code"]
    end
    
    OrderService -->|uses| ProviderFactory
    ProviderFactory -->|instantiates| AdapterInterface
    AdapterInterface -->|implements| BlueDart
    AdapterInterface -->|implements| Dtdc
    AdapterInterface -->|implements| Fedex
    
    BlueDart -.->|calls| BlueDartAPI["BlueDart API"]
    Dtdc -.->|calls| DtdcAPI["DTDC API"]
    Fedex -.->|calls| FedexAPI["FedEx API"]
Loading

Database Schema Diagram

graph TB
    Orders["ORDERS<br/>---<br/>id (PK)<br/>external_order_id<br/>status<br/>pickup_address<br/>delivery_address<br/>created_at<br/>updated_at"]
    
    Shipments["SHIPMENTS<br/>---<br/>id (PK)<br/>order_id (FK)<br/>provider_id (FK)<br/>tracking_id<br/>status<br/>estimated_delivery<br/>actual_delivery"]
    
    TrackingEvents["TRACKING_EVENTS<br/>---<br/>id (PK)<br/>shipment_id (FK)<br/>status<br/>location<br/>description<br/>timestamp<br/>source"]
    
    Providers["DELIVERY_PROVIDERS<br/>---<br/>id (PK)<br/>provider_code<br/>provider_tag<br/>name<br/>api_key<br/>api_secret"]
    
    RateCards["RATE_CARDS<br/>---<br/>id (PK)<br/>provider_id (FK)<br/>service_type<br/>origin<br/>destination<br/>base_price<br/>weight_slab<br/>price_per_kg"]
    
    Serviceability["SERVICEABILITY<br/>---<br/>id (PK)<br/>provider_id (FK)<br/>origin<br/>destination<br/>is_serviceable<br/>service_types"]
    
    OrderDimensions["ORDER_DIMENSIONS<br/>---<br/>id (PK)<br/>order_id (FK)<br/>length<br/>width<br/>height<br/>weight<br/>weight_unit"]
    
    Orders -->|1:N| Shipments
    Shipments -->|N:1| Providers
    Shipments -->|1:N| TrackingEvents
    Providers -->|1:N| RateCards
    Providers -->|1:N| Serviceability
    Orders -->|1:1| OrderDimensions
Loading

๐Ÿ”Œ API Endpoints

Order Management

  • POST /api/v1/orders - Create a new order
  • GET /api/v1/orders/{id} - Get order by internal ID
  • GET /api/v1/orders/external/{externalOrderId} - Get order by external ID

Tracking

  • GET /api/v1/tracking/{trackingId} - Track shipment by tracking ID

Serviceability

  • POST /api/v1/serviceability - Check delivery serviceability and get options

Webhooks

  • POST /api/v1/webhooks/bluedart - Receive BlueDart status updates
  • POST /api/v1/webhooks/delhivery - Receive Delhivery status updates
  • POST /api/v1/webhooks/dtdc - Receive DTDC status updates
  • POST /api/v1/webhooks/fedex - Receive FedEx status updates

API Endpoints Overview Diagram

graph TB
    subgraph Container["RouteMind API v1"]
        subgraph Orders["Orders API<br/>/api/v1/orders"]
            Create["POST /<br/>Create Order"]
            GetById["GET /{id}<br/>Get by ID"]
            GetByExtId["GET /external/{extId}<br/>Get by External ID"]
        end
        
        subgraph Serviceability["Serviceability API<br/>/api/v1/serviceability"]
            CheckService["POST /check<br/>Check if serviceable"]
        end
        
        subgraph Tracking["Tracking API<br/>/api/v1/tracking"]
            Track["GET /{trackingId}<br/>Track Shipment"]
        end
        
        subgraph Webhooks["Webhooks<br/>/api/v1/webhooks"]
            ShipmentStatus["POST /shipment-status<br/>Handle Status Update"]
            Delivery["POST /delivery<br/>Handle Delivery Update"]
        end
    end
    
    Client["E-Commerce App"] -->|REST| Container
    Providers["Delivery Providers"] -->|Webhooks| Webhooks
Loading

๐Ÿš€ Setup and Installation

Prerequisites

  • โ˜• Java 21 or higher
  • ๐Ÿ”จ Maven 3.6+
  • ๐Ÿ—„๏ธ MySQL 8.0+

Steps

  1. ๐Ÿ“ฅ Clone the repository:

    git clone https://github.com/amanxdeep/route-mind.git
    cd route-mind
  2. โš™๏ธ Configure the database:

    • Create a MySQL database named routemind_db
    • Update src/main/resources/application.yml with your database credentials
  3. ๐Ÿ”ง Configure FedEx API (optional):

    • Obtain FedEx API credentials
    • Update the fedex section in application.yml
  4. ๐Ÿ”จ Build the application:

    ./mvnw clean compile

    Note: The project uses MapStruct for object mapping, which requires annotation processing during compilation. The Maven compiler plugin is configured to include Lombok and MapStruct processors.

  5. โ–ถ๏ธ Run the application:

    ./mvnw spring-boot:run
  6. ๐ŸŒ Access the application:

    • API Base URL: http://localhost:8080/route-mind
    • Swagger Documentation: http://localhost:8080/route-mind/swagger-ui.html

Configuration

Key configuration properties in application.yml:

  • Server: Port 8080, context path /route-mind
  • Database: MySQL connection details
  • JPA: Hibernate settings with SQL logging
  • FedEx: API credentials and endpoints

Database Schema

The application uses the following main entities:

  • Order: Represents customer orders
  • Shipment: Links orders to provider shipments
  • TrackingEvent: Stores tracking history
  • RateCard: Provider pricing information
  • Serviceability: Delivery availability by pincode
  • DeliveryProvider: Provider configuration

๐Ÿ“Š Monitoring

The application includes Spring Boot Actuator for monitoring:

  • Health checks: /actuator/health
  • Metrics: /actuator/metrics
  • Info: /actuator/info

๐Ÿ”ฎ Future Enhancements

  • Complete implementation of BlueDart and DTDC API integrations
  • Add more delivery providers
  • Implement rate limiting and circuit breakers
  • Add comprehensive unit and integration tests
  • Implement authentication and authorization
  • Add message queuing for better webhook handling
  • Implement caching strategies for improved performance

๐Ÿค Contributing

This project demonstrates key software engineering concepts suitable for internship applications:

  • Clean architecture and separation of concerns
  • Design patterns implementation
  • RESTful API design
  • Database design and ORM usage
  • External API integration
  • Error handling and logging
  • Configuration management

License

This project is for educational and portfolio purposes.


๐Ÿ‘ค Author

Amandeep Kumar
Computer Science Graduate | Backend Developer | Microservices Enthusiast


๐Ÿ“ž Support

For questions or issues, please:

  • Check the troubleshooting section
  • Review application logs
  • Create an issue on GitHub

Last Updated: April 2026
Current Version: 0.0.1-SNAPSHOT

About

RouteMind is a comprehensive shipping and logistics management system that simplifies the integration of multiple courier services into a single, unified API. The platform enables businesses to manage shipments, track deliveries, and compare shipping options across various providers.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages