# kmutt-cpe-student/comcamp36 architecture

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

- Interactive diagram: https://gitdiagram.com/kmutt-cpe-student/comcamp36
- Repository: https://github.com/kmutt-cpe-student/comcamp36

## Overview

##### Main Components
- Web Frontend: This is the “web” app built with Next.js (Next 15), which serves the user interface for the comcamp.io website.
- API Server: This “server” app is built with Nest.js and serves as the API backend. It handles business logic, authentication, database interactions (evidenced by the Prisma ORM and migration folders), and more.
- Utility Package: The “utils” app provides an auto schema generator. While it is a utility tool, it might be used either as a standalone library or integrated within other modules.
- Shared Configurations: The “@repo/typescript-config” package contains shared TypeScript configuration files that are used throughout the monorepo to ensure consistency.
- Additional Components: You have configuration files such as Dockerfile, docker-compose.yml, and Supabase configuration files. These indicate containerization and potential deployment to services with database/other backend support.

##### Relationships and Interactions
- The API server likely interacts with a database through Prisma (as seen in the migrations and schema.prisma structure). Illustrate a database component connected to the API server.
- The Supabase directory and configuration files suggest there might be an external service for authentication/storage or additional database services, so include an “External Services” node connected to the Server as necessary.

##### Architectural Patterns and Key Technologies
- Frontend: Next.js with typical features such as server-side rendering and static site generation.
- Backend: Nest.js following an MVC or modular architecture pattern with clearly separated concerns (controllers, services, modules, and middleware such as authentication strategies).
- Shared configurations: Reinforcing code consistency via shared TypeScript configuration files.
- Utility: A specialized package that automates schema generation can be depicted as a library/component utilized across the monorepo.

##### Being Detailed Yet Practical
- Do not shy away from breaking down the API Server into its functional modules if further granularity is desired (e.g., Authentication, Users, Answers, Confirmations, Files, etc.). This is particularly useful for maintenance or scaling discussions.
- Interactions such as HTTP/REST API calls (from web to server), internal service dependencies (e.g., how authentication middleware interacts with endpoints), and database transactions (as managed by Prisma).
- Build and development pipelines – mark how “pnpm build” or “pnpm dev” commands relate to the overall architecture if it contributes to understanding deployment flows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Components
    subgraph "Application Components"
        W["Web (Next.js)"]:::frontend
        S["Server (Nest.js)"]:::backend
        U["Utils (Auto Schema Generator)"]:::utility
        SC["Shared TSConfig"]:::config
    end

    %% Infrastructure Components
    subgraph "Infrastructure"
        DB["Database (Prisma ORM)"]:::db
        subgraph "Deployment (Docker)"
            DF["Dockerfile (API)"]:::docker
            DC["Docker Compose"]:::docker
        end
        EX["Supabase (External)"]:::external
    end

    %% Relationships between Application Components
    W -->|"clientAPIcalls"| S
    S -->|"Prisma"| DB
    S -->|"autoSchema"| U

    %% Shared configuration usage (dotted lines)
    W ---|"usesConfig"| SC
    S ---|"usesConfig"| SC
    U ---|"usesConfig"| SC

    %% Deployment relationships
    S -->|"containerized"| DF
    W -->|"containerized"| DC
    S -->|"containerized"| DC

    %% External service interaction
    S -->|"external"| EX

    %% Click Events
    click W "https://github.com/kmutt-cpe-student/comcamp36/tree/main/apps/web"
    click S "https://github.com/kmutt-cpe-student/comcamp36/tree/main/apps/server"
    click U "https://github.com/kmutt-cpe-student/comcamp36/tree/main/apps/utils"
    click SC "https://github.com/kmutt-cpe-student/comcamp36/tree/main/packages/typescript-config"
    click DF "https://github.com/kmutt-cpe-student/comcamp36/tree/main/apps/server/Dockerfile"
    click DC "https://github.com/kmutt-cpe-student/comcamp36/blob/main/docker-compose.yml"
    click EX "https://github.com/kmutt-cpe-student/comcamp36/tree/main/supabase"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef utility fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef config fill:#D8BFD8,stroke:#333,stroke-width:2px;
    classDef db fill:#F0E68C,stroke:#333,stroke-width:2px;
    classDef docker fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef external fill:#FFFACD,stroke:#333,stroke-width:2px;
```
