# kurokeita/quotable-nestjs architecture

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

- Interactive diagram: https://gitdiagram.com/kurokeita/quotable-nestjs
- Repository: https://github.com/kurokeita/quotable-nestjs

## Overview

##### Main Components

a. Client Layer:
- External API Consumers (Web/Mobile Apps)
- REST API endpoints connection

b. Application Layer:
- NestJS Server
- Main Modules:
- Author Module
- Quote Module
- Tag Module
- Upload Module
- Health Module

c. Database Layer:
- PostgreSQL Database
- Schema Entities:
- Authors
- Quotes
- Tags
- Relations between entities

##### Architecture Pattern Representation

a. Module Structure (for each feature module):
- Controller (API endpoints)
- Service (Business logic)
- Repository (Data access)
- DTOs (Data transfer objects)

b. Middleware Layer:
- Resource Manipulation Middleware

c. Configuration Layer:
- App Config
- Database Config
- Environment Variables

##### Specific Implementation Details

- API Routes (from /api/index.ts)
- Database interactions using Drizzle ORM
- File upload flow
- Health check system

##### Technical Stack Indicators

Technology badges or labels for:
- NestJS
- PostgreSQL
- Drizzle ORM
- TypeScript
- Docker

##### Additional Elements

- Docker container boundary
- API documentation (Swagger) endpoint
- Health check endpoint
- File upload storage area

##### Legends and Notes

- HTTP methods (GET, POST, PUT, DELETE)
- Authentication flow (if implemented)
- Database migration process using Drizzle

Remember to highlight the scalability aspects enabled by the Docker support and the health check system that ensures system reliability.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CL["Client Layer"]
        Client["External API Consumers"]:::client
    end

    subgraph AL["Application Layer"]
        NestJS["NestJS Server"]:::server
        click NestJS "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app.module.ts"

        subgraph Modules["Feature Modules"]
            AuthorMod["Author Module"]:::module
            click AuthorMod "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/author/author.module.ts"
            QuoteMod["Quote Module"]:::module
            click QuoteMod "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/quote/quote.module.ts"
            TagMod["Tag Module"]:::module
            click TagMod "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/tag/tag.module.ts"
            UploadMod["Upload Module"]:::module
            click UploadMod "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/upload/upload.module.ts"
            HealthMod["Health Module"]:::module
            click HealthMod "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/health/health.module.ts"
        end

        subgraph Components["Module Components"]
            direction TB
            Controllers["Controllers"]:::component
            click Controllers "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/author/author.controller.ts"
            Services["Services"]:::component
            click Services "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/author/author.service.ts"
            Repos["Repositories"]:::component
            click Repos "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/author/author.repository.ts"
            DTOs["DTOs"]:::component
            click DTOs "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/author/author.dto.ts"
        end

        subgraph MW["Middleware Layer"]
            ResourceMW["Resource Manipulation"]:::middleware
            click ResourceMW "https://github.com/kurokeita/quotable-nestjs/blob/main/src/app/middlewares/resource_manipulation.middleware.ts"
        end

        subgraph Config["Configuration"]
            AppConfig["App Config"]:::config
            click AppConfig "https://github.com/kurokeita/quotable-nestjs/blob/main/src/config/app.config.ts"
            DBConfig["Database Config"]:::config
            click DBConfig "https://github.com/kurokeita/quotable-nestjs/blob/main/src/db/index.ts"
        end
    end

    subgraph DL["Database Layer"]
        PostgreSQL[(PostgreSQL)]:::database
        
        subgraph Schemas["Database Schemas"]
            Authors["Authors Schema"]:::schema
            click Authors "https://github.com/kurokeita/quotable-nestjs/blob/main/src/db/schema/author.schema.ts"
            Quotes["Quotes Schema"]:::schema
            click Quotes "https://github.com/kurokeita/quotable-nestjs/blob/main/src/db/schema/quote.schema.ts"
            Tags["Tags Schema"]:::schema
            click Tags "https://github.com/kurokeita/quotable-nestjs/blob/main/src/db/schema/tag.schema.ts"
            Relations["Schema Relations"]:::schema
            click Relations "https://github.com/kurokeita/quotable-nestjs/blob/main/src/db/schema/relations.ts"
        end

        subgraph Migrations["Database Migrations"]
            MigrationConfig["Migration Config"]:::migration
            click MigrationConfig "https://github.com/kurokeita/quotable-nestjs/blob/main/drizzle.config.ts"
            MigrationFiles["Migration Files"]:::migration
            click MigrationFiles "https://github.com/kurokeita/quotable-nestjs/tree/main/drizzle"
        end
    end

    %% Connections
    Client --> NestJS
    NestJS --> Modules
    Modules --> Components
    Components --> MW
    MW --> PostgreSQL
    Config --> NestJS
    PostgreSQL --> Schemas
    PostgreSQL --> Migrations

    %% Styles
    classDef client fill:#2196F3,stroke:#1565C0,color:white
    classDef server fill:#4CAF50,stroke:#2E7D32,color:white
    classDef module fill:#81C784,stroke:#4CAF50,color:white
    classDef component fill:#A5D6A7,stroke:#81C784,color:black
    classDef middleware fill:#FFF176,stroke:#FDD835,color:black
    classDef config fill:#90A4AE,stroke:#607D8B,color:white
    classDef database fill:#EF5350,stroke:#D32F2F,color:white
    classDef schema fill:#EF9A9A,stroke:#EF5350,color:black
    classDef migration fill:#FFB74D,stroke:#FB8C00,color:black

    %% Legend
    subgraph Legend
        Client_L["Client"]:::client
        Server_L["Server"]:::server
        Module_L["Module"]:::module
        Component_L["Component"]:::component
        Middleware_L["Middleware"]:::middleware
        Config_L["Config"]:::config
        Database_L["Database"]:::database
        Schema_L["Schema"]:::schema
        Migration_L["Migration"]:::migration
    end
```
