# tharunkunamalla/tms architecture

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

- Interactive diagram: https://gitdiagram.com/tharunkunamalla/tms
- Repository: https://github.com/tharunkunamalla/tms

## Overview

##### Project Type & Purpose
- That this is a web-based application built primarily with PHP and HTML/CSS/JavaScript, designed to manage and organize sporting tournaments, players, matches, and events.
- From the README that the system handles multiple sports, provides real-time score updates, and supports large-scale tournaments (e.g., Olympics 2024, Wimbledon 2024).

##### Analyzing the File Structure
- There are core PHP scripts for backend operations (e.g., Add-match.php, Add-match-details.php, Add-players.php, Add-sports.php, Add-tournaments.php, db_connect.php) indicating server-side logic for data manipulation.
- The HTML files (e.g., index1.html, index2.html, contact-us.html, help.html, login.html) along with a rich assets folder (containing stylesheets, JavaScript, images) form the frontend.
- There are specialized PHP files (olympics_2024.php, olympics_2024_user.php, players_admin.php, players_user.php) which suggest role-based views or pages for different user types.
- The file tree does not separate the project into directories like “backend” and “frontend”, so infer a more monolithic file organization, but the separation is still conceptually present.

a. Frontend:
- HTML pages (index, about, contact, login, etc.) and assets (CSS, JS, images).
- These represent the user interface through which users interact with the system.
b. Backend:
- PHP scripts handling core functionalities – adding match details, editing players, and tournament management.
- The authentication/login pages (login.html) and user/admin differentiated pages indicate business logic separating user roles.
c. Database Layer:
- The db_connect.php file shows the connection interface to a database where tournament, player, match, and sport information is stored.
d. External Services/Integration Points:

##### Relationships & Interactions
- The backend interacts with the database (via db_connect.php) to fetch or update data.
- Responses then travel back to the client’s browser and are rendered through the respective HTML/CSS/JS assets.
- Role-specific pages (e.g., players_admin.php versus players_user.php) should be shown as specialized paths originating from the same backend.

##### Architectural Patterns & Design Principles
- View: HTML/CSS/JS files (in assets and various HTML pages).
- Controller/Business Logic: PHP files (for adding, editing, or displaying data).
- Model: Database connections and the underlying data managed via db_connect.php.
- That modularity is maintained by having separate scripts to handle specific functionalities (matches, players, sports, tournaments).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level External Node
    U["User Browser"]:::external

    %% High-level Aggregator Nodes
    FE["Frontend UI"]:::frontend
    BE["PHP Backend Operations"]:::backend
    DB["Database Layer"]:::database

    %% High-level Connections
    U -->|"HTTP"| FE
    FE -->|"HTTP"| BE
    BE -->|"DB Query"| DB
    DB -->|"DB Response"| BE
    BE -->|"Response"| FE
    FE -->|"Render"| U

    %% Frontend UI Subgraph
    subgraph "Frontend UI Details"
        direction TB
        subgraph "HTML Pages"
            f1["index1.html"]:::frontend
            f2["index2.html"]:::frontend
            f3["contact-us.html"]:::frontend
            f4["help.html"]:::frontend
            f5["login.html"]:::frontend
            f6["About.html"]:::frontend
            f7["edit.html"]:::frontend
            f8["sponsors.html"]:::frontend
        end
        fAssets["Assets"]:::frontend
    end

    %% PHP Backend Operations Subgraph
    subgraph "PHP Backend Operations Details"
        direction TB
        subgraph "Match Management"
            b1["Add-match.php"]:::backend
            b2["Add-match-details.php"]:::backend
        end
        subgraph "Player Management"
            b3["Add-players.php"]:::backend
            b4["fetch_players.php"]:::backend
        end
        subgraph "Sports Management"
            b5["Add-sports.php"]:::backend
        end
        subgraph "Tournament Management"
            b6["Add-tournaments.php"]:::backend
        end
        subgraph "Role-based Pages/Specialized Views"
            subgraph "Olympics Tournament Pages"
                b7["olympics_2024.php"]:::backend
                b8["olympics_2024_user.php"]:::backend
            end
            subgraph "Players View Pages"
                b9["players_admin.php"]:::backend
                b10["players_user.php"]:::backend
            end
        end
    end

    %% Database Layer Node
    d1["Database Connection (db_connect.php)"]:::database

    %% Detailed Flow Connections (sample representative interactions)
    %% From Frontend HTML to Backend operations
    f1 -->|"submit_request"| b1
    f1 -->|"submit_request"| b3
    fAssets ---|"supports UI"| f1

    %% From Backend to Database
    b1 -->|"query"| d1
    b3 -->|"query"| d1

    %% From Database back to Backend then to Frontend
    d1 -->|"result"| b1
    d1 -->|"result"| b3
    b7 -->|"response"| f2
    b9 -->|"response"| f4

    %% Click Events for Frontend UI Files
    click f1 "https://github.com/tharunkunamalla/tms/blob/main/index1.html"
    click f2 "https://github.com/tharunkunamalla/tms/blob/main/index2.html"
    click f3 "https://github.com/tharunkunamalla/tms/blob/main/contact-us.html"
    click f4 "https://github.com/tharunkunamalla/tms/blob/main/help.html"
    click f5 "https://github.com/tharunkunamalla/tms/blob/main/login.html"
    click f6 "https://github.com/tharunkunamalla/tms/blob/main/About.html"
    click f7 "https://github.com/tharunkunamalla/tms/blob/main/edit.html"
    click f8 "https://github.com/tharunkunamalla/tms/blob/main/sponsors.html"
    click fAssets "https://github.com/tharunkunamalla/tms/tree/main/assets/"

    %% Click Events for PHP Backend Operations Files
    click b1 "https://github.com/tharunkunamalla/tms/blob/main/Add-match.php"
    click b2 "https://github.com/tharunkunamalla/tms/blob/main/Add-match-details.php"
    click b3 "https://github.com/tharunkunamalla/tms/blob/main/Add-players.php"
    click b4 "https://github.com/tharunkunamalla/tms/blob/main/fetch_players.php"
    click b5 "https://github.com/tharunkunamalla/tms/blob/main/Add-sports.php"
    click b6 "https://github.com/tharunkunamalla/tms/blob/main/Add-tournaments.php"
    click b7 "https://github.com/tharunkunamalla/tms/blob/main/olympics_2024.php"
    click b8 "https://github.com/tharunkunamalla/tms/blob/main/olympics_2024_user.php"
    click b9 "https://github.com/tharunkunamalla/tms/blob/main/players_admin.php"
    click b10 "https://github.com/tharunkunamalla/tms/blob/main/players_user.php"

    %% Click Event for Database Connection File
    click d1 "https://github.com/tharunkunamalla/tms/blob/main/db_connect.php"

    %% Styling Definitions
    classDef external fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px,color:#E65100;
    classDef frontend fill:#BBDEFB,stroke:#1E88E5,stroke-width:2px,color:#0D47A1;
    classDef backend fill:#C8E6C9,stroke:#43A047,stroke-width:2px,color:#1B5E20;
    classDef database fill:#FFF9C4,stroke:#FDD835,stroke-width:2px,color:#F57F17;
```
