# vishv0407/coc-auction architecture

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

- Interactive diagram: https://gitdiagram.com/vishv0407/coc-auction
- Repository: https://github.com/vishv0407/coc-auction

## Overview

##### Main Components

Frontend Layer:
- React Application (Vite-based)
- WebSocket Client (evident from WebSocketContext.jsx)
- Component Structure:
- Core Components (Navbar, Footer)
- Admin Components
- Page Components
- Authentication Components (RequireAuth.jsx)

Backend Layer:
- Node.js Server (server.js)
- API Routes
- Database Models
- WebSocket Server
- Authentication Service

Database Layer:
- MongoDB (implied by the models structure)
- Collections:
- Players
- Teams
- TransactionLogs

**┌─────────────────────────────────┐**
- Frontend Layer (React + Vite)   │
- ┤
- Backend Layer (Node.js)         │
- ┤
- Database Layer (MongoDB)        │
- ┘

##### Component Relationships

- HTTP/REST API calls between frontend and backend
- WebSocket connections for real-time updates
- Database operations between backend and MongoDB
- Authentication flow

##### Detailed Component Breakdown

Frontend (React + Vite):
- Components
- Admin Components
- Core UI Components
- Authentication Components
- Pages
- Admin Views
- User Views
- Public Views
- WebSocket Client

Backend (Node.js):
- API Routes
- Players
- Teams
- TransactionLogs
- Models
- WebSocket Server
- Authentication Middleware

##### Additional Elements

Include:
- Environment configurations
- Build/Deploy pipeline
- Static asset handling
- Error handling flow

##### Scalability points

Remember to include version information and any external service integrations that might be present in the actual deployment but not immediately visible in the source code.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        App["App"]:::frontend
        WSClient["WebSocket Client"]:::frontend
        Auth["Authentication"]:::auth
        
        subgraph CoreUI
            Navbar["Navbar"]:::ui
            AdminNav["Admin Navbar"]:::ui
            Footer["Footer"]:::ui
        end
        
        subgraph Pages
            direction TB
            AdminPages{"Admin Pages"}:::admin
            UserPages{"User Pages"}:::user
            PublicPages{"Public Pages"}:::public
            
            AdminDash["Admin Dashboard"]:::admin
            AdminLogs["Admin Logs"]:::admin
            Dashboard["User Dashboard"]:::user
            TeamPage["Team Page"]:::user
            BidPage["Random Bid"]:::user
            Home["Home"]:::public
            Scoreboard["Scoreboard"]:::public
            
            AdminPages --> AdminDash & AdminLogs
            UserPages --> Dashboard & TeamPage & BidPage
            PublicPages --> Home & Scoreboard
        end
    end
    
    subgraph Backend
        Server["Node.js Server"]:::backend
        WSServer["WebSocket Server"]:::backend
        
        subgraph Routes
            PlayerRoutes["Player Routes"]:::api
            TeamRoutes["Team Routes"]:::api
            TransactionRoutes["Transaction Routes"]:::api
        end
        
        subgraph Models
            PlayerModel["Player Model"]:::model
            TeamModel["Team Model"]:::model
            TransactionModel["Transaction Model"]:::model
        end
        
        subgraph Config
            TeamData["Team Data"]:::config
            PlayerData["Player Data"]:::config
            InitScript["Team Init Script"]:::config
        end
    end
    
    subgraph Database
        MongoDB[(MongoDB)]:::db
    end
    
    %% Relationships
    App --> WSClient
    App --> Auth
    Auth --> CoreUI
    WSClient <-.-> WSServer
    
    Server --> Routes
    Routes --> Models
    Models --> MongoDB
    
    %% Click Events
    click App "https://github.com/Vishv0407/coc-auction/blob/main/src/App.jsx"
    click WSClient "https://github.com/Vishv0407/coc-auction/blob/main/src/context/WebSocketContext.jsx"
    click Auth "https://github.com/Vishv0407/coc-auction/blob/main/src/components/RequireAuth.jsx"
    click Navbar "https://github.com/Vishv0407/coc-auction/blob/main/src/components/Navbar.jsx"
    click AdminNav "https://github.com/Vishv0407/coc-auction/blob/main/src/components/AdminNavbar.jsx"
    click Footer "https://github.com/Vishv0407/coc-auction/blob/main/src/components/Footer.jsx"
    click AdminDash "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/AdminDashboard.jsx"
    click AdminLogs "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/AdminLogs.jsx"
    click Dashboard "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/Dashboard.jsx"
    click TeamPage "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/TeamPage.jsx"
    click BidPage "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/RandomBid.jsx"
    click Home "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/Home.jsx"
    click Scoreboard "https://github.com/Vishv0407/coc-auction/blob/main/src/pages/Scoreboard.jsx"
    click Server "https://github.com/Vishv0407/coc-auction/blob/main/backend/server.js"
    click PlayerRoutes "https://github.com/Vishv0407/coc-auction/blob/main/backend/routes/players.js"
    click TeamRoutes "https://github.com/Vishv0407/coc-auction/blob/main/backend/routes/teams.js"
    click TransactionRoutes "https://github.com/Vishv0407/coc-auction/blob/main/backend/routes/transactionLogs.js"
    click PlayerModel "https://github.com/Vishv0407/coc-auction/blob/main/backend/models/Player.js"
    click TeamModel "https://github.com/Vishv0407/coc-auction/blob/main/backend/models/Team.js"
    click TransactionModel "https://github.com/Vishv0407/coc-auction/blob/main/backend/models/TransactionLog.js"
    click TeamData "https://github.com/Vishv0407/coc-auction/blob/main/src/constants/teamData.js"
    click PlayerData "https://github.com/Vishv0407/coc-auction/blob/main/src/data/players.json"
    click InitScript "https://github.com/Vishv0407/coc-auction/blob/main/backend/setup/initTeams.js"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef db fill:#FFC107,color:black
    classDef auth fill:#F44336,color:white
    classDef api fill:#9C27B0,color:white
    classDef model fill:#00BCD4,color:white
    classDef config fill:#FF9800,color:white
    classDef ui fill:#3F51B5,color:white
    classDef admin fill:#795548,color:white
    classDef user fill:#607D8B,color:white
    classDef public fill:#9E9E9E,color:white
```
