# entropy-10/2024-website architecture

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

- Interactive diagram: https://gitdiagram.com/entropy-10/2024-website
- Repository: https://github.com/entropy-10/2024-website

## Overview

##### Main Components
- API Routes – Located under /src/app/api. In particular, you have authentication callbacks (for Discord and osu), relink endpoints, heartbeat monitoring, and possibly more API endpoints. These API handlers serve as your back-end functions integrated into the Next.js framework.
- Localization – The [locale] directories and the “src/i18n” folder showcase that your pages/components are duplicated or dynamically built per language. This should be highlighted as an integral feature.
- Database/Data Layer – The integration of Supabase (visible under /src/lib/supabase) shows that your application relies on an external database/service. Also, some business logic components (like lib/session.ts, lib/sheets.ts, etc.) connect the frontend/API to Supabase.
- External Services/Integrations – Include Discord and osu integrations (e.g., src/api/auth/callback/{discord,osu}) as well as external hosting (Vercel) and status monitoring (BetterStack) services. These components are important for authentication and uptime monitoring.

##### Relationships and Interactions
- User Requests hit the Frontend:
– The client interacts with localized pages (served through Next.js app router).
– Components inside these pages interact with subcomponents (headers, footers, UI elements) and hooks (like use-size-query) from /src/hooks.
- API Layer Integration:
– When authentication, data updates, or form submissions occur, these actions call the API endpoints found under /src/app/api.
– For example, authentication callbacks (Discord, osu) process the external OAuth responses and then update the session in Supabase via the Supabase client libraries.
- Data Flow to Supabase:
– Business logic to read/write data is encapsulated in the /src/lib/supabase/* files.
– API endpoints and server-side components (like action handlers in profile, team, register) interact with Supabase to manage tournament data.
- Localization & Internationalization:
– The application routes (via [locale] folders) use Next Intl for language-specific routing and rendering – denote this as a cross-cutting concern.
- External Service Integration:
– OAuth callbacks connect to external providers (Discord, osu).
– BetterStack is used for status monitoring; Vercel handles deployment and hosting.

##### Architectural Patterns and Design Principles
- Next.js App Router Pattern: The file structure under /src/app/[locale] shows that the project is built with Next.js’s app directory pattern emphasizing server components and layouts.
- Separation of Concerns: The clear distinction between UI components, API endpoints, and the data layer points to a decoupled architecture.
- Modular Design: There is clear modularization (by domain, such as teams, schedule, profile) which can be individually maintained and updated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser/Client"]:::infra

    subgraph "Frontend Application"
        LocalizedPages["Localized Pages (src/app/[locale])"]:::frontend
        UIComponents["UI Components (src/app/[locale]/_components & src/components)"]:::frontend
        Localization["Internationalization & Localization (src/i18n & src/messages)"]:::localization
    end

    subgraph "API Endpoints"
        AuthDiscord["Authentication Callback Discord (src/app/api/auth/callback/discord/route.ts)"]:::api
        AuthOsu["Authentication Callback osu (src/app/api/auth/callback/osu/route.ts)"]:::api
        Relink["Relink Endpoint (src/app/api/auth/relink/discord/route.ts)"]:::api
        Heartbeat["Heartbeat Monitoring (src/app/api/heartbeat/route.ts)"]:::api
        APIUtils["API Utilities (src/app/api/auth/utils.ts)"]:::api
    end

    subgraph "Data Layer"
        SupabaseClient["Supabase Client (src/lib/supabase/client.ts)"]:::data
        SupabaseServer["Supabase Server (src/lib/supabase/server.ts)"]:::data
        SessionLogic["Session & Sheets Logic (src/lib/session.ts & src/lib/sheets.ts)"]:::data
    end

    subgraph "External Services"
        DiscordExt["Discord Integration (src/lib/discord.ts)"]:::external
        OsuExt["osu Integration (src/lib/osu.ts)"]:::external
        Vercel["Vercel Hosting"]:::infra
        BetterStack["BetterStack Monitoring"]:::external
    end

    Browser -->|"sendsRequest"| LocalizedPages
    Browser -->|"sendsRequest"| UIComponents

    LocalizedPages -->|"rendersWith"| Localization
    LocalizedPages -->|"apiCall"| AuthDiscord
    LocalizedPages -->|"apiCall"| AuthOsu
    LocalizedPages -->|"apiCall"| Relink
    UIComponents -->|"triggers"| APIUtils

    AuthDiscord -->|"updatesSession"| SupabaseClient
    AuthDiscord -->|"calls"| DiscordExt

    AuthOsu -->|"updatesSession"| SupabaseClient
    AuthOsu -->|"calls"| OsuExt

    Relink -->|"updatesSession"| SupabaseClient
    Heartbeat -->|"checksUptime"| BetterStack
    APIUtils -->|"processesData"| SupabaseServer

    SupabaseClient -->|"dbOps"| SupabaseServer
    APIUtils -->|"managesData"| SessionLogic

    %% Click Events
    click LocalizedPages "https://github.com/entropy-10/2024-website/tree/main/src/app/[locale]"
    click UIComponents "https://github.com/entropy-10/2024-website/tree/main/src/app/[locale]/_components"
    click AuthDiscord "https://github.com/entropy-10/2024-website/blob/main/src/app/api/auth/callback/discord/route.ts"
    click AuthOsu "https://github.com/entropy-10/2024-website/blob/main/src/app/api/auth/callback/osu/route.ts"
    click Relink "https://github.com/entropy-10/2024-website/blob/main/src/app/api/auth/relink/discord/route.ts"
    click Heartbeat "https://github.com/entropy-10/2024-website/blob/main/src/app/api/heartbeat/route.ts"
    click APIUtils "https://github.com/entropy-10/2024-website/blob/main/src/app/api/auth/utils.ts"
    click Localization "https://github.com/entropy-10/2024-website/tree/main/src/i18n"
    click SupabaseClient "https://github.com/entropy-10/2024-website/blob/main/src/lib/supabase/client.ts"
    click SupabaseServer "https://github.com/entropy-10/2024-website/blob/main/src/lib/supabase/server.ts"
    click SessionLogic "https://github.com/entropy-10/2024-website/blob/main/src/lib/session.ts"
    click DiscordExt "https://github.com/entropy-10/2024-website/blob/main/src/lib/discord.ts"
    click OsuExt "https://github.com/entropy-10/2024-website/blob/main/src/lib/osu.ts"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef api fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef external fill:#ffa500,stroke:#000,stroke-width:1px;
    classDef infra fill:#d3d3d3,stroke:#000,stroke-width:1px;
    classDef localization fill:#ffb6c1,stroke:#000,stroke-width:1px;
    classDef data fill:#f4a460,stroke:#000,stroke-width:1px;
```
