# niroj925/gadget-store architecture

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

- Interactive diagram: https://gitdiagram.com/niroj925/gadget-store
- Repository: https://github.com/niroj925/gadget-store

## Overview

##### Main Components

A. Frontend Applications (3 separate applications):
- Client Portal (React + Vite)
- Admin Dashboard (React + Vite)
- Delivery Portal (React + Vite)

B. Backend Server:
- Nest.js Application
- Authentication Services (Google OAuth)
- API Modules (Products, Orders, Customers, etc.)

C. External Services:
- eSewa Payment Gateway
- OpenStreetMap Integration
- Google OAuth Service

D. Database:
- PostgreSQL Database with multiple entities

##### Component Relationships

A. Client Applications → Backend:
- REST API connections
- WebSocket connections for real-time features
- Authenticated routes

B. Backend → External Services:
- Payment gateway integration
- Service integration
- OAuth flow

C. Backend → Database:
- Entity relationships
- Data flow

##### Detailed Components

A. Frontend Applications (show as separate containers):
- Client Portal:
- Product browsing
- Shopping cart
- Payment integration
- Location services

- Admin Dashboard:
- Product management
- Order tracking
- Customer management

- Delivery Portal:
- Order management
- Navigation system
- Delivery tracking

B. Backend Services (show as microservices):
- Auth Module
- Product Module
- Order Module
- Customer Module
- Payment Module
- Delivery Module
- Review Module

C. Database Entities (show major tables):
- Products
- Orders
- Customers
- Categories
- Reviews
- Payments
- Delivery
- Admin
- Auth

##### Security Layer

A security layer showing:
- JWT Authentication
- Role-based Access Control
- Google OAuth Integration
- Access Token/Refresh Token Flow

##### Additional Elements

- API Gateway layer
- Environment configurations
- Scalable components
- Caching mechanisms if any

##### Infrastructure Layer (Optional)

Docker containers and their relationships:
- Frontend containers
- Backend container
- Database container
- Network configuration

Remember to:
- Use consistent symbols throughout
- Clear labels and annotations
- Version information
- Document all external service integrations
- Primary and secondary data flows
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph ClientLayer
        CP["Client Portal"]:::frontend
        AD["Admin Dashboard"]:::frontend
        DP["Delivery Portal"]:::frontend
        
        subgraph ClientFeatures
            SC["Shopping Cart"]:::frontend
            PM["Product Management"]:::frontend
            OM["Order Management"]:::frontend
            CM["Customer Management"]:::frontend
            MAP["Map Integration"]:::frontend
        end
    end

    %% Backend Layer
    subgraph ServerLayer
        subgraph CoreModules
            AUTH["Auth Module"]:::backend
            PROD["Product Module"]:::backend
            ORD["Order Module"]:::backend
            CUST["Customer Module"]:::backend
            PAY["Payment Module"]:::backend
            DEL["Delivery Module"]:::backend
            REV["Review Module"]:::backend
        end

        subgraph Security
            OAUTH["Google OAuth"]:::security
            JWT_A["JWT Access Token"]:::security
            JWT_R["JWT Refresh Token"]:::security
            RBAC["Role-based Access"]:::security
        end
    end

    %% External Services
    subgraph ExternalServices
        ESEWA["eSewa Payment Gateway"]:::external
        OSM["OpenStreetMap"]:::external
        GAUTH["Google OAuth Service"]:::external
    end

    %% Database Layer
    subgraph DatabaseLayer
        DB[(PostgreSQL Database)]:::database
        PRODUCTS[("Products")]:::database
        ORDERS[("Orders")]:::database
        CUSTOMERS[("Customers")]:::database
        CATEGORIES[("Categories")]:::database
        REVIEWS[("Reviews")]:::database
        PAYMENTS[("Payments")]:::database
        DELIVERIES[("Deliveries")]:::database
    end

    %% Relationships
    CP --> AUTH
    AD --> AUTH
    DP --> AUTH
    
    AUTH --> CoreModules
    CoreModules --> DB
    
    PAY --> ESEWA
    MAP --> OSM
    AUTH --> GAUTH

    %% Click Events
    click CP "https://github.com/Niroj925/Gadget-Store/tree/main/client"
    click AD "https://github.com/Niroj925/Gadget-Store/tree/main/admin"
    click DP "https://github.com/Niroj925/Gadget-Store/tree/main/admin/src/pages/delivery"
    click AUTH "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/auth"
    click PROD "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/product"
    click ORD "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/order"
    click CUST "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/customer"
    click PAY "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/payment"
    click DEL "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/delivery"
    click REV "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/modules/review"
    click PRODUCTS "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/product.entity.ts"
    click ORDERS "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/order.entity.ts"
    click CUSTOMERS "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/customer.entity.ts"
    click CATEGORIES "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/category.entity.ts"
    click REVIEWS "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/review.entity.ts"
    click PAYMENTS "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/payment.entity.ts"
    click DELIVERIES "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/model/delivery.entity.ts"
    click OAUTH "https://github.com/Niroj925/Gadget-Store/blob/main/server/src/config/google-oauth.config.ts"
    click JWT_A "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/middlewares/access_token"
    click JWT_R "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/middlewares/refresh_token"
    click RBAC "https://github.com/Niroj925/Gadget-Store/tree/main/server/src/middlewares/authorisation"
    click MAP "https://github.com/Niroj925/Gadget-Store/blob/main/client/src/components/map/Map.jsx"
    click SC "https://github.com/Niroj925/Gadget-Store/tree/main/client/src/components/cart"
    click PM "https://github.com/Niroj925/Gadget-Store/tree/main/admin/src/pages/dashboard/product"
    click OM "https://github.com/Niroj925/Gadget-Store/tree/main/admin/src/pages/dashboard/order"
    click CM "https://github.com/Niroj925/Gadget-Store/tree/main/admin/src/pages/dashboard/customer"
```
