# delta-kor/ma-eum architecture

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

- Interactive diagram: https://gitdiagram.com/delta-kor/ma-eum
- Repository: https://github.com/delta-kor/ma-eum

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Application (app directory structure)
- Main feature modules:
- About section
- Video player
- Music mixer
- Talk (social/community feature)
- Spark (AI-related feature)
- Calendar/Schedules

b) API Layer:
- tRPC API endpoints
- Video API
- Cache management API

c) Backend Services:
- Prisma ORM with database
- Authentication system
- Cache system
- File storage (for media)

##### Architectural Patterns to Highlight

a) Next.js App Router Architecture:
- Route groups: (main), (header), (artistic), (details), (neutral)
- API routes structure
- Server and client components separation

b) Feature Modules:
- Clear boundaries between different features
- Shared components and utilities
- Provider pattern implementation

##### Specific Implementation Details

a) Data Flow:
- Client-server communication via tRPC
- API routes interaction
- Cache invalidation paths
- Media content delivery

b) State Management:
- Provider hierarchy
- Context relationships
- Data persistence

**┌─────────────────────────────────────────────┐**
- Client Layer                │
- ┌─────────┐ ┌─────────┐ ┌─────────────────┐│
- About  │ │  Video  │ │  Music Mixer    ││
- ┘ └─────────┘ └─────────────────┘│
- ┌─────────┐ ┌─────────┐ ┌─────────────────┐│
- Talk   │ │  Spark  │ │  Calendar       ││
- ┘ └─────────┘ └─────────────────┘│
- ┬───────────────────────┘

**┌─────────────────────▼───────────────────────┐**
- API Layer                      │
- ┌─────────────┐ ┌──────────┐ ┌───────────┐ │
- tRPC API   │ │Video API │ │Cache API  │ │
- ┘ └──────────┘ └───────────┘ │
- ┬───────────────────────┘

**┌─────────────────────▼───────────────────────┐**
- Service Layer                    │
- ┌─────────┐ ┌──────────┐ ┌───────────────┐ │
- Prisma  │ │  Auth    │ │  File Storage │ │
- ┘ └──────────┘ └───────────────┘ │
- ┘

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        About["About Section"]
        Video["Video Player"]
        Mixer["Music Mixer"]
        Talk["Talk Feature"]
        Spark["Spark AI"]
        Calendar["Calendar/Schedules"]
        
        subgraph StateManagement["State Management"]
            direction TB
            ModalProvider["Modal Provider"]
            TRPCProvider["TRPC Provider"]
            MixerProvider["Mixer Control"]
            TransProvider["Translation Provider"]
            SparkProvider["Spark Provider"]
        end
        
        subgraph SharedComponents["Shared Components"]
            direction TB
            CoreUI["Core UI"]
            Cards["Cards"]
            Menus["Menus"]
            Modals["Modal Components"]
        end
    end

    subgraph API["API Layer"]
        direction TB
        TRPCAPI["tRPC API"]
        VideoAPI["Video API"]
        CacheAPI["Cache API"]
    end

    subgraph Services["Service Layer"]
        direction TB
        AlbumService["Album Service"]
        VideoService["Video Service"]
        MusicService["Music Service"]
        TalkService["Talk Service"]
        ScheduleService["Schedule Service"]
        
        subgraph Core["Core Services"]
            direction TB
            PrismaORM["Prisma ORM"]
            Auth["Authentication"]
            Cache["Cache System"]
            Storage["File Storage"]
        end
    end

    subgraph I18N["Internationalization"]
        direction TB
        Locales["Locale Files"]
        I18NUtils["Translation Utils"]
    end

    %% Connections
    Client --> API
    API --> Services
    Services --> Core
    StateManagement --> API
    SharedComponents --> Client

    %% Styling
    classDef frontend fill:#a8d5ff
    classDef api fill:#98ff98
    classDef service fill:#ffb366
    classDef core fill:#ff9999
    classDef i18n fill:#e6e6e6

    class About,Video,Mixer,Talk,Spark,Calendar,SharedComponents,StateManagement frontend
    class TRPCAPI,VideoAPI,CacheAPI api
    class AlbumService,VideoService,MusicService,TalkService,ScheduleService service
    class Core,PrismaORM,Auth,Cache,Storage core
    class I18N,Locales,I18NUtils i18n

    %% Click events
    click About "https://github.com/delta-kor/ma-eum/tree/main/app/(main)/about/"
    click Video "https://github.com/delta-kor/ma-eum/tree/main/app/(main)/(header)/(neutral)/video/"
    click Mixer "https://github.com/delta-kor/ma-eum/tree/main/app/(main)/mixer/"
    click Talk "https://github.com/delta-kor/ma-eum/tree/main/app/(main)/(header)/(artistic)/talk/"
    click Spark "https://github.com/delta-kor/ma-eum/tree/main/app/(main)/(header)/(artistic)/spark/"
    click Calendar "https://github.com/delta-kor/ma-eum/tree/main/app/(main)/(header)/(details)/schedules/"
    click TRPCAPI "https://github.com/delta-kor/ma-eum/tree/main/app/api/trpc/[trpc]/"
    click VideoAPI "https://github.com/delta-kor/ma-eum/tree/main/app/api/video/"
    click CacheAPI "https://github.com/delta-kor/ma-eum/tree/main/app/api/cache/"
    click PrismaORM "https://github.com/delta-kor/ma-eum/tree/main/prisma/"
    click Auth "https://github.com/delta-kor/ma-eum/blob/main/utils/auth.util.ts"
    click Cache "https://github.com/delta-kor/ma-eum/blob/main/utils/cache.util.ts"
    click Storage "https://github.com/delta-kor/ma-eum/blob/main/utils/storage.util.ts"
    click ModalProvider "https://github.com/delta-kor/ma-eum/blob/main/providers/ModalProvider.tsx"
    click TRPCProvider "https://github.com/delta-kor/ma-eum/blob/main/providers/TRPCProvider.tsx"
    click MixerProvider "https://github.com/delta-kor/ma-eum/blob/main/providers/MixerControlProvider.tsx"
    click TransProvider "https://github.com/delta-kor/ma-eum/blob/main/providers/TranslateProvider.tsx"
    click SparkProvider "https://github.com/delta-kor/ma-eum/blob/main/providers/SparkProvider.tsx"
    click AlbumService "https://github.com/delta-kor/ma-eum/blob/main/services/album.service.ts"
    click VideoService "https://github.com/delta-kor/ma-eum/blob/main/services/video.service.ts"
    click MusicService "https://github.com/delta-kor/ma-eum/blob/main/services/music.service.ts"
    click TalkService "https://github.com/delta-kor/ma-eum/blob/main/services/talk.service.ts"
    click ScheduleService "https://github.com/delta-kor/ma-eum/blob/main/services/schedule.service.ts"
    click CoreUI "https://github.com/delta-kor/ma-eum/tree/main/components/core/"
    click Cards "https://github.com/delta-kor/ma-eum/tree/main/components/card/"
    click Menus "https://github.com/delta-kor/ma-eum/tree/main/components/menu/"
    click Modals "https://github.com/delta-kor/ma-eum/tree/main/components/core/modal/"
    click Locales "https://github.com/delta-kor/ma-eum/tree/main/locales/"
    click I18NUtils "https://github.com/delta-kor/ma-eum/blob/main/utils/i18n.util.ts"
```
