# mdazfar2/dbgmi-playzone architecture

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

- Interactive diagram: https://gitdiagram.com/mdazfar2/dbgmi-playzone
- Repository: https://github.com/mdazfar2/dbgmi-playzone

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack competitive gaming platform (“DBGMI-Playzone”) with a React/Tailwind front end, an Express/Node.js back end, MongoDB persistence, and Stripe for payment integration. Its purpose is to let users browse and register for tournaments and let admins manage tournaments and registrations.

##### File structure
- Top level only contains documentation files and a single “frontend” directory.
- frontend/ contains a modern React app set up with Vite (viteconfig.js), Tailwind CSS (tailwind.config.js, postcss.config.js), ESLint, and a src/ directory.
- Inside src/, pages/ map one-to-one to site routes (HomePage, RegistrationPage, AdminPage, etc.), components/ holds reusable UI widgets grouped by feature (auth, admin, common, home, leaderboard, registration, rules, tournaments, contact), data/, utils/, types/.
- No server code in this tree, but the README explicitly calls out Express.js/Node.js backend and MongoDB.

##### README for additional insights
- Tech stack: React, Tailwind CSS, Express.js, Node.js, MongoDB, Stripe.
- Core features: tournament listings, registration with payment, prize details, admin panel.
- There’s a RESTful relationship implied: front end → Express APIs → MongoDB, plus integration to Stripe gateway.

##### Components & relationships
a. Main components
- Client (React SPA)
- Web/API Server (Node.js + Express)
- Database (MongoDB)
- External Payment Service (Stripe)
- Static asset/store (optionally: CDN or Vite dev server)

b. Interactions & data flow
1. User’s browser loads the React app (served either via CDN/static host or Express static middleware).
2. React app calls Express REST endpoints over HTTPS for:
– GET /tournaments, GET /players, GET /winners
– POST /register, POST /login, POST /admin/tournament
3. Express routes apply business logic, interact with MongoDB (via Mongoose or similar), and return JSON.
4. For payment, front end opens Stripe Checkout or invokes a backend endpoint which calls Stripe’s API, then updates MongoDB.
5. Admin workflows (protected routes) follow the same pattern but require authentication/authorization.

c. Architectural patterns & design principles
- Client-Server separation (SPA + REST API)
- Layered architecture: Presentation (React), Application (Express controllers/services), Persistence (MongoDB)
- Modular feature organization in front end (component-per-feature)
- Authentication & Authorization middleware in Express
- External service integration (Stripe SDK on server)

d. Key technologies per component
- Frontend: React, Vite, Tailwind CSS, React Router (implied by pages folder)
- Backend: Node.js, Express.js, Body-Parser, CORS, dotenv (for config), Mongoose (MongoDB ODM)
- Database: MongoDB Atlas or self-hosted cluster
- Payments: Stripe Node.js SDK and Stripe Checkout / Payment Intents
- DevOps (implied by .github/workflows): GitHub Actions for CI/CD

