# bilal-pasha/student-sport-registration-app architecture

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

- Interactive diagram: https://gitdiagram.com/bilal-pasha/student-sport-registration-app
- Repository: https://github.com/bilal-pasha/student-sport-registration-app

## Overview

##### Main Components
- Frontend Client – built with React/Next.js and styled with Tailwind CSS. This includes pages under src/app (with public and protected sections), reusable components (under src/components), and utility hooks and helpers.
- Backend API Routes – located under src/app/api. These endpoints handle functionalities such as madrasas registration, student management (add, update, delete), authentication (NextAuth routes, signup routes), and additional endpoints for filtering data and updating statuses.
- Database – MongoDB is used to store data like user details, madrasas registration, student records, and roles.
- Authentication Service – NextAuth integration to support Google, GitHub, and custom credentials with secure password hashing using bcryptjs.
- External Integrations – Vercel for hosting and deployment, along with third-party authentication providers (Google, GitHub).

##### Relationships and Data Flow
- The Frontend Client communicates with the API Routes through HTTP requests (i.e., RESTful endpoints).
- API Routes act as the intermediary between the frontend and the database by handling business logic, data retrieval, and security (authentication and authorization).
- NextAuth across API endpoints manages session handling and role-based access control, splitting the application into public and protected routes.
- Components render UI elements that trigger API calls for CRUD operations on madrasas, students, and authentication events.
- External Services (like Vercel’s CI/CD and deployment pipelines) facilitate a smooth deployment process, while authentication providers integrate for sign-in functionalities.

##### Architectural Patterns and Important Details
- Full-Stack Separation: The design clearly separates the client (pages and UI components) from the backend API logic.
- Role-based Access Control: Different UI sections and API endpoints exist for public versus protected content, indicating segregation based on user roles (e.g., normal users vs. admins).
- Modular Design: The project emphasizes modularity by organizing code into directories for components, API routes, hooks, utilities, and context.
- Use of Next.js App Router: Highlights server-side rendering, static asset management, and file-based routing.
- Data Flow and Services: Include endpoints for operations like “add”, “update”, “delete” on student and madrasas data.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User Browser"):::external

    subgraph "Frontend Client"
        FE_Public("Public Pages (login/signup/forgot-password)"):::frontend
        FE_Protected("Protected Pages (class/registration/filter/work)"):::frontend
        FE_Components("UI Components"):::frontend
    end

    subgraph "Backend API"
        API_Gateway("API Gateway (src/app/api)"):::backend
    end

    subgraph "Database"
        DB_Connection("MongoDB Connection"):::database
        DB_Models("Data Models"):::database
    end

    subgraph "Authentication Service"
        Auth_API("Auth API (src/app/api/auth)"):::auth
        NextAuth("NextAuth Route (src/app/api/auth/[...nextauth]/route.ts)"):::auth
        Auth_Config("Auth Config (src/lib/authOptions.ts)"):::auth
        External_Providers("External Providers (Google/GitHub)"):::auth
    end

    Vercel("Deployment Service (Vercel)"):::external

    User -->|"HTTP_req"| FE_Public
    FE_Public -->|"HTTP_req"| API_Gateway
    FE_Protected -->|"HTTP_req"| API_Gateway
    FE_Components -->|"UI_action"| API_Gateway

    API_Gateway -->|"CRUD_ops"| DB_Connection
    API_Gateway -->|"CRUD_ops"| DB_Models
    API_Gateway -->|"Auth_flow"| Auth_API

    Auth_API -->|"Session_handling"| NextAuth
    Auth_API -->|"Config_access"| Auth_Config
    NextAuth -->|"OAuth_integ"| External_Providers

    Vercel -->|"Deploy"| FE_Public
    Vercel -->|"Deploy"| API_Gateway

    click FE_Public "https://github.com/bilal-pasha/student-sport-registration-app/tree/main/src/app/(public)"
    click FE_Protected "https://github.com/bilal-pasha/student-sport-registration-app/tree/main/src/app/(protected)"
    click FE_Components "https://github.com/bilal-pasha/student-sport-registration-app/tree/main/src/components"
    click API_Gateway "https://github.com/bilal-pasha/student-sport-registration-app/tree/main/src/app/api"
    click DB_Connection "https://github.com/bilal-pasha/student-sport-registration-app/blob/main/src/lib/mongodb.ts"
    click DB_Models "https://github.com/bilal-pasha/student-sport-registration-app/tree/main/src/models"
    click Auth_API "https://github.com/bilal-pasha/student-sport-registration-app/tree/main/src/app/api/auth"
    click NextAuth "https://github.com/bilal-pasha/student-sport-registration-app/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click Auth_Config "https://github.com/bilal-pasha/student-sport-registration-app/blob/main/src/lib/authOptions.ts"
    click Vercel "https://github.com/bilal-pasha/student-sport-registration-app/blob/main/next.config.mjs"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef auth fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA500,stroke:#000,stroke-width:2px;
```
