# rks-031/pragati architecture

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

- Interactive diagram: https://gitdiagram.com/rks-031/pragati
- Repository: https://github.com/rks-031/pragati

## Overview

##### Main Components
- Frontend:
- Built with Vite and ReactJS, it is responsible for rendering the UI, managing user flows (login, registration, assessment, exam upload, etc.), and handling offline capabilities.
- Key files/folders include: frontend/src (with components, context, pages, and styles) and configuration files like vite.config.js.
- Backend:
- Developed in Python using FastAPI, responsible for handling business logic, authentication, data management, and serving RESTful endpoints.
- Look at the backend folder structure, including directories for config, routes (assessment, auth, course routes), services (db_services, gcs_service, scheduler_services, sms_service), and utilities.
- Database & Data Models:
- Within the backend/db folder, models.py implies ORM or database schema definitions.
- External/Cloud Services:
- As described in the README, several Google Cloud services are used (Cloud Storage, Firestore, Firebase, text-to-speech, speech-to-text, IoT Core, Google Maps API, Cloud Run) along with the Twilio API.
- Offline & Mesh Networking Capabilities:
- The platform’s offline-first design and peer-to-peer sharing indicate that there’s a mechanism for local caching of educational content and synchronization when connectivity is available.
- Deployment Components:

##### Relationships and Data Flow
- Backend Interactions:
- Internal routing: Show a high-level interconnection between the different backend components (routes, services, and database).
- Services: Particularly note interactions like SMS services (using Twilio), GCS services (for storing/downloading course materials), scheduler services (for timed operations), and any database interactions through db_services.
- External Cloud Integrations:
- Offline & Peer-to-Peer Mesh:
- Offline content download module and possibly a peer-to-peer sharing component that supports local mesh networking and content synchronization.

##### Architectural Patterns & Design Principles
- Modular Separation:
- Clearly distinguish between the frontend (client-side logic/UI) and backend (API endpoints, business logic).
- Separation of concerns, with individual modules for configuration, routing, logging, and services.
- Scalability & Extensibility:
- The project’s architecture hints at microservices-like separation within the backend, modular enough to allow for future expansion and integration.
- Offline-First Strategy:
- Aspects that enable the system to work offline and synchronize data once connectivity is available.

##### Relevant Technologies & Frameworks
- Frontend: ReactJS, Vite, Axios (as seen in axiosConfig.jsx), CSS modules and custom styles.
- Backend: Python (FastAPI framework), YAML configuration, RESTful routes.
- Cloud Technologies: GCP (with services like Cloud Storage, Firestore, Firebase), Twilio for SMS, and potentially integrations with text-to-speech and speech-to-text services.
- Deployment: Google App Engine (backend), Vercel (frontend).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (ReactJS/Vite UI)"]:::frontend
        FE_Comp["UI Components & State Management (AuthContext)"]:::frontend
        FE_Config["API Integration & Config"]:::frontend
        FE_Offline["Offline Content & Mesh Networking"]:::offline
        FE --> FE_Comp
        FE --> FE_Config
        FE --> FE_Offline
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend (Python/FastAPI)"]:::backend
        BE_Entry["Server Entry (main.py/run.py)"]:::backend
        BE_Config["Configuration (backend/config)"]:::backend
        BE_Routes["Routing (assessment, auth, course routes)"]:::backend
        BE_Services["Services (Business Logic & External Integrations)"]:::backend
        BE_Models["Database & Data Models"]:::backend
        BE_Logging["Logging Module"]:::backend
        BE_Utils["Utilities"]:::backend

        BE --> BE_Entry
        BE --> BE_Config
        BE --> BE_Routes
        BE --> BE_Services
        BE --> BE_Models
        BE --> BE_Logging
        BE --> BE_Utils
    end

    %% Deployment Layer
    subgraph "Deployment"
        DEP_FE["Vercel (Frontend Deployment)"]:::deployment
        DEP_BE["Google App Engine (Backend Deployment)"]:::deployment
    end

    %% External Cloud Services
    subgraph "External Cloud Services"
        CLOUD["Cloud Services (GCP, Twilio, etc.)"]:::external
    end

    %% Relationships and Data Flows
    FE_Config -->|"APICalls"| BE_Entry
    BE_Routes -->|"callsServices"| BE_Services
    BE_Services -->|"interactsWith"| BE_Models
    BE_Services -->|"integratesWith"| CLOUD
    FE_Offline -->|"syncsWith"| FE_Config
    DEP_FE --> FE
    DEP_BE --> BE
    BE_Config --> BE_Entry
    FE -->|"userActions"| FE_Comp

    %% Click Events for Frontend Components
    click FE "https://github.com/rks-031/pragati/tree/master/frontend/"
    click FE_Comp "https://github.com/rks-031/pragati/tree/master/frontend/src/components"
    click FE_Comp "https://github.com/rks-031/pragati/blob/master/frontend/src/context/AuthContext.jsx"
    click FE_Config "https://github.com/rks-031/pragati/blob/master/frontend/src/axiosConfig.jsx"
    click FE_Config "https://github.com/rks-031/pragati/blob/master/frontend/vite.config.js"

    %% Click Events for Backend Components
    click BE_Entry "https://github.com/rks-031/pragati/blob/master/backend/main.py"
    click BE_Entry "https://github.com/rks-031/pragati/blob/master/backend/run.py"
    click BE_Config "https://github.com/rks-031/pragati/tree/master/backend/config"
    click BE_Routes "https://github.com/rks-031/pragati/tree/master/backend/routes"
    click BE_Models "https://github.com/rks-031/pragati/blob/master/backend/db/models.py"
    click BE_Services "https://github.com/rks-031/pragati/tree/master/backend/services"
    click BE_Logging "https://github.com/rks-031/pragati/blob/master/backend/logger/logging.py"
    click BE_Utils "https://github.com/rks-031/pragati/blob/master/backend/utils/utils.py"

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef external fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef deployment fill:#FFCCBC,stroke:#BF360C,stroke-width:2px;
    classDef offline fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
```
