# hemanthjinnala7/travtronics-assignment architecture

> Architecture diagram of the GitHub repository hemanthjinnala7/travtronics-assignment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hemanthjinnala7/travtronics-assignment
- Repository: https://github.com/hemanthjinnala7/travtronics-assignment

## Overview

##### Project Type and Purpose
- This is a standalone Spring Boot microservice providing RESTful APIs for product and user management.
- It uses an embedded Tomcat server to expose HTTP endpoints and an in-memory H2 database for persistence.

a. Client Layer
- Any HTTP client (Postman, front-end app, CLI) that calls the REST API on port 9090.
b. API Layer (Controllers)
- ProductController – exposes /api/getAllProducts, /api/getProductById/{id}, /api/admin/addProduct, etc.
- UserController – exposes /api/user/register, /api/user/addItemToCartById, /api/user/Orderitem, etc.
c. Domain Layer (Models)
- ProductModel – JPA entity defining id, name, price, type, gender
- UserModel – JPA entity defining id, username, password, cart, orders
d. Data Access Layer (Repositories)
- ProductRepository – extends JpaRepository<ProductModel, Long>
- UserRepository – extends JpaRepository<UserModel, Long>
e. Persistence (Database)
- H2 in-memory database (configured in application.properties)
f. Infrastructure
- Embedded Tomcat (via Spring Boot)
- Maven build lifecycle (pom.xml, mvnw scripts)
- Configuration – src/main/resources/application.properties

##### Relationships & Data Flow
- Client → Controllers (HTTP request/response)
- Controllers → Repositories (via Spring Data JPA calls)
- Repositories ↔ H2 database (SQL read/write)
- Application.properties configures port 9090 and H2 console (optional)
- Controllers and Repositories both depend on Domain Models

##### Architectural Patterns & Design Principles
- Layered architecture (HTTP → Controller → Repository → DB)
- Convention-over-configuration (Spring Boot auto-configuration)
- Dependency injection (controllers auto-wire repositories)
- In-memory database for rapid development/testing

## Diagram (Mermaid)

```mermaid
flowchart TB
    Client["Client (Postman, Browser)"]:::external

    subgraph "TravtronicsService"
        subgraph "Controllers"
            PC["ProductController"]:::controller
            UC["UserController"]:::controller
        end
        subgraph "Repositories"
            PR["ProductRepository"]:::repository
            UR["UserRepository"]:::repository
        end
        subgraph "Models"
            PM["ProductModel"]:::model
            UM["UserModel"]:::model
        end
        H2["H2 In-Memory DB"]:::db
        subgraph "Infrastructure"
            TA["TravtronicsApplication"]:::infra
            AP["application.properties"]:::config
        end
    end

    Maven["Maven Build"]:::infra
    Tests["TravtronicsApplicationTests"]:::test

    Client -->|"HTTP REST calls on port 9090"| PC
    Client -->|"HTTP REST calls on port 9090"| UC
    PC -->|"Spring Data JPA"| PR
    UC -->|"Spring Data JPA"| UR
    PR -->|"SQL read/write"| H2
    UR -->|"SQL read/write"| H2
    PC -.->|depends on| PM
    PC -.->|depends on| UM
    PR -.->|depends on| PM
    UR -.->|depends on| UM
    TA -->|configures port & DB| AP
    Tests -->|tests controllers| PC
    Tests -->|tests controllers| UC
    Maven -->|build/deploy| TA

    classDef external fill:#d5e8d4,stroke:#82b366,color:#082f0f;
    classDef controller fill:#dae8fc,stroke:#6c8ebf,color:#073763;
    classDef repository fill:#e1f5d1,stroke:#82b366,color:#204a02;
    classDef model fill:#fff2cc,stroke:#d6b656,color:#7f6000;
    classDef db fill:#f8cecc,stroke:#b85450,color:#5c1a1a,shape:cylinder;
    classDef infra fill:#e1e1e1,stroke:#999999,color:#333333;
    classDef config fill:#f5f5f5,stroke:#cccccc,color:#333333,shape:note;
    classDef test fill:#f2d7ee,stroke:#bb80c4,color:#541654;

    click PC "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/controller/ProductController.java"
    click UC "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/controller/UserController.java"
    click PM "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/model/ProductModel.java"
    click UM "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/model/UserModel.java"
    click PR "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/repository/ProductRepository.java"
    click UR "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/repository/UserRepository.java"
    click AP "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/resources/application.properties"
    click TA "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/main/java/com/assignment/travtronics/TravtronicsApplication.java"
    click Maven "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/pom.xml"
    click Maven "https://github.com/hemanthjinnala7/travtronics-assignment/tree/main/mvnw"
    click Maven "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/mvnw.cmd"
    click Maven "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/.mvn/wrapper/maven-wrapper.properties"
    click Tests "https://github.com/hemanthjinnala7/travtronics-assignment/blob/main/src/test/java/com/assignment/travtronics/TravtronicsApplicationTests.java"
```
