# 78-artilleryman/lily-server architecture

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

- Interactive diagram: https://gitdiagram.com/78-artilleryman/lily-server
- Repository: https://github.com/78-artilleryman/lily-server

## Overview

##### Main System Components

a) API Layer
- Entry point (main.ts)
- Controllers (app.controller, auth.controller)
- Guards (JWT, Roles)

b) Service Layer
- Application services (app.service, auth.service, user.service)
- Business logic implementation

c) Database Layer
- Prisma ORM integration
- Database migrations
- Schema definitions

d) Authentication System
- Multiple OAuth providers (Google, Kakao, Naver)
- JWT implementation
- Strategy patterns

**┌─────────────────────────────────────────────────────────┐**
- Client Requests                      │
- ┘
- ↓
**┌─────────────────────────────────────────────────────────┐**
- Nginx Reverse Proxy                 │
- ┘
- ↓
**┌─────────────────────────────────────────────────────────┐**
- NestJS Application                   │
- ┌───────────────┐  ┌───────────────┐  ┌────────────┐  │
- Controllers  │  │    Guards     │  │  Modules   │  │
- ┘  └───────────────┘  └────────────┘  │
- ↓               ↓                  ↓          │
- ┌───────────────┐  ┌───────────────┐  ┌────────────┐  │
- Services    │  │  Strategies   │  │  Prisma    │  │
- ┘  └───────────────┘  └────────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────────────────────┐**
- Database                           │
- ┘

##### Component Relationships

Interactions:
- Database interactions through Prisma
- Request flow through guards and controllers
- Service dependencies

##### Important Details

a) Authentication Flow:
- OAuth2 providers (Google, Kakao, Naver)
- JWT token flow
- Role-based access control

b) Database Schema:
- Prisma models
- Migration patterns
- Relationship between entities

c) API Structure:
- Route hierarchies
- Middleware chain
- Guard implementation

##### Infrastructure Elements

Include:
- Docker container boundaries
- Nginx configuration
- AWS deployment setup (referenced in appspec.yml)

##### Development/Production Environments

Highlight:
- Development setup
- Production deployment flow
- Testing infrastructure

Remember to:
- Clear boundaries between components
- Notes for important configuration details
- Document all external service integrations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CR[Client Requests]
    end

    subgraph Infrastructure
        NX["Nginx Reverse Proxy"]:::infra
        click NX "https://github.com/78-artilleryman/Lily-Server/blob/main/nginx.conf"
        DC["Docker Container"]:::infra
        click DC "https://github.com/78-artilleryman/Lily-Server/tree/main/Dockerfile"
    end

    subgraph "NestJS Application"
        EP["Entry Point"]:::app
        click EP "https://github.com/78-artilleryman/Lily-Server/blob/main/src/main.ts"

        subgraph "API Layer"
            AC["Auth Controller"]:::controller
            click AC "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/auth.controller.ts"
            AppC["App Controller"]:::controller
            click AppC "https://github.com/78-artilleryman/Lily-Server/blob/main/src/app.controller.ts"
        end

        subgraph "Authentication"
            JG["JWT Guard"]:::auth
            click JG "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/guards/jwt-auth-guard.ts"
            RG["Roles Guard"]:::auth
            click RG "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/guards/roles.guard.ts"

            subgraph "OAuth Strategies"
                GS["Google Strategy"]:::auth
                click GS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/strategies/google.strategy.ts"
                KS["Kakao Strategy"]:::auth
                click KS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/strategies/kakao.strategy.ts"
                NS["Naver Strategy"]:::auth
                click NS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/strategies/naver.strategy.ts"
                JS["JWT Strategy"]:::auth
                click JS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/strategies/jwt.strategy.ts"
            end
        end

        subgraph "Service Layer"
            AS["Auth Service"]:::service
            click AS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/auth.service.ts"
            AppS["App Service"]:::service
            click AppS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/app.service.ts"
            US["User Service"]:::service
            click US "https://github.com/78-artilleryman/Lily-Server/blob/main/src/user/user.service.ts"
        end

        subgraph "Modules"
            AM["Auth Module"]:::module
            click AM "https://github.com/78-artilleryman/Lily-Server/blob/main/src/auth/auth.module.ts"
            AppM["App Module"]:::module
            click AppM "https://github.com/78-artilleryman/Lily-Server/blob/main/src/app.module.ts"
            PM["Prisma Module"]:::module
            click PM "https://github.com/78-artilleryman/Lily-Server/blob/main/src/prisma/prisma.module.ts"
            UM["User Module"]:::module
            click UM "https://github.com/78-artilleryman/Lily-Server/blob/main/src/user/user.module.ts"
        end

        subgraph "Database Layer"
            PS["Prisma Service"]:::database
            click PS "https://github.com/78-artilleryman/Lily-Server/blob/main/src/prisma/prisma.service.ts"
            Schema["Prisma Schema"]:::database
            click Schema "https://github.com/78-artilleryman/Lily-Server/blob/main/prisma/schema.prisma"
            Migrations["Database Migrations"]:::database
            click Migrations "https://github.com/78-artilleryman/Lily-Server/tree/main/prisma/migrations/"
        end
    end

    subgraph "External Database"
        DB[(Database)]:::database
    end

    %% Connections
    CR --> NX
    NX --> EP
    EP --> AppC & AC
    AppC & AC --> JG & RG
    JG & RG --> AS & AppS & US
    GS & KS & NS & JS --> AS
    AS & AppS & US --> PS
    PS --> Schema
    Schema --> Migrations
    Migrations --> DB

    %% Styles
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef infra fill:#d3d3d3,stroke:#333
    classDef app fill:#b3e0ff,stroke:#333
    classDef controller fill:#ffb3b3,stroke:#333
    classDef auth fill:#98fb98,stroke:#333
    classDef service fill:#fff2b3,stroke:#333
    classDef module fill:#e6b3ff,stroke:#333
    classDef database fill:#ffd1dc,stroke:#333

    %% Legend
    subgraph Legend
        L1[Infrastructure]:::infra
        L2[Application]:::app
        L3[Controllers]:::controller
        L4[Authentication]:::auth
        L5[Services]:::service
        L6[Modules]:::module
        L7[Database]:::database
    end
```
