# quoctoan2103/watch_store_api architecture

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

- Interactive diagram: https://gitdiagram.com/quoctoan2103/watch_store_api
- Repository: https://github.com/quoctoan2103/watch_store_api

## Overview

##### Main Components
- Application Bootstrapping: Highlight the main entry point (src/main.ts) where the NestJS application is bootstrapped.
- Core Module: Represent the app module (src/app.module.ts) that ties together the different parts of the application.
- Domain Modules: Make separate nodes for each domain/module:
- Auth Module (src/auth) manages authentication via its controller (auth.controller.ts) and service (auth.service.ts).
- Cloudinary Module (src/cloudinary) acts as a dedicated service for media management, including its provider and constants.
- Database Module (src/database) centralizes the database connection/configuration.
- Orders Module (src/orders) handles order processing with controllers and business logic in its service.
- Products Module (src/products) encapsulates product management including DTOs for creating and updating products, interfaces, and the corresponding service.
- Users Module (src/users) handles user management via its controller and service.

##### Communication and Interactions
- That the AppModule aggregates and initializes these distinct domain modules.
- That some modules, like Cloudinary, may be used by others (for example, product images) or might be integrated as an external service.
- The Database module can be highlighted as the central repository for all persistent data, with multiple modules (such as Orders, Products, and Users) interacting with it through service layers.
- If applicable, denote dependency injection by showing that NestJS’s module system decouples and injects services where needed.

##### Architectural Patterns and Design Principles
- Modular Architecture: Each feature is encapsulated in its dedicated module to promote separation of concerns.
- Service-Oriented Structure for handling operations and clear RESTful endpoints exposed by controllers.
- Middleware/pipes/interceptors may be part of the overall system design (although not visible in the file tree, a note can be added if needed).

##### Knowing the Specific Project’s Structure

To Summarize for the Principal Software Engineer:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Bootstrap Layer
    subgraph "Bootstrap Layer"
        main("NestJS Bootstrapping (main.ts)"):::bootstrap
        appModule("Core Module (app.module.ts)"):::module
    end

    %% Authentication Module
    subgraph "Authentication Module"
        authModule("Auth Module"):::module
        authController("Auth Controller"):::controller
        authService("Auth Service"):::service
    end

    %% Cloudinary Module
    subgraph "Cloudinary Module"
        cloudinaryModule("Cloudinary Module"):::module
        cloudinaryProvider("Cloudinary Provider"):::provider
        cloudinaryService("Cloudinary Service"):::service
        cloudinaryConstants("Cloudinary Constants"):::constant
    end

    %% Database Module
    subgraph "Database Module"
        databaseModule("Database Module"):::database
    end

    %% Orders Module
    subgraph "Orders Module"
        ordersModule("Orders Module"):::module
        ordersController("Orders Controller"):::controller
        ordersService("Orders Service"):::service
    end

    %% Products Module
    subgraph "Products Module"
        productsModule("Products Module"):::module
        productsController("Products Controller"):::controller
        productsService("Products Service"):::service
        dtos("DTOs"):::dto
        interfaces("Interfaces"):::interface
    end

    %% Users Module
    subgraph "Users Module"
        usersModule("Users Module"):::module
        usersController("Users Controller"):::controller
        usersService("Users Service"):::service
    end

    %% Connections from Bootstrap Layer to Modules
    main -->|"bootstraps"| appModule
    appModule -->|"includes"| authModule
    appModule -->|"includes"| cloudinaryModule
    appModule -->|"includes"| databaseModule
    appModule -->|"includes"| ordersModule
    appModule -->|"includes"| productsModule
    appModule -->|"includes"| usersModule

    %% Authentication Module Connections
    authModule -->|"exposes"| authController
    authModule -->|"provides"| authService
    authController -->|"calls"| authService
    authService -->|"stores"| databaseModule

    %% Cloudinary Module Connections
    cloudinaryModule -->|"contains"| cloudinaryProvider
    cloudinaryModule -->|"contains"| cloudinaryService
    cloudinaryModule -->|"contains"| cloudinaryConstants

    %% Orders Module Connections
    ordersModule -->|"exposes"| ordersController
    ordersModule -->|"provides"| ordersService
    ordersController -->|"calls"| ordersService
    ordersService -->|"stores"| databaseModule

    %% Products Module Connections
    productsModule -->|"exposes"| productsController
    productsModule -->|"provides"| productsService
    productsController -->|"calls"| productsService
    productsModule -->|"includes"| dtos
    productsModule -->|"includes"| interfaces
    productsService -->|"stores"| databaseModule
    productsService -->|"integrates"| cloudinaryProvider

    %% Users Module Connections
    usersModule -->|"exposes"| usersController
    usersModule -->|"provides"| usersService
    usersController -->|"calls"| usersService
    usersService -->|"stores"| databaseModule

    %% Click Events
    click main "https://github.com/quoctoan2103/watch_store_api/blob/master/src/main.ts"
    click appModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/app.module.ts"
    click authModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/auth/auth.module.ts"
    click authController "https://github.com/quoctoan2103/watch_store_api/blob/master/src/auth/auth.controller.ts"
    click authService "https://github.com/quoctoan2103/watch_store_api/blob/master/src/auth/auth.service.ts"
    click cloudinaryModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/cloudinary/cloudinary.module.ts"
    click cloudinaryProvider "https://github.com/quoctoan2103/watch_store_api/blob/master/src/cloudinary/cloudinary.provider.ts"
    click cloudinaryService "https://github.com/quoctoan2103/watch_store_api/blob/master/src/cloudinary/cloudinary.service.ts"
    click cloudinaryConstants "https://github.com/quoctoan2103/watch_store_api/blob/master/src/cloudinary/constants.ts"
    click databaseModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/database/database.module.ts"
    click ordersModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/orders/orders.module.ts"
    click ordersController "https://github.com/quoctoan2103/watch_store_api/blob/master/src/orders/orders.controller.ts"
    click ordersService "https://github.com/quoctoan2103/watch_store_api/blob/master/src/orders/orders.service.ts"
    click productsModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/products/products.module.ts"
    click productsController "https://github.com/quoctoan2103/watch_store_api/blob/master/src/products/products.controller.ts"
    click productsService "https://github.com/quoctoan2103/watch_store_api/blob/master/src/products/products.service.ts"
    click dtos "https://github.com/quoctoan2103/watch_store_api/tree/master/src/products/dtos/"
    click interfaces "https://github.com/quoctoan2103/watch_store_api/tree/master/src/products/interfaces/"
    click usersModule "https://github.com/quoctoan2103/watch_store_api/blob/master/src/users/users.module.ts"
    click usersController "https://github.com/quoctoan2103/watch_store_api/blob/master/src/users/users.controller.ts"
    click usersService "https://github.com/quoctoan2103/watch_store_api/blob/master/src/users/users.service.ts"

    %% Styles
    classDef bootstrap fill:#f9c,stroke:#333,stroke-width:2px;
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef controller fill:#bfb,stroke:#333,stroke-width:2px;
    classDef service fill:#ffb,stroke:#333,stroke-width:2px;
    classDef database fill:#fc9,stroke:#333,stroke-width:2px;
    classDef provider fill:#9cf,stroke:#333,stroke-width:2px;
    classDef constant fill:#9f9,stroke:#333,stroke-width:2px;
    classDef dto fill:#c9f,stroke:#333,stroke-width:2px;
    classDef interface fill:#f9c,stroke:#333,stroke-width:2px;
```
