# pranavgithubacc/techeshi-castle architecture

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

- Interactive diagram: https://gitdiagram.com/pranavgithubacc/techeshi-castle
- Repository: https://github.com/pranavgithubacc/techeshi-castle

## Overview

##### Main Components

A. Frontend Layer:
- Single Page Application (React + Vite)
- Key Components:
- Public Pages (Home, Events, CreateTeam)
- Protected Pages (Quiz, Leaderboard, AdminDashboard)
- Authentication Components
- UI Components (Navbar, Footer, DynamicBackground)

B. Backend Layer:
- Node.js/Express Application
- Three Main Domains:
- Teams Management
- Circuits Management
- Questions Management

C. Database Layer:
- MongoDB (indicated by the db.js in config)
- Collections:
- Teams
- Circuit Steps
- Questions

**[Client Tier] <-> [Application Tier] <-> [Data Tier]**

##### Component Relationships

A. Frontend-Backend Communication:
- Team Routes (/api/teams)
- Circuit Routes (/api/circuits)
- Question Routes (/api/questions)

B. Backend-Database Communication:
- MongoDB connections
- Data flow between controllers and models

##### Specific Elements

A. Authentication Flow:
- Admin authentication flow
- Team authentication flow
- Protected route mechanisms

B. Business Logic Layer:
- Circuit evaluation system
- Quiz management system
- Team scoring system

##### Important Architectural Patterns to Highlight

- MVC Pattern in Backend:
- Models (Team.js, circuitSteps.js, question.js)
- Controllers (teamController.js, circuitsController.js, questionController.js)
- Routes (teamRoutes.js, circuitRoutes.js, questionRoutes.js)

- Component-Based Architecture in Frontend:
- Pages
- Reusable Components
- Assets Management

##### Data Layer (MongoDB)

Remember to:
- Use consistent styling
- Clear labels
- Data flow directions
- Security boundaries
- Document all external integrations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        FE[Frontend Application]
        
        subgraph PublicPages["Public Pages"]
            direction TB
            Home["Home"]:::frontend
            Events["Events"]:::frontend
            CreateTeam["Create Team"]:::frontend
        end

        subgraph ProtectedPages["Protected Pages"]
            direction TB
            Quiz["Quiz"]:::frontend
            Leaderboard["Leaderboard"]:::frontend
            AdminDash["Admin Dashboard"]:::frontend
            AdminLogin["Admin Login"]:::frontend
        end

        subgraph UIComponents["UI Components"]
            direction TB
            Navbar["Navbar"]:::frontend
            Footer["Footer"]:::frontend
            DynBG["Dynamic Background"]:::frontend
            JoinModal["Join Battle Modal"]:::frontend
        end

        ProtRoute["Protected Route Handler"]:::security
    end

    subgraph Server["Server Layer"]
        direction TB
        BE["Backend Application"]:::backend

        subgraph Controllers["Controllers"]
            direction TB
            TeamCtrl["Teams Controller"]:::controller
            CircuitCtrl["Circuits Controller"]:::controller
            QuestionCtrl["Questions Controller"]:::controller
        end

        subgraph Routes["API Routes"]
            direction TB
            TeamRoutes["/api/teams"]:::api
            CircuitRoutes["/api/circuits"]:::api
            QuestionRoutes["/api/questions"]:::api
        end

        subgraph Models["Data Models"]
            direction TB
            TeamModel["Team Model"]:::model
            CircuitModel["Circuit Steps Model"]:::model
            QuestionModel["Question Model"]:::model
        end
    end

    subgraph Data["Data Layer"]
        MongoDB[(MongoDB Database)]:::database
        DBConfig["Database Config"]:::config
    end

    %% Relationships
    FE --> Routes
    Routes --> Controllers
    Controllers --> Models
    Models --> MongoDB
    MongoDB --> DBConfig

    %% Click Events
    click Home "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/Home.jsx"
    click Events "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/Events.jsx"
    click CreateTeam "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/CreateTeam.jsx"
    click Quiz "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/Quiz.jsx"
    click Leaderboard "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/Leaderboard.jsx"
    click AdminDash "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/AdminDashboard.jsx"
    click AdminLogin "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/pages/AdminLogin.jsx"
    click Navbar "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/components/Navbar.jsx"
    click Footer "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/components/Footer.jsx"
    click DynBG "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/components/DynamicBackground.jsx"
    click JoinModal "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/components/JoinBattleModal.jsx"
    click ProtRoute "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/frontend/src/components/ProtectedRoute.jsx"
    click TeamCtrl "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/controllers/teamController.js"
    click CircuitCtrl "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/controllers/circuitsController.js"
    click QuestionCtrl "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/controllers/questionController.js"
    click TeamModel "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/models/Team.js"
    click CircuitModel "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/models/circuitSteps.js"
    click QuestionModel "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/models/question.js"
    click TeamRoutes "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/routes/teamRoutes.js"
    click CircuitRoutes "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/routes/circuitRoutes.js"
    click QuestionRoutes "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/routes/questionRoutes.js"
    click DBConfig "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/config/db.js"
    click BE "https://github.com/PranavGitHubAcc/Techeshi-Castle/blob/main/backend/app.js"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef api fill:#FF9800,color:white
    classDef controller fill:#9C27B0,color:white
    classDef model fill:#E91E63,color:white
    classDef database fill:#607D8B,color:white
    classDef security fill:#F44336,color:white
    classDef config fill:#795548,color:white
```
