# 4anghyeon/magic-pos architecture

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

- Interactive diagram: https://gitdiagram.com/4anghyeon/magic-pos
- Repository: https://github.com/4anghyeon/magic-pos

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Application (Client-side)
- Admin Portal (/admin routes)
- Mobile Kiosk (/kiosk routes)
- Authentication System (/auth routes)
- PWA Support (manifest.json, service workers)

b) Backend Layer:
- Supabase (BaaS)
- Authentication
- Database
- Real-time subscriptions
- Storage

c) External Services:
- Toss Payments Integration
- Firebase Cloud Messaging (FCM)
- Business Registration API
- Translation Service

##### Key Architectural Patterns to Highlight

a) State Management:
- Zustand stores (/shared/store)
- React Query for server state
- Custom hooks for business logic

b) Feature Modules:
- Menu Management
- Order Processing
- Sales Analytics
- Platform Management
- Store Configuration
- QR Code Generation

**Client Layer**
- PWA Container
- Mobile Kiosk
- Push Notifications
- Web Application
- Admin Portal
- Store Management
- Analytics Dashboard

**Service Layer**
- Authentication
- State Management
- Zustand
- React Query
- Business Logic
- Order Processing
- Menu Management
- Sales Analytics

**External Services Layer**
- Toss Payments
- Firebase Cloud Messaging
- Business Registration API
- Translation Service

**Data Layer**
- Supabase
- Authentication
- Database
- Real-time
- Storage

##### Important Relationships to Highlight

- Real-time order notifications flow
- Payment processing sequence
- Authentication flow
- Data synchronization between admin and kiosk
- Push notification system

##### Implementation Details

- Maintain consistent symbol usage
- Version information
- Brief descriptions for complex flows

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef data fill:#9b59b6,stroke:#8e44ad,color:white

    %% Client Layer
    subgraph ClientLayer
        PWA["PWA Container"]
        MK["Mobile Kiosk"]:::frontend
        PN["Push Notifications"]
        WA["Web Application"]
        AP["Admin Portal"]:::frontend
        SM["Store Management"]:::frontend
        AD["Analytics Dashboard"]:::frontend
    end

    %% Service Layer
    subgraph ServiceLayer
        Auth["Authentication System"]:::service
        StateM["State Management"]
        ZS["Zustand Store"]:::service
        RQ["React Query"]:::service
        BL["Business Logic"]
        OP["Order Processing"]:::service
        MM["Menu Management"]:::service
        SA["Sales Analytics"]:::service
        QR["QR Code Generation"]:::service
        TC["Store Configuration"]:::service
    end

    %% External Services Layer
    subgraph ExternalLayer
        TP["Toss Payments"]:::external
        FCM["Firebase Cloud Messaging"]:::external
        BRA["Business Registration API"]:::external
        TS["Translation Service"]:::external
    end

    %% Data Layer
    subgraph DataLayer
        SB["Supabase"]:::data
        SBA["Authentication"]:::data
        SBD["Database"]:::data
        SBR["Real-time"]:::data
        SBS["Storage"]:::data
    end

    %% Relationships
    PWA --> MK
    PWA --> PN
    WA --> AP
    WA --> SM
    WA --> AD
    
    Auth --> SBA
    StateM --> ZS
    StateM --> RQ
    BL --> OP
    BL --> MM
    BL --> SA
    BL --> QR
    BL --> TC
    
    OP --> TP
    PN --> FCM
    SM --> BRA
    WA --> TS
    
    SB --> SBA
    SB --> SBD
    SB --> SBR
    SB --> SBS

    %% Click Events
    click AP "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/layout/admin"
    click MK "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/kiosk"
    click Auth "https://github.com/4anghyeon/magic-pos/blob/dev/src/server/api/supabase/auth.ts"
    click PWA "https://github.com/4anghyeon/magic-pos/blob/dev/public/manifest.json"
    click MM "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/menu-item"
    click OP "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/order-check-list"
    click SA "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/sales"
    click TC "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/store"
    click QR "https://github.com/4anghyeon/magic-pos/tree/dev/src/components/qrCodeModal"
    click ZS "https://github.com/4anghyeon/magic-pos/tree/dev/src/shared/store"
    click TS "https://github.com/4anghyeon/magic-pos/blob/dev/src/server/service/translate.ts"
    click SB "https://github.com/4anghyeon/magic-pos/tree/dev/src/server/api/supabase"

    %% Legend
    subgraph Legend
        F["Frontend"]:::frontend
        S["Service"]:::service
        E["External"]:::external
        D["Data"]:::data
    end
```
