# zktm9903/nhn-eat architecture

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

- Interactive diagram: https://gitdiagram.com/zktm9903/nhn-eat
- Repository: https://github.com/zktm9903/nhn-eat

## Overview

Based on both the file tree and the README, this project ("nhn-eat") is a full-stack application with multiple client targets: a Chrome extension for quickly accessing and voting on cafeteria menus (“구내식당 메뉴”), a traditional front-end (React) web application, and even a React Native (rn) application, along with a robust back-end built in NestJS. The purpose is to let users view and vote on cafeteria menus (with a fun twist involving cats) and aggregate voting results.

- Chrome Extension Component: This is the core user interface for menu checking in browsers. It’s distinct in the file tree (chrome-extension folder) and provided links in the README.
- Front-End Web Client: Built with React/TypeScript, it is found under the “front” directory. This client includes pages (App.tsx), API communication modules, and shared UI components.
- React Native Client: Under the “rn” directory, indicating that a mobile version is also part of the ecosystem.
- Back-End Server: The “back” directory contains a NestJS application with various modules (auth, menu, images, crawling, batch-task, user-menus, and users) and TypeORM-based database configuration.
- Database: Although not directly visible as a separate folder, the back-end configuration shows integration with PostgreSQL (per README tech section and the “typeorm.config.ts” in the database folder).
- Infrastructure/Deployment Layer: Represented by Docker, docker-compose, Amazon EC2 deployment (per README), NGINX configuration (nginx/conf), and related hosting/environment files. Also note configuration files (e.g., dockerfile, nginx/conf/default.conf).

##### Lay Out Relationships and Data Flow
- User Interaction: Represent user devices (desktop for chrome extension, browsers for web client, mobile devices for RN) as sources initiating requests.
- Back-End Service: Show how internal modules interact:
- The Auth module provides authentication/authorization across client calls.
- The Menu, Image, and User-Menu modules handle their respective business logic.
- The Crawling module might fetch or update menu data from external sources.
- The Batch-Task module indicates scheduled periodic tasks (like data updates or aggregation).

##### Architectural Patterns / Design Principles
- Modular Back-End Design: The NestJS backend is organized into separate modules (auth, menus, etc.), making it clear that functionalities are encapsulated.
- Separation of Concerns: Front-end, back-end, the Chrome extension, and mobile applications are clearly isolated.
- API Layer: The frontend components interact with the back-end via well-defined API endpoints (as seen in the “front/src/apis” directory).
- Containerization and Deployment: The project uses Docker and docker-compose, suggesting a microservices or containerized deployment design.
- Use of External Services: In addition to internal modules, there is interaction with external infrastructure (Amazon EC2, NGINX).

##### Detailed Capture of Essential Elements
- To incorporate annotations or legends (if needed) that explain the role of each architectural pattern or component.
- That the system design is modular so that each functionality (authentication, menu display, image processing, voting, etc.) is isolated for maintainability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Applications
    subgraph "Client Applications"
        direction TB
        CE["Chrome Extension"]:::client
        FE["React Web Client"]:::client
        RN["React Native App"]:::client
    end

    %% Infrastructure and Deployment Layer
    subgraph "Infrastructure"
        direction TB
        NGINX["NGINX Reverse Proxy"]:::infra
        DOCKER["Docker Containers"]:::infra
        EC2["Amazon EC2"]:::infra
        DC["Docker Compose"]:::infra
        DF["Back Dockerfile"]:::infra
    end

    %% Back-End Server with its Modules
    subgraph "NestJS API Server (Back-End)"
        direction TB
        API["API Server"]:::backend
        subgraph "Modules"
            direction TB
            AUTH["Auth Module"]:::backend
            MENUS["Menus Module"]:::backend
            IMAGES["Images Module"]:::backend
            CRAWLING["Crawling Module"]:::backend
            BATCH["Batch-Task Module"]:::backend
            USER_MENUS["User-Menus Module"]:::backend
            USERS["Users Module"]:::backend
        end
    end

    %% Database
    DB["PostgreSQL Database"]:::db

    %% Data Flow Connections
    CE -->|"APIcalls"| NGINX
    FE -->|"APIcalls"| NGINX
    RN -->|"APIcalls"| NGINX

    NGINX -->|"Proxies"| API
    DOCKER -->|"Hosts"| API
    DOCKER --> EC2

    API -->|"UsesTypeORM"| DB

    %% Click Events
    click CE "https://github.com/zktm9903/nhn-eat/tree/main/chrome-extension/"
    click FE "https://github.com/zktm9903/nhn-eat/tree/main/front/"
    click RN "https://github.com/zktm9903/nhn-eat/tree/main/rn/"
    click API "https://github.com/zktm9903/nhn-eat/tree/main/back/"
    click DB "https://github.com/zktm9903/nhn-eat/blob/main/back/src/database/typeorm.config.ts"
    click NGINX "https://github.com/zktm9903/nhn-eat/blob/main/nginx/conf/default.conf"
    click DC "https://github.com/zktm9903/nhn-eat/blob/main/docker-compose.yml"
    click DF "https://github.com/zktm9903/nhn-eat/tree/main/back/dockerfile"

    %% Styles
    classDef client fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#43A047,stroke-width:2px;
    classDef db fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
    classDef infra fill:#F0F4C3,stroke:#7CB342,stroke-width:2px;
```
