Skip to content

Eshwar863/AR-Car-Showcase-Server

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ–₯️ AR Car Showcase β€” Server

The backend for the AR Car Showcase mobile application. Built with Spring Boot (Java 17) and a Python microservice for 3D model processing. Exposes a RESTful API for car data, user authentication, customization, and AI-powered recommendations.


πŸ› οΈ Tech Stack

Layer Technology
Core API Spring Boot 3.x (Java 17)
Build Tool Maven
Security Spring Security + JWT
Database PostgreSQL / MySQL (JPA/Hibernate)
3D Processing Python 3.x + Flask + Blender headless
Recommendation Engine Java (Spring Service) + Python ML
Static Model Hosting Spring Boot Static Resources

✨ Features

  • πŸ” JWT Authentication – Stateless sign-in/sign-up with token-based session management
  • πŸš— Car Catalog API – Full CRUD for car data with filtering by brand, body type, fuel type, and budget
  • 🎨 3D Customization Engine – Triggers a Python/Blender microservice to generate custom GLB models
  • πŸ€– Recommendation Engine – Personalized car suggestions based on user preferences and viewing history
  • πŸ’Ύ Customization Persistence – Saves and retrieves user-specific design configurations
  • 🌐 Cross-Origin Support – Configured for React Native / Expo mobile client

πŸ—οΈ System Architecture

graph TB
    subgraph "Mobile Client (React Native / Expo)"
        UI["User Interface"]
        API_Client["Fetch / AsyncStorage"]
    end

    subgraph "Spring Boot Core Server (Java 17)"
        AuthController["AuthController\n/api/auth/**"]
        CarController["CarController\n/api/cars/**"]
        CustomController["CustomizationController\n/api/customizations/**"]
        RecController["RecommendationController\n/api/recommendations/**"]

        AuthService["AuthService"]
        CarService["CarService"]
        CustomService["CustomizationService"]
        RecService["RecommendationService"]

        JwtFilter["AuthTokenFilter (JWT)"]
        SecurityConfig["WebSecurityConfig"]

        CarRepo["CarRepository (JPA)"]
        UserRepo["UserRepository (JPA)"]
        CustomRepo["CustomizationRepository (JPA)"]
    end

    subgraph "Microservices"
        BlenderSvc["Blender Service\n(Python/Flask :5000)"]
        MLSvc["Recommendation ML\n(Python :8000)"]
    end

    DB[(PostgreSQL)]
    ModelStore[("Static .glb Files\n/resources/static/models")]

    API_Client <--> AuthController
    API_Client <--> CarController
    API_Client <--> CustomController
    API_Client <--> RecController

    JwtFilter --> SecurityConfig

    AuthController --> AuthService
    CarController --> CarService
    CustomController --> CustomService
    RecController --> RecService

    AuthService --> UserRepo
    CarService --> CarRepo
    CustomService --> CustomRepo
    CustomService --> BlenderSvc
    RecService --> MLSvc

    CarRepo --> DB
    UserRepo --> DB
    CustomRepo --> DB

    BlenderSvc --> ModelStore
    ModelStore --> API_Client
Loading

πŸ”„ Sequence Diagram: Authentication Flow

sequenceDiagram
    participant U as User
    participant UI as LoginScreen
    participant AC as AuthContext
    participant CL as API Client
    participant S as Spring Boot Server
    participant AS as AsyncStorage

    U->>UI: Enter Credentials
    UI->>AC: signIn(user, pass)
    AC->>CL: post('/auth/signin')
    CL->>S: POST /api/auth/signin
    S-->>CL: Response (JWT + User Data)
    CL-->>AC: Adapted Data

    alt Success
        AC->>AS: Save Token & User Body
        AC->>UI: Update Auth State
        UI->>U: Navigate to Home
    else Failure
        AC->>UI: Return Error Message
        UI->>U: Display Alert
    end
Loading

πŸ”„ Sequence Diagram: 3D Studio & AR Flow

