# ozymandiaz1876/ecom-app architecture

> Architecture diagram of the GitHub repository ozymandiaz1876/ecom-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ozymandiaz1876/ecom-app
- Repository: https://github.com/ozymandiaz1876/ecom-app

## Overview

##### Project Type Analysis
This is a NestJS-based backend application with features typical of an e-commerce system, including user authentication, product management, order processing, and coupon handling.

##### Main Components

A. Core Application Layer:
- Main NestJS Application (app.module.ts as the root module)
- Configuration Management (src/config)
- Authentication System (src/auth)

B. Domain Modules:
- Users Module
- Products Module
- Orders Module
- Coupons Module
- Sales Module

C. Infrastructure Layer:
- Database (implied by .repository.ts files)
- Authentication Middleware
- Guards and Decorators
- Docker Infrastructure (Dockerfile.dev, Dockerfile.prod, docker-compose.yaml)

**┌─────────────────────────────────────────────────────┐**
- API Gateway Layer                   │
- (Swagger Documentation, Authentication, Guards)     │
- ┤
- Application Core                    │

- ┌─────────┐  ┌─────────┐  ┌─────────┐          │
- Users  │  │Products │  │ Orders  │          │
- ┘  └─────────┘  └─────────┘          │
- ┌─────────┐  ┌─────────┐                       │
- Coupons │  │  Sales  │                       │
- ┘  └─────────┘                       │
- ┤
- Infrastructure Layer                   │
- (Database, Docker, Configuration)               │
- ┘

##### Specific Component Details

- Blue rectangles for core modules
- Green hexagons for infrastructure components
- Yellow diamonds for cross-cutting concerns
- Red circles for security components

##### Relationships
- Double lines for HTTP/API interactions

##### Specific Elements

a) Authentication Flow:
- JWT Strategy (src/auth/strategies)
- Guards (src/auth/guards)
- Role-based access control (UserRoles.enum.ts)

b) Business Logic Flow:
- Order processing pipeline
- Coupon validation
- Sales tracking
- Product management

c) Data Flow:
- Repository pattern implementation
- Service layer interactions
- Controller endpoints

##### Technical Details to Highlight

- NestJS modules and their relationships
- Authentication and authorization flow
- Database interaction patterns
- API endpoints grouping

##### Data flow

Remember to include:
- Environment configurations
- Docker container relationships
- API documentation endpoints
- Security layers

This will provide a complete picture of the system while maintaining clarity and usefulness for development and maintenance purposes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph API["API Gateway Layer"]
        direction TB
        Swagger["Swagger Documentation"]
        AuthGuard["Authentication Guards"]:::security
        click AuthGuard "https://github.com/Ozymandiaz1876/Ecom-app/tree/master/src/auth/guards/"
    end

    subgraph Core["Application Core"]
        direction TB
        AppModule["App Module"]:::core
        click AppModule "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/app.module.ts"
        
        subgraph Auth["Authentication System"]
            direction TB
            JWTStrategy["JWT Strategy"]:::security
            AuthService["Auth Service"]:::security
            AuthConfig["Auth Config"]:::security
            click JWTStrategy "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/auth/strategies/jwt.strategy.ts"
            click AuthService "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/auth/auth.service.ts"
            click AuthConfig "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/auth/config/auth.config.ts"
        end

        subgraph Domain["Domain Modules"]
            direction TB
            Users["Users Module"]:::module
            Products["Products Module"]:::module
            Orders["Orders Module"]:::module
            Coupons["Coupons Module"]:::module
            Sales["Sales Module"]:::module

            click Users "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/users/users.module.ts"
            click Products "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/products/products.module.ts"
            click Orders "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/orders/orders.module.ts"
            click Coupons "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/coupons/coupons.module.ts"
            click Sales "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/sales/sales.module.ts"

            subgraph Services["Service Layer"]
                direction TB
                UsersService["Users Service"]:::service
                ProductsService["Products Service"]:::service
                OrdersService["Orders Service"]:::service
                CouponsService["Coupons Service"]:::service
                SalesService["Sales Service"]:::service

                click UsersService "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/users/users.service.ts"
                click ProductsService "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/products/products.service.ts"
                click OrdersService "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/orders/orders.service.ts"
                click CouponsService "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/coupons/coupons.service.ts"
                click SalesService "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/sales/sales.service.ts"
            end

            subgraph Repositories["Repository Layer"]
                direction TB
                UsersRepo["Users Repository"]:::repository
                ProductsRepo["Products Repository"]:::repository
                OrdersRepo["Orders Repository"]:::repository
                CouponsRepo["Coupons Repository"]:::repository

                click UsersRepo "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/users/users.repository.ts"
                click ProductsRepo "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/products/products.repository.ts"
                click OrdersRepo "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/orders/orders.repository.ts"
                click CouponsRepo "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/coupons/coupons.repository.ts"
            end
        end
    end

    subgraph Infrastructure["Infrastructure Layer"]
        direction TB
        Docker["Docker Configuration"]:::infra
        Database[(Database)]:::database
        Config["Configuration Management"]:::infra
        RoleManagement["Role Management"]:::infra
        OrderStatus["Order Status Management"]:::infra
        Utils["Utilities"]:::infra

        click Docker "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/docker-compose.yaml"
        click Config "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/config/config.type.ts"
        click RoleManagement "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/constants/enums/UserRoles.enum.ts"
        click OrderStatus "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/constants/enums/OrderStatus.enum.ts"
        click Utils "https://github.com/Ozymandiaz1876/Ecom-app/blob/master/src/utils/misc.ts"
    end

    %% Relationships
    API --> Core
    Core --> Infrastructure
    Auth --> Domain
    Domain --> Infrastructure

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef security fill:#FF5252,stroke:#D32F2F,color:white
    classDef module fill:#4CAF50,stroke:#388E3C,color:white
    classDef service fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef repository fill:#FF9800,stroke:#F57C00,color:white
    classDef database fill:#607D8B,stroke:#455A64,color:white
    classDef infra fill:#795548,stroke:#5D4037,color:white

    %% Legend
    subgraph Legend
        direction TB
        L1["Core Component"]:::core
        L2["Security Component"]:::security
        L3["Module"]:::module
        L4["Service"]:::service
        L5["Repository"]:::repository
        L6["Infrastructure"]:::infra
        L7[(Database)]:::database
    end
```