##### Detail but maintain clarity
- Data schemas or collections if needed (e.g., Players, Tournaments, Registrations).
- Call out environment/config boundaries (e.g., .env holds Stripe secret key, DB URI).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser
    Browser["User Browser"]:::ui

    %% Frontend Layer
    subgraph "Frontend: React SPA (Vite + TailwindCSS)"
        direction TB
        FE_Main["Index.html / App Bundle"]:::ui
        subgraph "Pages"
            direction TB
            HomePage["HomePage.jsx"]:::ui
            TournamentsPage["TournamentsPage.jsx"]:::ui
            TournamentDetailsPage["TournamentDetailsPage.jsx"]:::ui
            RegistrationPage["RegistrationPage.jsx"]:::ui
            RegistrationSuccessPage["RegistrationSuccessPage.jsx"]:::ui
            LeaderboardPage["LeaderboardPage.jsx"]:::ui
            RulesPage["RulesPage.jsx"]:::ui
            ContactPage["ContactPage.jsx"]:::ui
            AdminPage["AdminPage.jsx"]:::ui
        end
        subgraph "Reusable Components"
            direction TB
            AuthModal["AuthModal.jsx"]:::ui
            AdminDashboardWidget["AdminDashboard.jsx"]:::ui
            Button["Button.jsx"]:::ui
            Card["Card.jsx"]:::ui
            Navbar["Navbar.jsx"]:::ui
            Footer["Footer.jsx"]:::ui
            LoadingScreen["LoadingScreen.jsx"]:::ui
        end
        subgraph "Home Feature"
            direction TB
            HeroSection["HeroSection.jsx"]:::ui
            HowItWorks["HowItWorks.jsx"]:::ui
            PastWinners["PastWinners.jsx"]:::ui
            UpcomingTournaments["UpcomingTournaments.jsx"]:::ui
            Countdown["Countdown.jsx"]:::ui
            TournamentCard["TournamentCard.jsx"]:::ui
        end
        subgraph "Tournaments Feature"
            direction TB
            TournamentsList["TournamentsList.jsx"]:::ui
            TournamentDetailsWidget["TournamentDetails.jsx"]:::ui
        end
        subgraph "Registration Feature"
            direction TB
            RegistrationForm["RegistrationForm.jsx"]:::ui
            PaymentSimulator["PaymentSimulator.jsx"]:::ui
            RegistrationSuccessUI["RegistrationSuccess.jsx"]:::ui
        end
        subgraph "Leaderboard Feature"
            direction TB
            LeaderboardTable["LeaderboardTable.jsx"]:::ui
        end
        subgraph "Rules Feature"
            direction TB
            TournamentRules["TournamentRules.jsx"]:::ui
        end
        subgraph "Contact Feature"
            direction TB
            ContactForm["ContactForm.jsx"]:::ui
        end
        subgraph "Data & Utils"
            direction TB
            PlayersData["players.js"]:::ui
            TournamentsData["tournaments.js"]:::ui
            WinnersData["winners.js"]:::ui
            Helpers["helpers.js"]:::ui
            Types["index.js"]:::ui
            GlobalStyles["index.css"]:::ui
            Main["main.jsx"]:::ui
            App["App.jsx"]:::ui
        end
    end

    %% Backend Layer
    subgraph "Backend: Node.js + Express"    
        direction TB
        AuthMiddleware["Authentication Middleware"]:::server
        TournamentCtrl["Tournament Controller"]:::server
        RegistrationCtrl["Registration Controller"]:::server
        AdminCtrl["Admin Controller"]:::server
        PaymentService["Payment Service Adapter"]:::server
    end

    %% Database and External
    MongoDB["MongoDB (Atlas)"]:::db
    Stripe["Stripe API"]:::external

    %% Connections
    Browser -->|Loads index.html| FE_Main
    FE_Main -->|Hydrates SPA| App
    App -->|Renders Pages| HomePage
    App -->|Renders Pages| TournamentsPage
    App -->|Renders Pages| TournamentDetailsPage
    App -->|Renders Pages| RegistrationPage
    App -->|Renders Pages| RegistrationSuccessPage
    App -->|Renders Pages| LeaderboardPage
    App -->|Renders Pages| RulesPage
    App -->|Renders Pages| ContactPage
    App -->|Renders Pages| AdminPage

    App -->|GET /tournaments| TournamentCtrl
    App -->|GET /players| TournamentCtrl
    App -->|GET /winners| TournamentCtrl
    App -->|POST /register| RegistrationCtrl
    App -->|POST /login| AuthMiddleware
    App -->|POST /admin/tournament| AdminCtrl
    RegistrationCtrl -->|create record| MongoDB
    TournamentCtrl -->|read/write| MongoDB
    AdminCtrl -->|manage| MongoDB
    PaymentService -->|PaymentIntent| Stripe
    PaymentService -->|update registration| MongoDB
    AuthMiddleware -->|validate| MongoDB

    %% Click Events
    click Frontend "https://github.com/mdazfar2/dbgmi-playzone/tree/main/frontend/"
    click HomePage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/HomePage.jsx"
    click TournamentsPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/TournamentsPage.jsx"
    click TournamentDetailsPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/TournamentDetailsPage.jsx"
    click RegistrationPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/RegistrationPage.jsx"
    click RegistrationSuccessPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/RegistrationSuccessPage.jsx"
    click LeaderboardPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/LeaderboardPage.jsx"
    click RulesPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/RulesPage.jsx"
    click ContactPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/ContactPage.jsx"
    click AdminPage "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/pages/AdminPage.jsx"
    click AuthModal "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/auth/AuthModal.jsx"
    click AdminDashboardWidget "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/admin/AdminDashboard.jsx"
    click Button "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/common/Button.jsx"
    click Card "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/common/Card.jsx"
    click Navbar "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/common/Navbar.jsx"
    click Footer "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/common/Footer.jsx"
    click LoadingScreen "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/common/LoadingScreen.jsx"
    click HeroSection "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/home/HeroSection.jsx"
    click HowItWorks "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/home/HowItWorks.jsx"
    click PastWinners "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/home/PastWinners.jsx"
    click UpcomingTournaments "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/home/UpcomingTournaments.jsx"
    click Countdown "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/home/Countdown.jsx"
    click TournamentCard "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/home/TournamentCard.jsx"
    click TournamentsList "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/tournaments/TournamentsList.jsx"
    click TournamentDetailsWidget "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/tournaments/TournamentDetails.jsx"
    click RegistrationForm "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/registration/RegistrationForm.jsx"
    click PaymentSimulator "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/registration/PaymentSimulator.jsx"
    click RegistrationSuccessUI "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/registration/RegistrationSuccess.jsx"
    click LeaderboardTable "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/leaderboard/LeaderboardTable.jsx"
    click TournamentRules "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/rules/TournamentRules.jsx"
    click ContactForm "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/components/contact/ContactForm.jsx"
    click PlayersData "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/data/players.js"
    click TournamentsData "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/data/tournaments.js"
    click WinnersData "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/data/winners.js"
    click Helpers "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/utils/helpers.js"
    click Types "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/types/index.js"
    click GlobalStyles "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/index.css"
    click Main "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/main.jsx"
    click App "https://github.com/mdazfar2/dbgmi-playzone/blob/main/frontend/src/App.jsx"

    %% Styles
    classDef ui fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef server fill:#E8F5E9,stroke:#66BB6A,stroke-width:1px
    classDef db fill:#FFF3E0,stroke:#FFB74D,stroke-width:1px
    classDef external fill:#F3E5F5,stroke:#AB47BC,stroke-width:1px
```
