# jaewon4/poki architecture

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

- Interactive diagram: https://gitdiagram.com/jaewon4/poki
- Repository: https://github.com/jaewon4/poki

## Overview

##### Main Components
- Client (Frontend):
– React-based single-page application with pages for signing in, chatting, mission management, video calls, and more.
– Integrates PWA elements (service workers, manifest.json) and Firebase for messaging.
– Organized into logical areas (components, pages, hooks, etc.).
- Server (Backend):
– Built with NestJS, which is organized into various modules such as auth, board, mission, event (chat messaging), push notifications, video-chat, and wishlist.
– Contains dedicated controllers, services, DTOs, repositories, and tests for each domain.
- Infrastructure / External Services:
– Database: Likely MySQL for persistent storage.
– Cache/Session: Redis, as indicated by the redis module.
– WebRTC and real-time communications: WebRTC, Socket.IO, and PeerJS for video calling and chat.
– DevOps/Deployment: AWS components (Route 53, CloudFront, ALB, ACM, S3) and GitHub Actions for deployment.

##### Relationships and Data Flow
- Client to Server:
– The React client makes API calls (documented in client/src/api) to the NestJS server endpoints.
– The backend handles authentication, mission registration, wish list updates, real-time chat, and video services.
- Server Internal Module Interactions:
– Each NestJS module (e.g., auth, board, mission, video-chat) encapsulates its own controller, service, and repository layers.
– Events for chat use real-time gateways (WebSocket/Socket.IO) to maintain communication channels.
- External Service Integration:
– Firebase messaging is integrated in the client for notifications.
– The backend interacts with MySQL for structured data and Redis for caching operations or session management.
– WebRTC/PeerJS facilitate direct video communications among users, making use of the backend as a signaling server when necessary.

##### Architectural Patterns
- Separation of Concerns: The project clearly separates presentation (client) from business logic and data management (server).
- Modularization: The NestJS backend is divided into modules (auth, board, mission, etc.), each with its own DTOs, services, and repositories.
- Real-Time Communication: Use of WebSocket-based real-time communication via Socket.IO and integration with WebRTC shows a mix of pub/sub or event-driven patterns.
- PWA and Responsive Design: The frontend configuration (service workers and manifest) signifies a mobile-friendly, installable app design.

##### Relevant Technologies and Frameworks
- Frontend: React, Tailwind CSS, Recoil for state management, Firebase.
- Backend: NestJS, TypeScript, various NestJS decorators, JWT authentication, and domain-specific modules.
- Communication: Socket.IO, PeerJS, WebRTC.
- Databases/Cache: MySQL and Redis.
- DevOps: GitHub Actions, AWS services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User("User"):::external

    %% Client (React Frontend)
    subgraph "Client (React Frontend)"
        RC("React Client (Poki App)"):::frontend
        Manifest("Manifest.json"):::frontend
        SW("Service Worker"):::frontend
        FirebaseSW("Firebase-Messaging SW"):::frontend
        FB("Firebase Messaging"):::frontend
        API("API Communication Layer"):::frontend
    end

    %% Server (NestJS Backend)
    subgraph "Server (NestJS Backend)"
        API_GATEWAY("API Gateway"):::backend
        AUTH("Auth Module"):::backend
        BOARD("Board Module"):::backend
        MISSION("Mission Module"):::backend
        CHAT("Chat/Event Module"):::backend
        PUSH("Push Notification Module"):::backend
        VIDEO("Video-Chat Module"):::backend
        WISHLIST("Wishlist Module"):::backend
        REDIS("Redis Cache Integration"):::backend
    end

    %% External Services & Infrastructure
    subgraph "External Services"
        MYSQL("MySQL Database"):::database
        WEBRTC("WebRTC/PeerJS Signaling"):::external
        AWS("AWS Services"):::external
    end

    %% Connections - Client
    User --> RC
    RC --> Manifest
    RC --> SW
    RC --> FirebaseSW
    RC --> FB
    RC -->|"API calls"| API

    %% Connection from Client to Server
    API -->|"REST"| API_GATEWAY

    %% Server Module Connections
    API_GATEWAY -->|"auth"| AUTH
    API_GATEWAY -->|"board"| BOARD
    API_GATEWAY -->|"mission"| MISSION
    API_GATEWAY -->|"chat"| CHAT
    API_GATEWAY -->|"push"| PUSH
    API_GATEWAY -->|"video-chat"| VIDEO
    API_GATEWAY -->|"wishlist"| WISHLIST
    API_GATEWAY -->|"cache"| REDIS

    %% External Interactions
    API_GATEWAY -->|"Data storage"| MYSQL
    VIDEO -->|"Signaling"| WEBRTC
    API_GATEWAY -->|"Deployed"| AWS
    RC -->|"Hosted assets"| AWS

    %% Click Events for Client Components
    click RC "https://github.com/jaewon4/poki/tree/master/client"
    click Manifest "https://github.com/jaewon4/poki/blob/master/client/public/manifest.json"
    click SW "https://github.com/jaewon4/poki/blob/master/client/src/service-worker.js"
    click FirebaseSW "https://github.com/jaewon4/poki/blob/master/client/public/firebase-messaging-sw.js"
    click FB "https://github.com/jaewon4/poki/blob/master/client/src/firebase.js"
    click API "https://github.com/jaewon4/poki/tree/master/client/src/api"

    %% Click Events for Server Components
    click AUTH "https://github.com/jaewon4/poki/tree/master/server/src/auth"
    click BOARD "https://github.com/jaewon4/poki/tree/master/server/src/board"
    click MISSION "https://github.com/jaewon4/poki/tree/master/server/src/mission"
    click CHAT "https://github.com/jaewon4/poki/tree/master/server/src/event"
    click PUSH "https://github.com/jaewon4/poki/tree/master/server/src/push"
    click VIDEO "https://github.com/jaewon4/poki/tree/master/server/src/video-chat"
    click WISHLIST "https://github.com/jaewon4/poki/tree/master/server/src/wishlist"
    click REDIS "https://github.com/jaewon4/poki/tree/master/server/src/redis"

    %% Styles
    classDef frontend fill:#bde0fe,stroke:#0077b6,stroke-width:2px;
    classDef backend fill:#ffc8dd,stroke:#ff006e,stroke-width:2px;
    classDef database fill:#fdffb6,stroke:#e6bd02,stroke-width:2px;
    classDef external fill:#caffbf,stroke:#008000,stroke-width:2px;
```
