# ataekren/secrethitlertracker architecture

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

- Interactive diagram: https://gitdiagram.com/ataekren/secrethitlertracker
- Repository: https://github.com/ataekren/secrethitlertracker

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Next.js for the frontend and Firebase for the backend (authentication, Firestore, hosting). Its purpose is to track game matches, maintain player statistics, and provide an admin panel for managing data.

##### Key Components
a. Frontend Components:
- Next.js Pages (located in the app/ directory):
- Public Landing Page (app/page.tsx) that integrates components for Leaderboard, RoleStats, and MatchList.
- Admin Page (app/admin/page.tsx) for managing players and match results.
- Login Page (app/login/page.tsx) for authentication.
- Global layout and not-found handling (app/layout.tsx, app/not-found.tsx).
- UI Components (from the components/ directory):
- Forms for adding players and matches (AddPlayerForm.tsx, AddMatchForm.tsx).
- Components like Leaderboard, RoleStats, MatchList, etc.
- Reusable UI elements under components/ui such as buttons, dialogs, tables, and toast notifications.

b. Backend/Infrastructure:
- Firebase Integration:
- lib/firebase.ts handles Firebase initialization and configuration.
- Firestore is used as the primary database for storing Players and Matches (as detailed in the Data Model).
- Authentication is via Firebase as described in the setup instructions.
- Utilities and Hooks:
- hooks/use-toast.ts and components/use-toast.ts manage in-app notifications.
- lib/utils.ts for shared helper functions.

c. External/Config Components:
- Next.js Configuration (next.config.mjs, tsconfig.json) and environment setup.
- Styling through Tailwind CSS (global CSS, tailwind.config.js/ts).
- ESLint and other development configurations to maintain code quality.

