Skip to content

πŸš— PitStop Backend β€” A scalable microservices-based backend for the PitStop app, providing fuel delivery, emergency services, and location-aware support. Built with Spring Boot, Spring Cloud, Eureka, and MySQL for real-time service orchestration and data management.

Notifications You must be signed in to change notification settings

srivilliamsai/pitstop-backend

Repository files navigation

βš™οΈ PitStop Backend

Microservices-based Backend for On-Demand Roadside Assistance & Fuel Delivery Platform


πŸš€ Overview

PitStop Backend is a Java Spring Boot microservices architecture designed to power the PitStop mobile app β€” a futuristic platform offering real-time roadside assistance, fuel delivery, emergency help, BNPL (Buy-Now-Pay-Later) payments, and intelligent analytics.

Each microservice is modular, independently deployable, and communicates securely through REST and Feign clients via an API Gateway. The backend ensures scalability, fault tolerance, and high availability using the Spring Cloud Netflix Stack.


🧱 Core Features

  • 🧩 Microservices Architecture
    • Fully decoupled domain-based services (User, Order, Payment, BNPL, etc.)
  • πŸ›° Spring Cloud Integration
    • Eureka Discovery Server
    • Config Server
    • API Gateway (Routing + Load Balancing)
  • 🧾 RESTful API Design
    • Clean controller-service-repo structure with DTOs
    • Unified JSON responses and exception handling
  • πŸ” Secure Authentication
    • JWT-based user authentication and role-based authorization
  • ⚑ Asynchronous Communication
    • Feign clients for inter-service calls
    • RabbitMQ or internal REST integration (optional)
  • πŸ“Š Analytics & Monitoring
    • Analytics service for logs, metrics, and usage tracking
  • 🧠 BNPL Integration
    • Split payments and deferred payment logic for fuel or services
  • πŸ“¨ Notification Service
    • Email/SMS/Push event triggers for orders and emergencies
  • 🧰 Swagger Documentation
    • Auto-generated API docs per service at /swagger-ui.html

πŸ—‚οΈ Folder Structure

pitstop-backend/
β”‚
β”œβ”€β”€ config-server/            # Centralized config management
β”‚   └── src/main/resources/
β”‚       └── application.yml
β”‚
β”œβ”€β”€ discovery-server/         # Eureka service registry
β”‚   └── src/main/resources/
β”‚       └── application.yml
β”‚
β”œβ”€β”€ api-gateway/              # API routing and authentication entrypoint
β”‚   └── src/main/resources/
β”‚       └── application.yml
β”‚
β”œβ”€β”€ common-lib/               # Shared DTOs and utility classes
β”‚   └── src/main/java/com/pitstop/common/
β”‚
β”œβ”€β”€ user-service/             # Handles user accounts, profiles, JWT
β”‚   β”œβ”€β”€ controller/
β”‚   β”œβ”€β”€ service/
β”‚   β”œβ”€β”€ repository/
β”‚   β”œβ”€β”€ entity/
β”‚   β”œβ”€β”€ dto/
β”‚   └── application.yml
β”‚
β”œβ”€β”€ order-service/            # Manages fuel orders, requests, tracking
β”‚   β”œβ”€β”€ controller/
β”‚   β”œβ”€β”€ service/
β”‚   β”œβ”€β”€ repository/
β”‚   β”œβ”€β”€ feign/
β”‚   β”œβ”€β”€ entity/
β”‚   β”œβ”€β”€ dto/
β”‚   └── application.yml
β”‚
β”œβ”€β”€ payment-service/          # Handles transactions, BNPL, gateways
β”œβ”€β”€ bnpl-service/             # Deferred billing logic
β”œβ”€β”€ mechanic-service/         # Mechanic and service provider registry
β”œβ”€β”€ emergency-service/        # Emergency call and dispatch
β”œβ”€β”€ notification-service/     # Notification management
β”œβ”€β”€ analytics-service/        # Data logs, metrics, usage analytics
β”‚
β”œβ”€β”€ pom.xml                   # Parent Maven config
└── README.md

🧰 Tech Stack

Layer Technology Description
Language Java 8 Modern, type-safe JVM language
Framework Spring Boot 2.7.x Microservice foundation
Cloud Tools Spring Cloud Netflix Eureka, Gateway, Config
Build Tool Maven 3.9.x Multi-module dependency management
Security Spring Security + JWT Authentication & Authorization
Database MySQL 8 Persistent data store
API Docs Swagger / OpenAPI Auto API documentation
Testing JUnit 5 + Mockito Unit and integration tests
CI/CD GitHub Actions / Docker Automated build & deploy
Monitoring Spring Actuator Service health endpoints

