# nkhang1234/nest_exercise_mobile architecture

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

- Interactive diagram: https://gitdiagram.com/nkhang1234/nest_exercise_mobile
- Repository: https://github.com/nkhang1234/nest_exercise_mobile

## Overview

##### Project type and purpose
- This is a NestJS-based server-side application written in TypeScript.
- It exposes RESTful endpoints for user authentication (“auth” module), category management (“category” module), and wallet management (“wallet” module).
- It persists data in a relational database via Prisma ORM and uses JWT for auth.

##### File structure
- Top-level ingredients:
- Dockerfile & docker-compose.yml (containerization)
- .github/workflows/cicd.yml (CI/CD pipeline)
- prisma/ (schema, migrations, seed script)
- src/ (application code in modules)
- test/ (e2e suites)
- Inside src/:
- app.module.ts – root application module wiring submodules
- auth/ – controller, service, DTOs, guards, strategies (JWT)
- category/ – CRUD controller + service + DTOs
- wallet/ – CRUD controller + service + DTOs
- prisma/ – PrismaModule & PrismaService (DB client wrapper)
- main.ts – NestJS bootstrap entry point

##### Key README insights
- Standard NestJS starter, no frontend present.
- Emphasis on efficient & scalable server-side architecture.
- Deployment via NestJS Mau or Docker.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client (Browser/Mobile)"]:::external

    %% NestJS Server Container
    subgraph "NestJS Server" 
        direction TB
        Main["main.ts"]:::entry
        AppModule["AppModule"]:::core

        %% Auth Module
        subgraph "Auth Module" 
            direction TB
            AuthController["AuthController"]:::auth
            AuthService["AuthService"]:::auth
            JwtStrategy["JwtStrategy"]:::auth
            JWTAuthGuard["JWTAuthGuard"]:::auth
            SignInDTO["SignIn DTO"]:::auth
            SignUpDTO["SignUp DTO"]:::auth
            PublicDecorator["Public Decorator"]:::auth
        end

        %% Category Module
        subgraph "Category Module"
            direction TB
            CategoryController["CategoryController"]:::category
            CategoryService["CategoryService"]:::category
            CreateCategoryDTO["CreateCategory DTO"]:::category
            UpdateCategoryDTO["UpdateCategory DTO"]:::category
        end

        %% Wallet Module
        subgraph "Wallet Module"
            direction TB
            WalletController["WalletController"]:::wallet
            WalletService["WalletService"]:::wallet
            CreateWalletDTO["CreateWallet DTO"]:::wallet
            UpdateWalletDTO["UpdateWallet DTO"]:::wallet
        end

        %% Prisma Module
        subgraph "Prisma Module"
            direction TB
            PrismaModule["PrismaModule"]:::prisma
            PrismaService["PrismaService"]:::prisma
        end

        %% Bootstrapping and Wiring
        Main --> AppModule
        AppModule --> AuthModule
        AppModule --> CategoryModule
        AppModule --> WalletModule
        AppModule --> PrismaModule
    end

    %% Database
    Database[(PostgreSQL/MySQL DB)]:::database

    %% Infrastructure
    Docker["Docker & docker-compose"]:::infra
    CICD["CI/CD Pipeline"]:::infra

    %% Interactions
    Client -->|HTTP/HTTPS| AuthController
    Client -->|HTTP/HTTPS| CategoryController
    Client -->|HTTP/HTTPS| WalletController

    AuthController -->|"calls"| AuthService
    CategoryController -->|"calls"| CategoryService
    WalletController -->|"calls"| WalletService

    AuthService -->|"uses"| JwtStrategy
    AuthService -->|"uses"| JWTAuthGuard

    AuthService -->|"uses"| PrismaService
    CategoryService -->|"uses"| PrismaService
    WalletService -->|"uses"| PrismaService

    PrismaService -->|SQL queries| Database

    %% Click Events
    click AuthController "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/auth.controller.ts"
    click AuthService "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/auth.service.ts"
    click JwtStrategy "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/strategies/jwt.strategy.ts"
    click JWTAuthGuard "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/guards/jwt-auth.guard.ts"
    click SignInDTO "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/dto/sign-in.dto.ts"
    click SignUpDTO "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/dto/sign-up.dto.ts"
    click PublicDecorator "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/decorators/public.decorator.ts"
    click AuthModule "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/auth/auth.module.ts"
    click CategoryController "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/category/category.controller.ts"
    click CategoryService "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/category/category.service.ts"
    click CreateCategoryDTO "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/category/dto/create-category.dto.ts"
    click UpdateCategoryDTO "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/category/dto/update-category.dto.ts"
    click CategoryModule "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/category/category.module.ts"
    click WalletController "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/wallet/wallet.controller.ts"
    click WalletService "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/wallet/wallet.service.ts"
    click CreateWalletDTO "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/wallet/dto/create-wallet.dto.ts"
    click UpdateWalletDTO "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/wallet/dto/update-wallet.dto.ts"
    click WalletModule "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/wallet/wallet.module.ts"
    click PrismaModule "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/prisma/prisma.module.ts"
    click PrismaService "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/prisma/prisma.service.ts"
    click Database "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/prisma/schema.prisma"
    click Database "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/prisma/seed.ts"
    click Database "https://github.com/nkhang1234/nest_exercise_mobile/tree/main/prisma/migrations"
    click AppModule "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/app.module.ts"
    click Main "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/src/main.ts"
    click Docker "https://github.com/nkhang1234/nest_exercise_mobile/tree/main/Dockerfile"
    click Docker "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/docker-compose.yml"
    click CICD "https://github.com/nkhang1234/nest_exercise_mobile/blob/main/.github/workflows/cicd.yml"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef entry fill:#ccc,stroke:#333,stroke-width:1px
    classDef core fill:#bbb,stroke:#333,stroke-width:1px
    classDef auth fill:#cce5ff,stroke:#007bff,stroke-width:1px
    classDef category fill:#d4edda,stroke:#28a745,stroke-width:1px
    classDef wallet fill:#fff3cd,stroke:#ffc107,stroke-width:1px
    classDef prisma fill:#e2d4f7,stroke:#6f42c1,stroke-width:1px
    classDef database fill:#ffe0e6,stroke:#dc3545,stroke-width:1px,stroke-dasharray: 5 5
    classDef infra fill:#e2e3e5,stroke:#6c757d,stroke-width:1px,stroke-dasharray: 2 2
```
