# triellis/clash-of-codes architecture

> Architecture diagram of the GitHub repository triellis/clash-of-codes, 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/triellis/clash-of-codes
- Repository: https://github.com/triellis/clash-of-codes

## Overview

##### Main Components

a) Client-Side (Next.js Application):
- Inside this container, create sub-sections for:
- Pages Layer (Admin, Clans, Live, PastScores)
- Components Layer (Reusable UI components)
- State Management (Redux store - indicated by userSlice.ts)
- Utilities Layer (functions, hooks, types)

b) External Services:
- CodeForces API
- Custom Express Backend (as mentioned in README)
- Authentication Service (indicated by LoginBtn component)

##### Component Relationships

- Data flow between pages and components
- API calls to CodeForces and custom backend
- State management interactions
- Authentication flow

##### Specific Implementation Details

Create sections showing:
- Routing structure (based on the app directory structure)
- Component hierarchy (showing reusable components)
- Data flow for live contest updates
- Clan management system

**┌─ Next.js Frontend ─────────────────────┐**
- ┌─ Pages ─────────┐ ┌─ Components ──┐ │
- Admin         │ │ - NavBar      │ │
- Clans         │ │ - Leaderboard │ │
- Live          │ │ - UserItem    │ │
- PastScores    │ │ - ...         │ │
- ┘ └──────────────┘ │
- ┌─ State ─────────┐ ┌─ Utils ──────┐ │
- User Store    │ │ - Functions   │ │
- Redux         │ │ - Hooks       │ │
- ┘ └──────────────┘ │
- ┘

**┌─ APIs ──────────┐  ┌─ Backend ────────┐**
- CodeForces    │  │ - Express Server │
- Authentication│  │ - Contest Data   │
- ┘  └─────────────────┘

##### Important Notes

- Real-time data flow for live contest updates
- Clan management system's interaction with the backend
- Authentication flow
- How past scores are stored and retrieved
- Error handling paths (Error component)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        NextApp["Next.js Application"]
        
        subgraph Pages
            Admin["Admin Dashboard"]:::page
            Clans["Clans Management"]:::page
            Live["Live Scoring"]:::page
            PastScores["Past Scores"]:::page
        end
        
        subgraph Components
            NavBar["Navigation Bar"]:::component
            LoginBtn["Login Button"]:::component
            Leaderboard["Leaderboard"]:::component
            UserItem["User Item"]:::component
            ClanCard["Clan Card"]:::component
            ConfigItem["Config Item"]:::component
            UserAdd["User Addition"]:::component
            PastScoreBoard["Past Score Board"]:::component
            SearchBar["Search Bar"]:::component
            Pagination["Pagination"]:::component
            NotifToast["Notifications"]:::component
        end
        
        subgraph State
            ReduxStore["Redux Store"]:::state
            UserState["User State"]:::state
        end
        
        subgraph Utils
            Functions["Helper Functions"]:::util
            Hooks["Custom Hooks"]:::util
            Types["Type Definitions"]:::util
        end
        
        ErrorHandler["Error Handler"]:::error
    end
    
    subgraph External
        CodeForcesAPI["CodeForces API"]:::external
        Backend["Express Backend"]:::external
        Auth["Authentication Service"]:::external
    end
    
    %% Relationships
    NextApp --> Pages
    NextApp --> Components
    NextApp --> State
    NextApp --> Utils
    
    Admin --> ReduxStore
    Clans --> ReduxStore
    Live --> ReduxStore
    PastScores --> ReduxStore
    
    Components --> ReduxStore
    ReduxStore --> UserState
    
    NextApp --> CodeForcesAPI
    NextApp --> Backend
    LoginBtn --> Auth
    
    %% Click Events
    click Admin "https://github.com/Triellis/clash-of-codes/tree/main/app/Admin"
    click Clans "https://github.com/Triellis/clash-of-codes/tree/main/app/Clans"
    click Live "https://github.com/Triellis/clash-of-codes/tree/main/app/Live"
    click PastScores "https://github.com/Triellis/clash-of-codes/tree/main/app/PastScores"
    click NavBar "https://github.com/Triellis/clash-of-codes/tree/main/app/components/NavBar"
    click LoginBtn "https://github.com/Triellis/clash-of-codes/tree/main/app/components/LoginBtn"
    click Leaderboard "https://github.com/Triellis/clash-of-codes/tree/main/app/components/Leaderboard"
    click UserItem "https://github.com/Triellis/clash-of-codes/tree/main/app/components/UserItem"
    click ClanCard "https://github.com/Triellis/clash-of-codes/tree/main/app/components/ClanCard"
    click ConfigItem "https://github.com/Triellis/clash-of-codes/tree/main/app/components/ConfigItem"
    click UserAdd "https://github.com/Triellis/clash-of-codes/tree/main/app/components/UserAdd"
    click PastScoreBoard "https://github.com/Triellis/clash-of-codes/tree/main/app/components/PastScoreBoard"
    click SearchBar "https://github.com/Triellis/clash-of-codes/tree/main/app/components/Searchbar"
    click Pagination "https://github.com/Triellis/clash-of-codes/tree/main/app/components/Pagination"
    click NotifToast "https://github.com/Triellis/clash-of-codes/tree/main/app/components/NotifToast"
    click ReduxStore "https://github.com/Triellis/clash-of-codes/blob/main/app/util/store.ts"
    click UserState "https://github.com/Triellis/clash-of-codes/blob/main/app/util/userSlice.ts"
    click Functions "https://github.com/Triellis/clash-of-codes/blob/main/app/util/functions.ts"
    click Hooks "https://github.com/Triellis/clash-of-codes/blob/main/app/util/hooks.ts"
    click Types "https://github.com/Triellis/clash-of-codes/blob/main/app/util/types.ts"
    click ErrorHandler "https://github.com/Triellis/clash-of-codes/tree/main/app/Error"
    
    %% Styles
    classDef page fill:#3498db
    classDef component fill:#2ecc71
    classDef state fill:#e67e22
    classDef util fill:#95a5a6
    classDef error fill:#e74c3c
    classDef external fill:#9b59b6
```
