# iamqasimali/badminton architecture

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

- Interactive diagram: https://gitdiagram.com/iamqasimali/badminton
- Repository: https://github.com/iamqasimali/badminton

## Overview

##### Project type and purpose
- This is a MERN-style web application for organizing and managing badminton tournaments.
- It offers three portals (Player, Tournament Management, Admin), with this repository containing the React front-end.
- The front-end is built with Vite + React + Tailwind, consuming an Express.js API and PostgreSQL database.

##### File structure
- Root files:
– index.html: single-page application host
– vite.config.js, tailwind.config.js, postcss.config.js: build and styling configurations
– package.json / package-lock.json: project dependencies
- public/: static assets served alongside index.html
- src/: entrypoints and React code
– main.jsx → mounts App.jsx
– App.jsx → configures React Router and global layout
– src/components/auth/: authentication flows (Signup, Signin, Welcome, etc.)
– assets/: images and static media
– CSS files (App.css, index.css) leveraging Tailwind utilities

##### Pulling architecture insights from the README
- Back-end (not in this repo) follows MVC:
– Models: Sequelize schemas mapping to PostgreSQL
– Controllers: Express route handlers
– Views: JSON payloads
- Authentication via JWT + Bcrypt, input validation with Joi, RESTful API endpoints accessed by Axios in the client
- Tech stack callouts: React Router, Formik, Yup/Joi, Axios, Express.js, PostgreSQL, Sequelize

