# akazdayo/disco-chan architecture

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

- Interactive diagram: https://gitdiagram.com/akazdayo/disco-chan
- Repository: https://github.com/akazdayo/disco-chan

## Overview

##### Main Components

a. Frontend Layer:
- Astro Pages (src/pages/)
- React Components (src/components/)
- UI Components (src/components/ui/)
- Layouts (src/layouts/)

b. Authentication Layer:
- Discord OAuth Integration
- Auth Components (src/components/auth/)

c. Backend Layer:
- API Routes (src/pages/api/)
- Database Layer (Prisma)

##### Client-Side Flow
- User Browser -> Astro Pages -> React Components -> API Endpoints

##### Authentication Flow
- User -> Discord OAuth -> Auth Components -> Database

##### Data Flow
- UI Components -> API Routes -> Prisma Client -> Database

##### Specific Implementation Details

- 🟦 Blue rectangles for Astro pages and layouts
- 🟨 Yellow rectangles for React components
- 🟩 Green rectangles for API endpoints
- 🟪 Purple database symbol for Prisma/Database
- 🟥 Red rectangle for Discord OAuth

##### Component Relationships

- Posts flow (Timeline -> Post -> Reactions)
- Authentication flow (LoginButton -> Discord -> Database)
- Data mutations (API routes -> Database)

##### Technical Stack Highlights

- Astro for page rendering
- React for interactive components
- Prisma for database ORM
- Discord for authentication
- Tailwind CSS for styling

##### Key Features to Emphasize

- Post Management
- Reaction System
- Authentication
- User Management

Specific Guidelines:

##### In the Frontend section, create subsections for
- Pages (index.astro, afterlogin.astro, etc.)
- Components (posts, auth, ui)
##### In the API Layer, show
- API routes (addreaction.ts, logout.ts, submit.ts)
- Auth handlers
##### In the Database section, show
- Prisma schema
- Database tables

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Frontend Layer"
        Pages["Astro Pages"]:::pages
        Layout["Base Layout"]:::layout
        
        subgraph "Components"
            direction TB
            UI["UI Components"]:::ui
            Auth["Auth Components"]:::auth
            LoginBtn["Login Button"]:::auth
            TokenHandler["Token Handler"]:::auth
            
            subgraph "Post System"
                direction TB
                Timeline["Timeline"]:::posts
                Post["Post Component"]:::posts
                CreatePost["Post Creation"]:::posts
                Reactions["Reactions"]:::posts
            end
        end
    end

    subgraph "API Layer"
        API_React["Reaction Handler"]:::api
        API_Auth["Auth Handler"]:::api
        API_Submit["Post Submission"]:::api
    end

    subgraph "Data Layer"
        UserMgmt["User Management"]:::data
        PrismaClient["Prisma Client"]:::data
        Database[(Database)]:::database
        Schema["Prisma Schema"]:::data
    end

    subgraph "External Services"
        Discord["Discord OAuth"]:::external
    end

    %% Relationships
    Browser --> Pages
    Pages --> Layout
    Layout --> Components
    Auth --> Discord
    LoginBtn --> Discord
    TokenHandler --> UserMgmt
    Timeline --> Post
    Post --> Reactions
    CreatePost --> API_Submit
    Reactions --> API_React
    Auth --> API_Auth
    API_React --> PrismaClient
    API_Auth --> PrismaClient
    API_Submit --> PrismaClient
    PrismaClient --> Database
    Schema --> Database
    UserMgmt --> PrismaClient

    %% Click Events
    click Pages "https://github.com/akazdayo/disco-chan/tree/main/src/pages/"
    click Layout "https://github.com/akazdayo/disco-chan/blob/main/src/layouts/base.astro"
    click UI "https://github.com/akazdayo/disco-chan/tree/main/src/components/ui/"
    click Auth "https://github.com/akazdayo/disco-chan/tree/main/src/components/auth/"
    click LoginBtn "https://github.com/akazdayo/disco-chan/blob/main/src/components/auth/loginButton.tsx"
    click TokenHandler "https://github.com/akazdayo/disco-chan/blob/main/src/components/auth/get_token.ts"
    click Timeline "https://github.com/akazdayo/disco-chan/blob/main/src/components/posts/timeline.astro"
    click Post "https://github.com/akazdayo/disco-chan/blob/main/src/components/posts/post.astro"
    click CreatePost "https://github.com/akazdayo/disco-chan/blob/main/src/components/posts/create/popup.tsx"
    click Reactions "https://github.com/akazdayo/disco-chan/blob/main/src/components/posts/reactions.tsx"
    click API_React "https://github.com/akazdayo/disco-chan/blob/main/src/pages/api/addreaction.ts"
    click API_Auth "https://github.com/akazdayo/disco-chan/blob/main/src/pages/api/logout.ts"
    click API_Submit "https://github.com/akazdayo/disco-chan/blob/main/src/pages/api/submit.ts"
    click Schema "https://github.com/akazdayo/disco-chan/blob/main/prisma/schema.prisma"
    click PrismaClient "https://github.com/akazdayo/disco-chan/blob/main/src/lib/prisma.ts"
    click UserMgmt "https://github.com/akazdayo/disco-chan/blob/main/src/lib/user.ts"

    %% Styling
    classDef pages fill:#2B6CB0
    classDef layout fill:#2C5282
    classDef ui fill:#C53030
    classDef auth fill:#B83280
    classDef posts fill:#2F855A
    classDef api fill:#6B46C1
    classDef data fill:#B7791F
    classDef database fill:#4A5568
    classDef external fill:#718096

    %% Legend
    subgraph Legend
        L1[Astro Pages]:::pages
        L2[Layout]:::layout
        L3[UI Components]:::ui
        L4[Auth Components]:::auth
        L5[Post System]:::posts
        L6[API Routes]:::api
        L7[Data Layer]:::data
        L8[(Database)]:::database
        L9[External Services]:::external
    end
```
