# ved-asole/ekart-ecommerce-backend architecture

> Architecture diagram of the GitHub repository ved-asole/ekart-ecommerce-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ved-asole/ekart-ecommerce-backend
- Repository: https://github.com/ved-asole/ekart-ecommerce-backend

## Overview

##### Main System Components

a) Client Layer:
- External React Frontend (mentioned in README)
- Swagger UI for API documentation

b) API Gateway Layer:
- Security & Authentication components
- JWT Authentication Filter
- Request/Response handlers

c) Application Layer:
- Controllers (REST endpoints)
- Service Layer (Business Logic)
- Data Transfer Objects (DTOs)

d) Data Layer:
- JPA Repositories
- Entity Models
- Database (H2/PostgreSQL)

e) External Services:
- Email Service
- Stripe Payment Gateway
- Monitoring Services (BetterStack)

##### Component Relationships

**[Client Layer] → [API Gateway] → [Controllers] → [Services] → [Repositories] → [Database]**

With cross-cutting concerns:
**[Security Layer] ↔ [All Layers]**
**[Exception Handling] ↔ [All Layers]**

##### Detailed Component Breakdown

a) Authentication & Security:
- JWT Service
- Security Config
- Authentication Controller

b) Product Management:
- Product Controller
- Category Controller
- Product Service
- Category Service

c) Order Processing:
- Order Controller
- Shopping Cart Controller
- Payment Controller
- Related Services

d) Customer Management:
- Customer Controller
- User Controller
- Address Management

##### Infrastructure Components

Supporting elements:
- Docker container
- Maven build system
- Logging framework
- Monitoring systems

##### Data Flow Patterns

Key flows:
- Authentication flow
- Order processing flow
- Payment processing flow
- Shopping cart operations

##### Scalability points

Keep the abstraction level balanced - detailed enough to understand the system's architecture but not so detailed that it becomes cluttered with implementation specifics.

Remember to include the monitoring and observability aspects shown by the SonarCloud and BetterStack integrations mentioned in the README.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL["Client Layer"]
        RF[React Frontend]:::client
        SW["Swagger UI"]:::client
    end

    %% API Gateway Layer
    subgraph AG["API Gateway & Security"]
        JF["JWT Filter"]:::security
        SC["Security Config"]:::security
        AC["Auth Controller"]:::security
    end
    click SC "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/src/main/java/com/vedasole/ekartecommercebackend/security/"
    click AC "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/src/main/java/com/vedasole/ekartecommercebackend/controller/AuthController.java"

    %% Controllers Layer
    subgraph CO["Controllers"]
        PC["Product Controller"]:::controller
        CC["Category Controller"]:::controller
        OC["Order Controller"]:::controller
        UC["User Controller"]:::controller
    end
    click CO "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/src/main/java/com/vedasole/ekartecommercebackend/controller/"

    %% Service Layer
    subgraph SL["Service Layer"]
        PS["Product Service"]:::service
        CS["Category Service"]:::service
        OS["Order Service"]:::service
        US["User Service"]:::service
        ES["Email Service"]:::service
        SS["Stripe Service"]:::service
    end
    click SL "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/src/main/java/com/vedasole/ekartecommercebackend/service/service_interface/"
    click ES "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/src/main/java/com/vedasole/ekartecommercebackend/service/service_impl/EmailServiceImpl.java"
    click SS "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/src/main/java/com/vedasole/ekartecommercebackend/service/service_impl/StripeService.java"

    %% Data Layer
    subgraph DL["Data Layer"]
        EN["Entities"]:::data
        RP["Repositories"]:::data
        DTO["DTOs"]:::data
        DB[(Database)]:::database
    end
    click EN "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/src/main/java/com/vedasole/ekartecommercebackend/entity/"
    click RP "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/src/main/java/com/vedasole/ekartecommercebackend/repository/"
    click DTO "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/src/main/java/com/vedasole/ekartecommercebackend/payload/"

    %% Infrastructure & Config
    subgraph IN["Infrastructure"]
        DC["Docker"]:::infra
        MV["Maven"]:::infra
        CF["Config Files"]:::infra
        LG["Logging"]:::infra
    end
    click DC "https://github.com/ved-asole/eKart-ecommerce-backend/tree/master/Dockerfile"
    click MV "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/pom.xml"
    click CF "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/src/main/resources/application-*.properties"
    click LG "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/src/main/resources/logback.xml"

    %% External Services
    subgraph EX["External Services"]
        SP["Stripe Payment"]:::external
        BS["BetterStack"]:::external
        EM["Email Server"]:::external
    end

    %% Exception Handling
    EH["Exception Handler"]:::error
    click EH "https://github.com/ved-asole/eKart-ecommerce-backend/blob/master/src/main/java/com/vedasole/ekartecommercebackend/exception/GlobalExceptionHandler.java"

    %% Relationships
    RF & SW --> AG
    AG --> CO
    CO --> SL
    SL --> DL
    DL --> DB
    SL --> EX
    EH -.-> AG & CO & SL
    IN -.-> AG & CO & SL & DL

    %% Styles
    classDef client fill:#B2D7FF,stroke:#333,stroke-width:2px
    classDef security fill:#FFE0B2,stroke:#333,stroke-width:2px
    classDef controller fill:#90CAF9,stroke:#333,stroke-width:2px
    classDef service fill:#A5D6A7,stroke:#333,stroke-width:2px
    classDef data fill:#FFE082,stroke:#333,stroke-width:2px
    classDef database fill:#CE93D8,stroke:#333,stroke-width:2px
    classDef external fill:#B39DDB,stroke:#333,stroke-width:2px
    classDef infra fill:#BDBDBD,stroke:#333,stroke-width:2px
    classDef error fill:#EF9A9A,stroke:#333,stroke-width:2px
```