a. Main components to include
– Client (Browser) with React SPA
– Static asset host (Vite dev server or production CDN / web server)
– API Server (Express.js)
– Authentication service (JWT issuance & verification, Bcrypt hashing, Joi validation)
– Database (PostgreSQL via Sequelize)
– External services (e.g., CORS, UUID library if depicted as part of back-end utilities)
b. Relationships & data flows
1. User → Browser UI (React + React Router)
2. UI → HTTP calls (Axios) → Express API endpoints
3. Express Controller → validate (Joi) → hash/verify (Bcrypt) → issue/check token (JWT)
4. Controller → ORM (Sequelize) → PostgreSQL
5. Database responses → Controller → JSON response → UI updates
c. Architectural patterns & principles
– Front-end: component-based, single-page application
– Back-end: layered MVC, RESTful services
– Separation of concerns: UI, API, Data layer
– Stateless authentication via JWT
d. Key technologies & frameworks
– React, Vite, Tailwind, React Router, Formik, Yup/Joi, Axios
– Node.js, Express.js, Sequelize, pg, PostgreSQL, JWT, Bcryptjs, CORS

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Front-end Layer
    subgraph "Front-end" 
        direction TB
        subgraph "Static Assets" 
            direction TB
            Public["public/"]:::document
            Images["src/assets/images/"]:::document
            click Public "https://github.com/iamqasimali/badminton/tree/main/public/"
            click Images "https://github.com/iamqasimali/badminton/tree/main/src/assets/images/"
        end
        subgraph "React SPA" 
            direction TB
            IndexHTML["index.html"]:::document
            MainJS["src/main.jsx"]:::frontend
            AppJS["src/App.jsx"]:::frontend
            click IndexHTML "https://github.com/iamqasimali/badminton/blob/main/index.html"
            click MainJS "https://github.com/iamqasimali/badminton/blob/main/src/main.jsx"
            click AppJS "https://github.com/iamqasimali/badminton/blob/main/src/App.jsx"
        end
        subgraph "Routing & Global Layout"
            AppJS2["App.jsx"]:::frontend
        end
        click AppJS2 "https://github.com/iamqasimali/badminton/blob/main/src/App.jsx"
        subgraph "Authentication Flows"
            direction TB
            AuthIndex["Index.jsx"]:::frontend
            Signup["Signup.jsx"]:::frontend
            Signin["Signin.jsx"]:::frontend
            Welcome["Welcome.jsx"]:::frontend
            SelectRole["SelectRole.jsx"]:::frontend
            PlayerInfo["PlayerInfo.jsx"]:::frontend
            AccountCreated["AccountCreated.jsx"]:::frontend
            Congrats["Congrats.jsx"]:::frontend
            click AuthIndex "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/Index.jsx"
            click Signup "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/Signup.jsx"
            click Signin "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/Signin.jsx"
            click Welcome "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/Welcome.jsx"
            click SelectRole "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/SelectRole.jsx"
            click PlayerInfo "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/PlayerInfo.jsx"
            click AccountCreated "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/AccountCreated.jsx"
            click Congrats "https://github.com/iamqasimali/badminton/blob/main/src/components/auth/Congrats.jsx"
        end
        subgraph "Global Styles & Tailwind"
            direction TB
            IndexCSS["src/index.css"]:::css
            AppCSS["src/App.css"]:::css
            TailwindConfig["tailwind.config.js"]:::config
            PostCSS["postcss.config.js"]:::config
            click IndexCSS "https://github.com/iamqasimali/badminton/blob/main/src/index.css"
            click AppCSS "https://github.com/iamqasimali/badminton/blob/main/src/App.css"
            click TailwindConfig "https://github.com/iamqasimali/badminton/blob/main/tailwind.config.js"
            click PostCSS "https://github.com/iamqasimali/badminton/blob/main/postcss.config.js"
        end
        subgraph "Build & Dev Server"
            ViteConfig["vite.config.js"]:::config
            click ViteConfig "https://github.com/iamqasimali/badminton/blob/main/vite.config.js"
        end
        subgraph "Package Management"
            PackageJSON["package.json"]:::config
            PackageLock["package-lock.json"]:::config
            click PackageJSON "https://github.com/iamqasimali/badminton/blob/main/package.json"
            click PackageLock "https://github.com/iamqasimali/badminton/blob/main/package-lock.json"
        end
    end

    %% Back-end Layer
    subgraph "Back-end" 
        direction TB
        API["Express API"]:::backend
        subgraph "API Endpoints"
            direction TB
            AuthEndpoint["/auth"]:::backend
            PlayersEndpoint["/players"]:::backend
            TournamentsEndpoint["/tournaments"]:::backend
            AdminEndpoint["/admin"]:::backend
        end
        AuthService["Authentication Service"]:::auth
        ORM["Sequelize ORM"]:::backend
        DB["PostgreSQL"]:::db
    end

    %% Data Flows
    User["User (Browser)"]:::frontend -->|"loads"| IndexHTML
    IndexHTML -->|renders| MainJS
    MainJS -->|mounts| AppJS
    AppJS -->|configures routes| AuthIndex
    AppJS -->|routes to| Signup
    AppJS -->|routes to| Signin
    Signup -->|submits via Axios| AuthEndpoint
    Signin -->|submits via Axios| AuthEndpoint
    AuthEndpoint -->|"validate (Joi)"| AuthService
    AuthService -->|"hash/verify (Bcrypt)"| AuthService
    AuthService -->|"issue/check token (JWT)"| AuthService
    AuthEndpoint -->|calls| ORM
    ORM -->|"SQL queries"| DB
    PlayersEndpoint -->|calls| ORM
    TournamentsEndpoint -->|calls| ORM
    AdminEndpoint -->|calls| ORM
    AuthService -->|verifies token| API
    API -->|responds JSON| MainJS

    %% API Endpoint connections
    API --> AuthEndpoint
    API --> PlayersEndpoint
    API --> TournamentsEndpoint
    API --> AdminEndpoint

    %% Styles and configs used by SPA
    MainJS --> IndexCSS
    MainJS --> AppCSS
    MainJS --> TailwindConfig
    MainJS --> PostCSS

    %% Assets usage
    AppJS --> Public
    AppJS --> Images

    classDef frontend fill:#cce5ff,stroke:#005cbf,color:#005cbf
    classDef document fill:#fff3cd,stroke:#856404,color:#856404
    classDef config fill:#d4edda,stroke:#155724,color:#155724
    classDef css fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef backend fill:#d1ecf1,stroke:#0c5460,color:#0c5460
    classDef auth fill:#e2d5f3,stroke:#6f42c1,color:#6f42c1
    classDef db fill:#fff0f6,stroke:#bd2130,color:#bd2130
```
