# distortion-12/esports-arena architecture

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

- Interactive diagram: https://gitdiagram.com/distortion-12/esports-arena
- Repository: https://github.com/distortion-12/esports-arena

## Overview

##### Project Type and Purpose
- This is a full-stack MERN (MongoDB, Express.js, React, Node.js) web application called “eSports Arena.”
- Purpose: allow users to discover official esports tournaments, create and manage community events, register/participate in scrims, and view live scorecards.

##### File Structure Analysis
- Monorepo with two top-level folders:
- backend/ – Node.js + Express server
– index.js (server entry point)
– routes/ (auth, players, tournaments, users)
– middleware/auth.js (JWT verification)
– models/ (Mongoose schemas for User, Player, Tournament)
– utils/sendEmail.js (Nodemailer OTP service)
- frontend/ – React single-page app
– public/ (static HTML, manifest, robots)
– src/
· components/ (Header, Footer, TournamentCard, etc.)
· pages/ (Home, Dashboard, Auth, TournamentDetail, LiveWatch, etc.)
· hooks/useAuth.js (auth state & token management)
· App.js, PrivateRoute.js, index.js
- Config: package.json, .gitignore in both folders; frontend uses React Router + Axios; backend uses environment variables for MongoDB, JWT, email.

##### README Highlights
- Key features: user registration/login with OTP email, protected routes, official vs. community events, tournament management, personal dashboard.
- Tech stack: React (frontend), Express/Node (backend), MongoDB/Mongoose, JWT, bcryptjs, Nodemailer (Gmail).
- Deployment runtimes: frontend on http://localhost:3000, backend on http://localhost:5000.

a. Main Components
- React Frontend
- Express/Node Backend API
- MongoDB Database
- External Email Service (Gmail via Nodemailer)
- Authentication Layer (JWT + bcryptjs)
b. Component Relationships
1. User interacts with React app in browser.
2. React makes HTTP requests to Express API (public & protected endpoints).
3. Express middleware verifies JWT (auth.js) for protected routes.
4. Express controllers (routes/) perform CRUD on MongoDB via Mongoose models.
5. On signup/login, backend sends OTP email through sendEmail util (Nodemailer → Gmail SMTP).
c. Architectural Patterns & Principles
– Client-Server (RESTful API)
– Layered Architecture:
- Presentation (React UI)
- Application (Express routing + middleware)
- Data (MongoDB via Mongoose)
– Separation of Concerns: models vs. routes vs. middleware vs. utils
– Secure authentication (JWT tokens + protected routes)
d. Key Technologies & Frameworks
– React.js + React Router + Axios
– Express.js + Node.js
– MongoDB + Mongoose
– JSON Web Tokens (JWT)
– bcryptjs (password hashing)
– Nodemailer (email OTP)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Layer"
        direction TB
        App["App.js"]:::frontend
        Index["index.js"]:::frontend
        PrivateRoute["PrivateRoute.js"]:::frontend
        useAuth["useAuth.js (Auth Hook)"]:::frontend
        subgraph Pages
            direction TB
            Home["HomePage.js"]:::frontend
            Dashboard["DashboardPage.js"]:::frontend
            Auth["AuthPage.js"]:::frontend
            Register["RegisterPage.js"]:::frontend
            Detail["TournamentDetailPage.js"]:::frontend
            Live["LiveWatchPage.js"]:::frontend
            Game["GamePage.js"]:::frontend
        end
        subgraph Components
            direction TB
            Header["Header.js"]:::frontend
            Footer["Footer.js"]:::frontend
            Card["TournamentCard.js"]:::frontend
            Score["LiveScorecardBGMI.js"]:::frontend
        end
        Dummy["dummyData.js"]:::frontend
        App -->|uses| Index
        App -->|routes via React Router| PrivateRoute
        App -->|manages auth| useAuth
        App -->|renders| Pages
        App -->|renders| Components
        Dummy -->|provides mock data| Components
    end

    subgraph "Backend Layer"
        direction TB
        API["index.js\n(Express API)"]:::backend
        AuthMW["auth.js\n(JWT Middleware)"]:::backend
        subgraph Routes
            direction TB
            RAuth["auth.js"]:::backend
            RPlayers["players.js"]:::backend
            RTournaments["tournaments.js"]:::backend
            RUsers["users.js"]:::backend
        end
        subgraph Models
            direction TB
            MUser["User.js"]:::backend
            MPlayer["Player.js"]:::backend
            MTournament["Tournament.js"]:::backend
        end
        Util["sendEmail.js"]:::backend
        API -->|uses middleware| AuthMW
        AuthMW -->|protects| RPlayers
        AuthMW -->|protects| RTournaments
        AuthMW -->|protects| RUsers
        API -->|routes| RAuth
        API -->|routes| RPlayers
        API -->|routes| RTournaments
        API -->|routes| RUsers
        RAuth -->|CRUD via Mongoose| MUser
        RPlayers -->|CRUD via Mongoose| MPlayer
        RTournaments -->|CRUD via Mongoose| MTournament
        RUsers -->|CRUD via Mongoose| MUser
        RAuth -->|sends OTP email| Util
    end

    DB[(MongoDB Atlas)]:::database
    Email[(Gmail SMTP)]:::external

    App -->|HTTP requests via Axios| API
    API -->|queries| DB
    Util -->|sends email via SMTP| Email

    classDef frontend fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20;
    classDef database fill:#eeeeee,stroke:#616161,color:#424242,stroke-dasharray:5 5;
    classDef external fill:#ffe0b2,stroke:#e65100,color:#e65100;

    click App "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/App.js"
    click Index "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/index.js"
    click PrivateRoute "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/PrivateRoute.js"
    click useAuth "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/hooks/useAuth.js"
    click Home "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/HomePage.js"
    click Dashboard "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/DashboardPage.js"
    click Auth "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/AuthPage.js"
    click Register "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/RegisterPage.js"
    click Detail "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/TournamentDetailPage.js"
    click Live "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/LiveWatchPage.js"
    click Game "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/pages/GamePage.js"
    click Header "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/components/Header.js"
    click Footer "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/components/Footer.js"
    click Card "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/components/TournamentCard.js"
    click Score "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/components/LiveScorecardBGMI.js"
    click Dummy "https://github.com/distortion-12/esports-arena/blob/master/frontend/src/data/dummyData.js"
    click API "https://github.com/distortion-12/esports-arena/blob/master/backend/index.js"
    click AuthMW "https://github.com/distortion-12/esports-arena/blob/master/backend/middleware/auth.js"
    click RAuth "https://github.com/distortion-12/esports-arena/blob/master/backend/routes/auth.js"
    click RPlayers "https://github.com/distortion-12/esports-arena/blob/master/backend/routes/players.js"
    click RTournaments "https://github.com/distortion-12/esports-arena/blob/master/backend/routes/tournaments.js"
    click RUsers "https://github.com/distortion-12/esports-arena/blob/master/backend/routes/users.js"
    click MUser "https://github.com/distortion-12/esports-arena/blob/master/backend/models/User.js"
    click MPlayer "https://github.com/distortion-12/esports-arena/blob/master/backend/models/Player.js"
    click MTournament "https://github.com/distortion-12/esports-arena/blob/master/backend/models/Tournament.js"
    click Util "https://github.com/distortion-12/esports-arena/blob/master/backend/utils/sendEmail.js"
```