##### Architectural Relationships and Data Flow
- User Interaction Layer:
- Users (or administrators) navigate to different Next.js pages.
- The Navigator (Navbar component) provides links to login, admin, and main pages.
- UI Component Integration:
- Each page composes several smaller components (e.g., Leaderboard, RoleStats, MatchList) that fetch and display data.
- The forms (AddPlayerForm, AddMatchForm) interact with Firebase through library calls.
- Business Logic / Data Layer:
- The Firebase module manages connections to Firestore and handles real-time data updates.
- Data flows from Firebase directly into the UI components using React Firebase Hooks.
- Authentication:
- The login page secures the Admin Panel, with Firebase handling user authentication.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend: Next.js Pages
    subgraph "Client (Next.js Pages)"
        A1["Public Landing Page \n– app/page.tsx"]:::frontend
        A2["Admin Page \n– app/admin/page.tsx"]:::frontend
        A3["Login Page \n– app/login/page.tsx"]:::frontend
        A4["Global Layout \n– app/layout.tsx"]:::frontend
        A5["Not Found Page \n– app/not-found.tsx"]:::frontend
    end

    %% UI Components
    subgraph "UI Components"
        B1["Add Player Form \n– components/AddPlayerForm.tsx"]:::frontend
        B2["Add Match Form \n– components/AddMatchForm.tsx"]:::frontend
        B3["Leaderboard \n– components/Leaderboard.tsx"]:::frontend
        B4["Role Stats \n– components/RoleStats.tsx"]:::frontend
        B5["Match List \n– components/MatchList.tsx"]:::frontend
        B6["Navbar \n– components/Navbar.tsx"]:::frontend
        B7["UI Elements \n– components/ui/"]:::frontend
        B8["Toast/Notification \n– components/toast.tsx, components/toaster.tsx, hooks/use-toast.ts, components/use-toast.ts"]:::frontend
    end

    %% Firebase Backend
    subgraph "Firebase Backend"
        C1["Firebase Init & Config \n– lib/firebase.ts"]:::backend
        C2["Firestore Database"]:::backend
        C3["Authentication Service"]:::backend
    end

    %% Utilities & Helpers
    subgraph "Utilities & Helpers"
        D1["Utility Functions \n– lib/utils.ts"]:::utils
    end

    %% Configuration & Build Settings
    subgraph "Configurations"
        E1["Next.js Config \n– next.config.mjs"]:::config
        E2["TypeScript Config \n– tsconfig.json"]:::config
        E3["Global CSS \n– app/globals.css"]:::config
        E4_1["Tailwind Config \n– tailwind.config.js"]:::config
        E4_2["Tailwind Config \n– tailwind.config.ts"]:::config
    end

    %% Relationships
    %% Navigation via Navbar
    B6 -->|"navigatesTo"| A1
    B6 -->|"navigatesTo"| A2
    B6 -->|"navigatesTo"| A3

    %% Global Layout routes pages
    A4 --> A1
    A4 --> A2
    A4 --> A3
    A4 --> A5

    %% Page Compositions
    A1 -->|"composes"| B3
    A1 -->|"composes"| B4
    A1 -->|"composes"| B5

    A2 -->|"composes"| B1
    A2 -->|"composes"| B2
    A2 -->|"includes"| B8

    %% Authentication Flow
    A3 -->|"authenticatesVia"| C3

    %% Data Flow: UI Forms to Firebase
    B1 -->|"savesTo"| C1
    B2 -->|"savesTo"| C1
    C1 -->|"manages"| C2
    C1 -->|"manages"| C3

    %% UI Notification uses Utility Functions
    B8 -->|"triggers"| D1

    %% Global Layout Configurations
    A4 -->|"configuredBy"| E1
    A4 -->|"configuredBy"| E2
    A4 -->|"configuredBy"| E3
    A4 -->|"configuredBy"| E4_1
    A4 -->|"configuredBy"| E4_2

    %% Styles
    classDef frontend fill:#B3CDE0,stroke:#6497B1,stroke-width:2px;
    classDef backend fill:#FBB4AE,stroke:#F768A1,stroke-width:2px;
    classDef utils fill:#CBE86B,stroke:#9ACD32,stroke-width:2px;
    classDef config fill:#D5E1DF,stroke:#A3B18A,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/ataekren/secrethitlertracker/blob/main/app/page.tsx"
    click A2 "https://github.com/ataekren/secrethitlertracker/blob/main/app/admin/page.tsx"
    click A3 "https://github.com/ataekren/secrethitlertracker/blob/main/app/login/page.tsx"
    click A4 "https://github.com/ataekren/secrethitlertracker/blob/main/app/layout.tsx"
    click A5 "https://github.com/ataekren/secrethitlertracker/blob/main/app/not-found.tsx"
    click B1 "https://github.com/ataekren/secrethitlertracker/blob/main/components/AddPlayerForm.tsx"
    click B2 "https://github.com/ataekren/secrethitlertracker/blob/main/components/AddMatchForm.tsx"
    click B3 "https://github.com/ataekren/secrethitlertracker/blob/main/components/Leaderboard.tsx"
    click B4 "https://github.com/ataekren/secrethitlertracker/blob/main/components/RoleStats.tsx"
    click B5 "https://github.com/ataekren/secrethitlertracker/blob/main/components/MatchList.tsx"
    click B6 "https://github.com/ataekren/secrethitlertracker/blob/main/components/Navbar.tsx"
    click B7 "https://github.com/ataekren/secrethitlertracker/tree/main/components/ui/"
    click B8 "https://github.com/ataekren/secrethitlertracker/blob/main/components/toast.tsx"
    click C1 "https://github.com/ataekren/secrethitlertracker/blob/main/lib/firebase.ts"
    click D1 "https://github.com/ataekren/secrethitlertracker/blob/main/lib/utils.ts"
    click E1 "https://github.com/ataekren/secrethitlertracker/blob/main/next.config.mjs"
    click E2 "https://github.com/ataekren/secrethitlertracker/blob/main/tsconfig.json"
    click E3 "https://github.com/ataekren/secrethitlertracker/blob/main/app/globals.css"
    click E4_1 "https://github.com/ataekren/secrethitlertracker/blob/main/tailwind.config.js"
    click E4_2 "https://github.com/ataekren/secrethitlertracker/blob/main/tailwind.config.ts"
```