🌐 Microservice List

Service Port Description
Config Server 8888 Central configuration management
Discovery Server (Eureka) 8761 Service registry
API Gateway 8080 Unified routing and authentication layer
User Service 8081 Manages user authentication and profiles
Order Service 8082 Handles orders, requests, and tracking
Payment Service 8083 Processes transactions
BNPL Service 8084 Manages deferred payments
Mechanic Service 8085 Mechanic and workshop data
Emergency Service 8086 Emergency dispatch and assistance
Notification Service 8087 Email/SMS/push notifications
Analytics Service 8088 Logging and analytics

βš™οΈ Configuration Management

πŸ”§ config-server

Holds all shared configurations in one repository:

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/srivilliamsai/pitstop-config-repo

Each service connects to it:

spring:
  config:
    import: optional:configserver:http://localhost:8888

πŸ” Authentication (JWT)

  • Login β†’ Generates a JWT token
  • Token β†’ Attached to all service requests via headers
  • Gateway validates token β†’ routes request only if valid
  • Role-based authorization for admin, mechanic, and user

Example Header:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6...

πŸ“‘ Inter-Service Communication

Services communicate using OpenFeign Clients:

@FeignClient(name = "payment-service")
public interface PaymentClient {
    @PostMapping("/payments/process")
    PaymentResponse processPayment(@RequestBody PaymentRequest request);
}

πŸ§ͺ Testing Setup

Each service includes:

  • βœ… Unit tests with JUnit 5
  • πŸ” Mocked dependencies using Mockito
  • πŸ“Š Code coverage with JaCoCo

Example:

src/test/java/com/pitstop/user/service/UserServiceTest.java

🧠 Swagger Documentation

Available per service at: http://localhost:<port>/swagger-ui.html

Example:

  • User Service β†’ http://localhost:8081/swagger-ui.html
  • Order Service β†’ http://localhost:8082/swagger-ui.html

πŸš€ Running the Project

Step 1 β€” Build Parent

mvn clean install -DskipTests

Step 2 β€” Start Config & Discovery

(In separate terminals)

cd config-server
mvn spring-boot:run
cd ../discovery-server
mvn spring-boot:run

Step 3 β€” Start All Services

(In separate terminals)

cd ../api-gateway
mvn spring-boot:run
# Start other services
mvn spring-boot:run -pl user-service
mvn spring-boot:run -pl order-service
mvn spring-boot:run -pl payment-service
# ... and so on for all other services

🧩 API Example

POST /orders/create

Request:

{
  "userId": "U001",
  "serviceType": "Fuel Delivery",
  "location": "Anna Salai, Chennai",
  "paymentMode": "BNPL"
}

Response:

{
  "orderId": "O12345",
  "status": "CONFIRMED",
  "eta": "15 mins"
}

πŸ“¦ Deployment

🐳 Docker Setup

Each service has a Dockerfile:

docker build -t pitstop-user-service .
docker run -p 8081:8081 pitstop-user-service

☁️ Cloud Deployment

  • Oracle Cloud Infrastructure / AWS ECS / Render
  • Use docker-compose.yml or Kubernetes YAML for orchestration

🧠 Future Enhancements

  • πŸ”‹ Service Mesh (Istio / Linkerd)
  • πŸ“Š Centralized ELK logging stack
  • πŸ” OAuth2 + Refresh Token flow
  • 🧠 AI-driven emergency prediction model integration
  • πŸš— Integration with vehicle telematics APIs

πŸ‘¨β€πŸ’» Author

Sri Villiam Sai Ayyappan B.Tech (Information Technology) | SRM Valliammai Engineering College
πŸ“ Chennai, India
πŸ”— LinkedIn πŸ”— GitHub


🏁 License

This project is licensed under the MIT License β€” see the LICENSE file for details.

β€œPowering safer journeys through intelligent service architecture β€” PitStop Backend.” βš™οΈ

About

πŸš— PitStop Backend β€” A scalable microservices-based backend for the PitStop app, providing fuel delivery, emergency services, and location-aware support. Built with Spring Boot, Spring Cloud, Eureka, and MySQL for real-time service orchestration and data management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages