# chiragkv-juspay/finternet-web architecture

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

- Interactive diagram: https://gitdiagram.com/chiragkv-juspay/finternet-web
- Repository: https://github.com/chiragkv-juspay/finternet-web

## Overview

##### Project type and purpose
- This is a single‐page, mobile‐first web application built in ReScript (ReasonReact) that compiles to JavaScript, bundled by Vite, styled with Tailwind.
- Its purpose is to deliver various financial flows (user onboarding, banking transfers, loan applications, property tokenization) via a unified mobile UI.

##### Main components of the system
a. Build & Deployment
- Source Code (src/**/*.res)
- ReScript Compiler (rescript.json + npm scripts)
- Vite (vite.config.mjs) for bundling, HMR, asset handling
- Tailwind/PostCSS (tailwind.config.js, postcss.config.js) for styling
- Output: static files (index.html, JS/CSS bundles in “public” or “dist”)
- Hosting: CDN or static‐site host (e.g., Netlify, Vercel)

b. Client Runtime (in the user’s browser)
- index.html loads the ReScript‐generated bundle
- App Context (src/Context/AppContext) provides global state via React Context
- UI Components (src/Components) present reusable elements (Accordion, Cards, Headers, Modals, etc.)
- Screen Modules (src/MobileScreens, src/Screens) implement complete flows (Login, Onboarding, Money Transfer, Loan Against Property, Property User Onboarding, Dashboard)
- Types (src/Types) define domain models and API contracts (WebApiTypes, SimpleWebAuthnTypes)

c. External Services
- Backend APIs (REST/GraphQL endpoints for banking, identity, loan underwriting, property tokenization)
- Authentication Provider (WebAuthn via SimpleWebAuthnTypes)
- Third‐party services for QR codes, credentials attestations, etc.

##### Relationships and data flows
- Build & Deployment → produces a static asset bundle → served to Client Runtime
- Client Runtime ↔ Backend APIs: data fetch, submit transactions, authentication flows
- Context manages state transitions triggered by UI Components
- UI Components consume Types and Utilities to render data and handle interactions

##### Architectural patterns and design principles
- Component‐Based UI: each .res file is a self‐contained React component
- Unidirectional Data Flow: React Context + props drilling for state propagation
- Layered structure:
- Presentation Layer (Components & Screens)
- State Management Layer (Context)
- Domain Layer (Types & Utilities)
- Integration Layer (API calls in Utilities or custom hooks)
- Separation of Concerns: styling, logic, types, assets all in dedicated directories

## Diagram (Mermaid)

