# chimple/cuba architecture

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

- Interactive diagram: https://gitdiagram.com/chimple/cuba
- Repository: https://github.com/chimple/cuba

## Overview

Key Components to Include in the System Design:

##### Frontend Architecture
- React Web Application
- Pages (src/pages)
- Components (src/components)
- Services (src/services)
- Models (src/models)
- Mobile Application (Android)
- Capacitor integration for mobile capabilities
- Native Android components (MainActivity, OTPReceiver, PortPlugin)

##### Backend Services
- Firebase Integration
- Authentication (FirebaseAuth)
- Remote Config
- API Services
- OneRoster API Integration
- Authentication
- Data Services

##### Data Flow Layers
- Service Layer
- API Handlers
- Authentication Handlers
- Service Configuration
- Model Layer
- Curriculum
- User Management
- Assignment System
- Live Quiz System

##### External Integrations
- Analytics Dashboard
- Looker Studio Integration
- School Management System

##### Use a layered architecture approach
- [Client Layer]
- Web App (React) ←→ Mobile App (Android/Capacitor)
- ↕                 ↕
- [Service Layer]
- Firebase Services ←→ OneRoster Services
- ↕                 ↕
- [Data Layer]
- Models & Controllers
- ↕
- [External Systems]
- Analytics & Reporting

##### Component Relationships

Special Considerations:

##### Multi-language Support
- I18n integration with supported languages (en, hi, kn, mr)
- Localization flow

##### Educational Features
- Curriculum management
- Quiz system architecture
- Assignment workflow
- Leaderboard system

##### User Management
- Teacher/Student/Parent roles
- School management
- Class management
- Profile management

##### Mobile-Specific Features
- Native capabilities
- OTP handling
- File system access
- Platform-specific optimizations

- Component types
- Connection types
- State management flow
- Data flow direction

Remember to include version control and CI/CD workflow indicators, as evidenced by the GitHub workflows in the repository.

This system design should provide a clear understanding of the application's architecture while maintaining the right balance between detail and abstraction.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        direction TB
        WebApp["React Web App"]:::frontend
        MobileApp["Mobile App (Android/Capacitor)"]:::mobile
        
        subgraph WebComponents
            direction TB
            Pages["Pages"]:::frontend
            Components["Components"]:::frontend
            AppServices["Services"]:::frontend
            Models["Models"]:::frontend
        end
        
        subgraph MobileComponents
            direction TB
            MainActivity["MainActivity"]:::mobile
            OTPReceiver["OTPReceiver"]:::mobile
            PortPlugin["PortPlugin"]:::mobile
        end
        
        WebApp --> WebComponents
        MobileApp --> MobileComponents
    end
    
    subgraph Services
        direction TB
        subgraph FirebaseServices
            direction TB
            FirebaseAuth["Firebase Auth"]:::service
            FirebaseApi["Firebase API"]:::service
            RemoteConfig["Remote Config"]:::service
        end
        
        subgraph OneRosterServices
            direction TB
            OneRosterAuth["OneRoster Auth"]:::service
            OneRosterApi["OneRoster API"]:::service
        end
        
        subgraph ServiceHandlers
            direction TB
            ApiHandler["API Handler"]:::service
            AuthHandler["Auth Handler"]:::service
            ServiceConfig["Service Config"]:::service
        end
    end
    
    subgraph DataLayer
        direction TB
        subgraph Models
            direction TB
            Curriculum["Curriculum"]:::data
            User["User Management"]:::data
            Assignment["Assignment System"]:::data
            LiveQuiz["Live Quiz System"]:::data
        end
        
        subgraph i18n
            direction TB
            EN["English"]:::i18n
            HI["Hindi"]:::i18n
            KN["Kannada"]:::i18n
            MR["Marathi"]:::i18n
        end
    end
    
    subgraph External
        direction TB
        Analytics["Analytics Dashboard"]:::external
        Looker["Looker Studio"]:::external
        SMS["School Management System"]:::external
    end
    
    Client --> Services
    Services --> DataLayer
    DataLayer --> External
    
    %% Click Events
    click WebApp "https://github.com/chimple/cuba/blob/master/src/App.tsx"
    click Pages "https://github.com/chimple/cuba/tree/master/src/pages/"
    click Components "https://github.com/chimple/cuba/tree/master/src/components/"
    click MainActivity "https://github.com/chimple/cuba/blob/master/android/app/src/main/java/org/chimple/bahama/MainActivity.java"
    click OTPReceiver "https://github.com/chimple/cuba/blob/master/android/app/src/main/java/org/chimple/bahama/OTPReceiver.java"
    click PortPlugin "https://github.com/chimple/cuba/blob/master/android/app/src/main/java/org/chimple/bahama/PortPlugin.java"
    click FirebaseAuth "https://github.com/chimple/cuba/blob/master/src/services/auth/FirebaseAuth.ts"
    click FirebaseApi "https://github.com/chimple/cuba/blob/master/src/services/api/FirebaseApi.ts"
    click OneRosterAuth "https://github.com/chimple/cuba/blob/master/src/services/auth/OneRosterAuth.ts"
    click OneRosterApi "https://github.com/chimple/cuba/blob/master/src/services/api/OneRosterApi.ts"
    click ApiHandler "https://github.com/chimple/cuba/blob/master/src/services/api/ApiHandler.ts"
    click AuthHandler "https://github.com/chimple/cuba/blob/master/src/services/auth/AuthHandler.ts"
    click ServiceConfig "https://github.com/chimple/cuba/blob/master/src/services/ServiceConfig.ts"
    click Curriculum "https://github.com/chimple/cuba/blob/master/src/models/curriculum.ts"
    click User "https://github.com/chimple/cuba/blob/master/src/models/user.ts"
    click Assignment "https://github.com/chimple/cuba/blob/master/src/models/assignment.ts"
    click LiveQuiz "https://github.com/chimple/cuba/blob/master/src/models/liveQuiz.ts"
    click EN "https://github.com/chimple/cuba/blob/master/public/locales/en/translation.json"
    click HI "https://github.com/chimple/cuba/blob/master/public/locales/hi/translation.json"
    click KN "https://github.com/chimple/cuba/blob/master/public/locales/kn/translation.json"
    click MR "https://github.com/chimple/cuba/blob/master/public/locales/mr/translation.json"
    
    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef mobile fill:#4CAF50,stroke:#2E7D32,color:white
    classDef service fill:#FF9800,stroke:#EF6C00,color:white
    classDef data fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef external fill:#F44336,stroke:#C62828,color:white
    classDef i18n fill:#795548,stroke:#4E342E,color:white
```
