# sagar-tandan/gym_management_system architecture

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

- Interactive diagram: https://gitdiagram.com/sagar-tandan/gym_management_system
- Repository: https://github.com/sagar-tandan/gym_management_system

## Overview

##### Main Components
- Frontend Client:
- React-based single-page application (SPA)
- Sub-components for Admin (e.g., AdminDashboard, AdminAttendence, Inventory) and User (e.g., NavBar, HeroSection, TrainingPrograms)
- Built with Vite, using the “src” directory for components, assets, and routing.
- Backend API:
- ASP.NET Core Web API project
- Controllers manage routes like Attendence, Auth, Inventory, Member, and Plan.
- Entity Framework Core for data persistence (as shown by ApplicationDbContext and numerous Migration files).
- Database:
- Although the actual database isn’t explicitly listed, the use of EF Core and migrations implies a relational database (like SQL Server, PostgreSQL, etc.).
- External Dependencies/Services:
- Email sending is handled by a service (IEmailSender interface and EmailSender implementation).
- The token service suggests JWT-based authentication or similar mechanisms.

##### Relationships and Interactions
- The Frontend communicates with the Backend API via RESTful HTTP requests (as suggested by the presence of “API.http” and multiple controllers handling endpoints).
- The API routes incoming requests to the appropriate controllers, which then use DTOs for data validation and Models represent the underlying database tables.
- The API, through the ApplicationDbContext, interacts with the Database to perform CRUD operations.
- Auxiliary services such as EmailSender and TokenService support additional functionality like user verification and secure authentication.
- Authentication flows: There is an AuthController and corresponding DTOs for login, registration, and password changes, suggesting a flow where user credentials are verified, a token (JWT likely) is returned and then used by the frontend for subsequent API calls.
- The separation between admin routes and user routes in the frontend indicates role-based access control.

##### Diagramming Architectural Patterns
- Use of Dependency Injection in the API: Although not explicitly visible in the file tree, the structure implies that services (like EmailSender and TokenService) are likely injected into the controllers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (React SPA)"
        FEU["User Components"]:::frontend
        FEA["Admin Components"]:::frontend
    end

    subgraph "Backend API (ASP.NET Core)"
        CTR["Controllers"]:::backend
        DTOS["DTOs"]:::backend
        MODELS["Models"]:::backend
        TOKEN["Token Service"]:::backend
        EMAIL["Email Service"]:::backend
        DATA["Data Access (ApplicationDbContext)"]:::backend
    end

    DB["Database (Relational)"]:::database

    FEU -->|"HTTP/REST"| CTR
    FEA -->|"HTTP/REST"| CTR
    CTR -->|"uses"| DTOS
    CTR -->|"uses"| MODELS
    CTR -->|"calls"| TOKEN
    CTR -->|"calls"| EMAIL
    CTR -->|"accesses"| DATA
    DATA -->|"CRUD"| DB

    click FEU "https://github.com/sagar-tandan/gym_management_system/tree/main/Frontend/src/User/UserComponents"
    click FEA "https://github.com/sagar-tandan/gym_management_system/tree/main/Frontend/src/Admin/AdminComp"
    click CTR "https://github.com/sagar-tandan/gym_management_system/tree/main/API/Controllers"
    click DTOS "https://github.com/sagar-tandan/gym_management_system/tree/main/API/DTOs"
    click DATA "https://github.com/sagar-tandan/gym_management_system/blob/main/API/Data/ApplicationDbContext.cs"
    click MODELS "https://github.com/sagar-tandan/gym_management_system/tree/main/API/Models"
    click EMAIL "https://github.com/sagar-tandan/gym_management_system/blob/main/API/Service/EmailSender.cs"
    click TOKEN "https://github.com/sagar-tandan/gym_management_system/blob/main/API/Services/TokenService.cs"

    classDef frontend fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef database fill:#FFCCBC,stroke:#BF360C,stroke-width:2px;
```