sequenceDiagram
    participant U as User
    participant HS as HybridScreen (3D Studio)
    participant CC as CarContext (React)
    participant CD as CustomizationDrawer
    participant AR as ARHybridScene (Viro)
    participant BV as Blender Microservice (Python)

    U->>HS: Select Car from Catalog
    HS->>CC: updateVehicle(carData)
    U->>HS: Toggle Customizer Workspace
    HS->>CD: mount(isPickerVisible=true)

    U->>CD: Modify Material Color (e.g. #FF0000)
    CD->>CC: updateMaterialColor(part, color)
    CC-->>HS: trigger(r3f-re-render)
    HS->>HS: Apply Material to Mesh Object

    U->>HS: Click "Apply to AR"
    HS->>BV: generateCustomModel(vehicleId, materials)
    activate BV
    BV->>BV: Load Base .blend
    BV->>BV: Update Cycles/Eevee Materials
    BV->>BV: Export .glb Stream
    BV-->>HS: Return Model Metadata & Filename
    deactivate BV

    HS->>HS: setGeneratedModelUrl(newUrl)
    HS->>AR: mount(viroAppProps)
    AR->>AR: initialize(ARSession)
    AR->>AR: fetch(customModelUrl)
    AR-->>U: Project Customized Car in AR
Loading

πŸ”„ Sequence Diagram: Recommendation & Search Flow

sequenceDiagram
    participant U as User
    participant SC as Search/Home Screen
    participant AC as AuthContext
    participant RA as Recommendation API
    participant S as Spring Boot Server
    participant RE as Java Recommendation Engine

    U->>SC: Enter Search Query / View Home
    SC->>AC: Get User Preferences
    SC->>RA: getUserRecommendations()
    RA->>S: GET /api/recommendations/personalized
    S->>RE: Query Preferred Matches
    RE-->>S: List of Recommended Cars
    S-->>RA: JSON Data
    RA-->>SC: Map to UI Components
    SC->>U: Display "Recommended for You"

    U->>SC: Click on a Car
    SC->>RA: trackInteraction(carId, 'view')
    RA->>S: POST /api/recommendations/feedback
    S->>RE: Update User Behavior Model
Loading

πŸ“Š Class Diagram: Core Logic

classDiagram
    class AuthController {
        +authenticateUser(LoginRequest) ResponseEntity
        +registerUser(SignupRequest) ResponseEntity
    }

    class CarController {
        +allCars() ResponseEntity~List~Car~~
        +getCarsById(id) Car
        +allBrands() ResponseEntity~List~String~~
        +allModels(brand) ResponseEntity
        +allVariants(brand, model) ResponseEntity
        +getVariant(brand, model, variant) ResponseEntity
    }

    class CustomizationController {
        +createCustomization(CustomizationRequest) ResponseEntity
        +getUserCustomizations() ResponseEntity
    }

    class AuthService {
        +authenticateUser(LoginRequest) JwtResponse
        +registerUser(SignupRequest) MessageResponse
    }

    class CarService {
        <<interface>>
        +GetAllCars() List~Car~
        +searchCars(keyword) List~Car~
        +getCarsById(id) Car
        +getAllBrands() List~String~
        +getAllModels(brand) List~String~
        +getAllVariants(brand, model) List~CarVariant~
        +getVariant(brand, model, variant) CarVariant
    }

    class CustomizationService {
        +createCustomization(CustomizationRequest) CustomizationResponse
        +getUserCustomizations() List~CustomizationResponse~
    }

    class RecommendationService {
        +getRecommendedCars(carId) List~Car~
        +getPersonalizedRecommendations(userId) List~Car~
    }

    class User {
        +Long id
        +String username
        +String email
        +String password
        +String phoneNumber
        +String profilePic
        +Set~String~ favBrands
        +Set~String~ preferredBodyTypes
        +Set~String~ preferredFuelTypes
        +Set~String~ preferredTransmissions
        +String drivingCondition
        +Double maxBudget
        +Set~Role~ roles
    }

    class Car {
        +Long id
        +String brand
        +String model
        +String fuelType
        +String transmissionType
        +String bodyType
        +Double minPriceLakhs
        +Double maxPriceLakhs
        +String modelUrl
    }

    class Customization {
        +UUID id
        +User user
        +String vehicleId
        +String materials
        +String modelUrl
        +LocalDateTime createdAt
    }

    class JwtUtils {
        +generateJwtToken(auth) String
        +validateJwtToken(token) boolean
        +getUserNameFromJwtToken(token) String
    }

    class AuthTokenFilter {
        +doFilterInternal(req, res, chain) void
    }

    AuthController --> AuthService
    CarController --> CarService
    CustomizationController --> CustomizationService
    AuthService --> JwtUtils
    AuthService --> User
    CarService --> Car
    CustomizationService --> Customization
    Customization --> User
    AuthTokenFilter --> JwtUtils
Loading

πŸ” State Machine Diagram

stateDiagram-v2
    [*] --> Guest_State

    state Guest_State {
        [*] --> Home_Browse
        Home_Browse --> Details_View
        Details_View --> Home_Browse
        Details_View --> 3D_Studio_Limited
    }

    Guest_State --> Authenticated_State : Login Success

    state Authenticated_State {
        [*] --> Dashboard
        Dashboard --> Customization_Studio
        Customization_Studio --> AR_Mode
        AR_Mode --> Customization_Studio

        Dashboard --> Comparison_Tool
        Dashboard --> Personal_Showroom

        state Customization_Studio {
            [*] --> Exterior_View
            Exterior_View --> Interior_View
            Interior_View --> Exterior_View
        }
    }

    Authenticated_State --> Guest_State : Logout
Loading

πŸ“‚ Project Structure

AR-Car-Showcase-Server/
β”‚
β”œβ”€β”€ src/
β”‚   └── main/
β”‚       β”œβ”€β”€ java/com/arcarshowcaseserver/
β”‚       β”‚   β”œβ”€β”€ controller/           # REST Controllers (Auth, Car, Customization, Recommendation)
β”‚       β”‚   β”œβ”€β”€ service/              # Business logic layer
β”‚       β”‚   β”œβ”€β”€ repository/           # Spring Data JPA repositories
β”‚       β”‚   β”œβ”€β”€ model/                # JPA Entities (User, Car, Customization)
β”‚       β”‚   β”œβ”€β”€ payload/              # Request/Response DTOs
β”‚       β”‚   β”œβ”€β”€ security/             # JWT utils, AuthTokenFilter, WebSecurityConfig
β”‚       β”‚   └── ArCarShowcaseServerApplication.java
β”‚       └── resources/
β”‚           β”œβ”€β”€ application.properties
β”‚           β”œβ”€β”€ static/models/        # Hosted .glb 3D model files
β”‚           └── data/cars_data_final.json  # Car catalog seed data
β”‚
β”œβ”€β”€ blender-service/                  # Python Flask microservice
β”‚   β”œβ”€β”€ server.py                     # Flask API entry point
β”‚   β”œβ”€β”€ generate.py                   # Blender headless script
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ car-recommendation-service/       # Recommendation microservice
β”œβ”€β”€ pom.xml                           # Maven build file
└── mvnw / mvnw.cmd                   # Maven wrapper scripts

πŸš€ Getting Started

Prerequisites

  • Java 17+
  • Maven 3.8+
  • PostgreSQL (or MySQL) running locally
  • Python 3.9+ with Blender installed (for 3D generation)

Running the Spring Boot Server

  1. Clone the repository

    git clone https://github.com/AdepuSriCharan/AR-Car-Showcase-Server.git
    cd AR-Car-Showcase-Server
  2. Configure the database β€” edit src/main/resources/application.properties:

    spring.datasource.url=jdbc:postgresql://localhost:5432/arcarshowcase
    spring.datasource.username=your_user
    spring.datasource.password=your_password
    spring.jpa.hibernate.ddl-auto=update
  3. Run the server

    ./mvnw spring-boot:run

    The API will be available at http://localhost:8080.

Running the Blender Service

cd blender-service
pip install -r requirements.txt
python server.py

The Blender microservice will start on http://localhost:5000.


πŸ”Œ API Endpoints

Auth

Method Endpoint Description
POST /api/auth/signin Login and receive JWT
POST /api/auth/signup Register a new user

Cars

Method Endpoint Description
GET /api/cars/allcars Get all cars
GET /api/cars/{id} Get car by ID
GET /api/cars/search?q= Search cars by query
GET /api/cars/filter Filter by body type, fuel, budget

Customizations (requires auth)

Method Endpoint Description
POST /api/customizations Save a customization
GET /api/customizations/user/{userId} Get user's saved designs
GET /api/customizations/{id} Get specific customization

Recommendations (requires auth)

Method Endpoint Description
GET /api/recommendations/personalized Personalized car feed
GET /api/recommendations/similar/{carId} Similar cars
POST /api/recommendations/feedback Record user interaction

πŸ” Security Architecture

sequenceDiagram
    participant C as Client
    participant F as AuthTokenFilter
    participant SC as SecurityContext
    participant CTR as Controller

    C->>F: HTTP Request + Authorization: Bearer <token>
    F->>F: validateJwtToken(token)
    alt Token Valid
        F->>SC: setAuthentication(userDetails)
        F->>CTR: Forward Request
        CTR-->>C: 200 Response
    else Token Invalid / Missing
        F-->>C: 401 Unauthorized
    end
Loading

🎨 Blender Service: How It Works

The Python microservice receives customization requests from the Spring Boot server and generates a new .glb model file with the specified colors applied.

Spring Boot β†’ POST /generate β†’ Flask Server β†’ subprocess(blender --background --python generate.py) β†’ New .glb β†’ Return URL β†’ Spring Boot β†’ Frontend

Input payload:

{
  "base_model": "car.glb",
  "materials": {
    "CAR_BODY_PRIMARY": "#FF0000",
    "CAR_RIM": "#C0C0C0"
  }
}

Output:

{
  "model_url": "/models/custom_abc123.glb",
  "filename": "custom_abc123.glb"
}

πŸ“¦ Key Dependencies (pom.xml)

Dependency Purpose
spring-boot-starter-web REST API framework
spring-boot-starter-data-jpa ORM / Database access
spring-boot-starter-security Authentication & authorization
jjwt JWT generation & validation
postgresql / mysql-connector Database driver
lombok Boilerplate reduction
spring-boot-starter-validation Bean validation (@Valid)

🌐 Learn More


πŸ“„ License

MIT License β€” See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 88.1%
  • Python 11.0%
  • Dockerfile 0.9%