# iiph-gandhinagar/ni-kshay-setu-frontend architecture

> Architecture diagram of the GitHub repository iiph-gandhinagar/ni-kshay-setu-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iiph-gandhinagar/ni-kshay-setu-frontend
- Repository: https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend

## Overview

##### Project type and purpose
- This is a full-stack, cross-platform learning and knowledge-management application (“Ni-kshay Setu”) comprising:
- A React Native mobile app (Android & iOS)
- A React.js web app
- A shared package of UI components, Redux store logic, sagas, and utility modules
- Its goal is to provide interactive learning modules, case simulations, assessments, leaderboards, chat-bot navigation, notifications, multi-language support, and resource materials for TB care.

##### File structure
- Top-level monorepo layout:
- packages/mobile → React Native code + native Android/iOS projects
- packages/web    → React.js web app
- packages/shared → common Redux store (actions, reducers, sagas), utilities (API client, URLs, auth, functions), mock store
- State management: Redux + Redux Saga, with actions, reducers, sagas under shared/Store
- Network layer: shared/utils/NetworkClient.js & Api.js invoke RESTful backend endpoints
- Config/build files: babel.config.js, metro.config.js (mobile), tsconfig.json, package.json, .circleci/config.yml, Husky hooks, commitlint

##### README for additional insights
- Architecture notes: mobile uses React Native + Java/Swift for native modules; web uses React.js
- Notification service: Firebase Push Notification
- Backend: REST API published separately (link in README)
- Key features: chat-bot (ML/NLP engine integration), multi-language, offline/SQLite support on mobile

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Clients"
        direction TB
        MobileApp["React Native App"]:::ui
        WebApp["React.js Web App"]:::ui
    end

    %% Shared Code Library
    subgraph "Shared Library" 
        direction TB
        SharedIndex["packages/shared/index.js"]:::library
        subgraph "State Management (Redux + Sagas)"
            direction TB
            Actions["Actions"]:::logic
            Reducers["Reducers"]:::logic
            Sagas["Sagas"]:::logic
            StoreSetup["Store Setup"]:::logic
        end
        subgraph "Mock Store"
            direction TB
            MockStore["Mock Store"]:::logic
        end
        subgraph "Utilities"
            direction TB
            NetworkClient["NetworkClient.js"]:::api
            ApiLayer["Api.js"]:::api
            Urls["urls.js"]:::api
            AuthUtil["auth.js"]:::api
        end
    end

    %% Mobile-specific Offline Persistence & Navigation
    subgraph "Mobile Native Modules"
        direction TB
        SQLiteClient["SQLiteClient.ts"]:::logic
        Database["Database.ts"]:::logic
        Navigation["App Navigation"]:::logic
    end

    %% Backend Services & Data
    subgraph "Backend Services"
        direction TB
        APIService["REST API Service"]:::backend
        DB["Database (Postgres/Mongo)"]:::db
    end

    %% External Integrations
    subgraph "External Services"
        direction TB
        Firebase["Firebase Push Notifications"]:::external
        CDN["CDN / Object Storage"]:::external
        Chatbot["Chatbot / ML Engine"]:::external
        AuthProvider["Authentication Provider"]:::external
    end

    %% Data Flow
    MobileApp -->|"uses shared UI, store"| SharedIndex
    WebApp -->|"uses shared UI, store"| SharedIndex
    SharedIndex -->|dispatches actions| Actions
    Actions -->|update| Reducers
    Actions -->|trigger| Sagas
    Sagas -->|call| NetworkClient
    NetworkClient -->|invoke| ApiLayer
    ApiLayer -->|request| APIService
    APIService -->|query| DB
    APIService -->|push notifications via| Firebase
    APIService -->|serve assets via| CDN
    MobileApp -->|offline read/write| SQLiteClient
    SQLiteClient -->|persist| Database
    MobileApp -->|navigate via| Navigation
    MobileApp -->|chat queries| Chatbot
    WebApp -->|chat queries| Chatbot
    MobileApp -->|auth| AuthProvider
    WebApp -->|auth| AuthProvider

    %% Click Events
    click MobileApp "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/tree/main/packages/mobile/src"
    click WebApp "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/tree/main/packages/web/src"
    click SharedIndex "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/index.js"
    click Actions "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/tree/main/packages/shared/Store/action"
    click Reducers "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/tree/main/packages/shared/Store/reducer"
    click Sagas "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/tree/main/packages/shared/Store/saga"
    click StoreSetup "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/Store/index.js"
    click MockStore "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/MockStore/Store.tsx"
    click NetworkClient "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/utils/NetworkClient.js"
    click ApiLayer "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/utils/Api.js"
    click Urls "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/utils/urls.js"
    click AuthUtil "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/shared/utils/auth.js"
    click SQLiteClient "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/mobile/src/SqlStore/SQLiteClient.ts"
    click Database "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/mobile/src/SqlStore/Database.ts"
    click Navigation "https://github.com/iiph-gandhinagar/ni-kshay-setu-frontend/blob/main/packages/mobile/src/AppNavigation.tsx"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0066CC,color:#003366;
    classDef library fill:#E8F4D0,stroke:#6B8E23,color:#556B2F;
    classDef logic fill:#E0FFE0,stroke:#228B22,color:#006400;
    classDef api fill:#FFE8C0,stroke:#FF8C00,color:#8B4500;
    classDef backend fill:#F0F0F0,stroke:#666666,color:#333333;
    classDef db fill:#F5F5F5,stroke:#888888,color:#555555;
    classDef external fill:#F4E1FF,stroke:#800080,color:#4B0082;
```