```mermaid
graph TD
    %% Developer/CI Pipeline
    subgraph "Developer/CI Pipeline"
        direction TB
        ReScriptCompiler["rescript.json"]:::build
        Bundler["vite.config.mjs"]:::build
        TailwindConfig["tailwind.config.js"]:::build
        PostCSSConfig["postcss.config.js"]:::build
        PackageJSON["package.json"]:::build
        StylingEntry["src/index.css"]:::build
    end

    %% Hosting/Static Assets
    subgraph "Hosting / Static Assets"
        direction TB
        HTML["index.html"]:::hosting
        StaticAssets["JS/CSS Bundles (dist)"]:::hosting
        PublicAssets["public"]:::hosting
    end

    %% Client Browser
    subgraph "Client Browser"
        direction TB

        %% Entry
        IndexModule["src/Index.res"]:::entry
        AppRoot["src/App.res"]:::entry

        %% State Management
        subgraph "State Management Layer"
            direction TB
            AppContext["AppContext"]:::state
        end

        %% UI Components
        subgraph "Presentation Layer / UI Components"
            direction TB
            ComponentsDir["src/Components"]:::ui
            Accordion["Accordion"]:::ui
            AccountCard["AccountCard"]:::ui
        end

        %% Icons
        subgraph "Icon Components"
            direction TB
            IconsDir["src/Icons"]:::ui
            ChevronDownIcon["ChevronDownIcon"]:::ui
            ExpandMoreIcon["ExpandMoreIcon"]:::ui
        end

        %% Screen Modules
        subgraph "Screen Modules (Flows)"
            direction TB
            MobileScreensDir["src/MobileScreens"]:::ui
            DomesticTransfer["DomesticMoneyTransfer"]:::ui
            FinternetOnboarding["FinternetOnboarding"]:::ui
            LoanProperty["LoanAgainstProperty"]:::ui
            PropertyOnboarding["PropertyUserOnboarding"]:::ui
            UserOnboarding["UserOnboarding"]:::ui
            LoginScreen["Login"]:::ui
            P4Wrapper["P4Wrapper"]:::ui
            DashboardScreen["src/Screens/Dashboard.res"]:::ui
        end

        %% Domain Types
        subgraph "Domain Layer / Types"
            direction TB
            TypesDir["src/Types"]:::domain
            WebApiTypes["WebApiTypes"]:::domain
            WebAuthnTypes["SimpleWebAuthnTypes"]:::domain
            GeneralTypes["Types"]:::domain
        end

        %% Utilities
        subgraph "Integration Layer / Utilities"
            direction TB
            UtilsDir["src/Utilities"]:::util
            ColorsUtil["Colors"]:::util
            StringsUtil["Strings"]:::util
            PasskeyUtil["RegisterWithPassKeys"]:::util
            UtilsGeneral["Utils"]:::util
            ExampleData["ExampleData"]:::util
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        BankingAPI["Banking API"]:::external
        AuthProvider["Auth Provider (WebAuthn)"]:::external
        PropertyService["Property Tokenization Service"]:::external
        QRService["QR Code Service"]:::external
    end

    %% Connections
    ReScriptCompiler -->|compiles src/**/*.res| Bundler
    Bundler -->|bundles JS/CSS| StaticAssets
    TailwindConfig -->|styles| Bundler
    PostCSSConfig -->|postcss| Bundler
    PackageJSON --> Bundler
    StylingEntry --> Bundler

    Bundler --> HTML
    PublicAssets --> HTML

    HTML -->|loads| IndexModule
    IndexModule --> AppRoot
    AppRoot --> AppContext

    AppContext --> Accordion
    AppContext --> AccountCard
    AppContext --> ChevronDownIcon
    AppContext --> ExpandMoreIcon

    AppContext --> DomesticTransfer
    AppContext --> FinternetOnboarding
    AppContext --> LoanProperty
    AppContext --> PropertyOnboarding
    AppContext --> UserOnboarding
    AppContext --> LoginScreen
    AppContext --> P4Wrapper
    AppContext --> DashboardScreen

    Accordion --> WebApiTypes
    DomesticTransfer --> WebApiTypes
    LoanProperty --> WebApiTypes
    PropertyOnboarding --> WebAuthnTypes

    Accordion --> ColorsUtil
    AccountCard --> ColorsUtil
    UserOnboarding --> ExampleData

    DomesticTransfer -->|REST/GraphQL| BankingAPI
    AuthProvider --> AppContext
    LoginScreen --> AuthProvider
    PropertyOnboarding --> PropertyService
    DashboardScreen --> QRService

    %% Click Events
    click ReScriptCompiler "https://github.com/chiragkv-juspay/finternet-web/blob/main/rescript.json"
    click Bundler "https://github.com/chiragkv-juspay/finternet-web/blob/main/vite.config.mjs"
    click TailwindConfig "https://github.com/chiragkv-juspay/finternet-web/blob/main/tailwind.config.js"
    click PostCSSConfig "https://github.com/chiragkv-juspay/finternet-web/blob/main/postcss.config.js"
    click HTML "https://github.com/chiragkv-juspay/finternet-web/blob/main/index.html"
    click AppRoot "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/App.res"
    click IndexModule "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Index.res"
    click AppContext "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Context/AppContext.res"
    click Accordion "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Components/Accordion.res"
    click AccountCard "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Components/AccountCard.res"
    click ComponentsDir "https://github.com/chiragkv-juspay/finternet-web/tree/main/src/Components"
    click IconsDir "https://github.com/chiragkv-juspay/finternet-web/tree/main/src/Icons"
    click ChevronDownIcon "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Icons/ChevronDownIcon.res"
    click ExpandMoreIcon "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Icons/ExpandMoreIcon.res"
    click MobileScreensDir "https://github.com/chiragkv-juspay/finternet-web/tree/main/src/MobileScreens"
    click DashboardScreen "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Screens/Dashboard.res"
    click TypesDir "https://github.com/chiragkv-juspay/finternet-web/tree/main/src/Types"
    click WebApiTypes "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Types/WebApiTypes.res"
    click WebAuthnTypes "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Types/SimpleWebAuthnTypes.res"
    click GeneralTypes "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Types/Types.res"
    click UtilsDir "https://github.com/chiragkv-juspay/finternet-web/tree/main/src/Utilities"
    click ColorsUtil "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Utilities/Colors.res"
    click StringsUtil "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Utilities/Strings.res"
    click PasskeyUtil "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Utilities/RegisterWithPassKeys.res"
    click UtilsGeneral "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Utilities/Utils.res"
    click ExampleData "https://github.com/chiragkv-juspay/finternet-web/blob/main/src/Utilities/ExampleData.res"
    click PublicAssets "https://github.com/chiragkv-juspay/finternet-web/tree/main/public"

    %% Styles
    classDef build fill:#FFA500,stroke:#333,stroke-width:1px
    classDef hosting fill:#EFEFEF,stroke:#333,stroke-width:1px
    classDef entry fill:#CCE5FF,stroke:#333,stroke-width:1px
    classDef state fill:#D5F5E3,stroke:#333,stroke-width:1px
    classDef ui fill:#AED6F1,stroke:#333,stroke-width:1px
    classDef domain fill:#F9E79F,stroke:#333,stroke-width:1px
    classDef util fill:#D7BDE2,stroke:#333,stroke-width:1px
    classDef external fill:#E59866,stroke:#333,stroke-width:1px
```
