# delta/dalal-street-client architecture

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

- Interactive diagram: https://gitdiagram.com/delta/dalal-street-client
- Repository: https://github.com/delta/dalal-street-client

## Overview

##### Main Components
- UI/Presentation Layer: Represented by the Flutter UI code in lib/pages, lib/components, and lib/theme. This layer handles rendering widgets, handling user interactions, and maintaining platform-specific styling.
- Business Logic Layer: The BLoC components in lib/blocs (organized by feature such as auth, ipo, market_depth, mortgage, etc.). This layer manages state, processes user actions, and coordinates between the UI and lower-level services.
- Service & Data Access Layer: Consists of network and GRPC communication (lib/grpc folder), configuration/setup (lib/config, config.json), models (lib/models), and utility modules. This component communicates with back-end servers via gRPC and handles data serialization (using protocol buffers in the proto folder).
- Navigation & Routing: Managed via lib/navigation to control routing between pages and handle error screens.
- External Modules and Integrations:
- Platform-specific projects (android, ios, web folders) that serve as entry points to the application.
- Build and deployment components (Dockerfile, GitHub workflows, build_proto.sh) for CI/CD and containerization.

##### Out the Relationships and Data Flow
- The UI layer (pages and components) sends user events to the underlying BLoC (Business Logic) components.
- The BLoCs process these events, manage state, and invoke service calls.
- Data requests from BLoCs are delegated to the service layer where gRPC is used to communicate with backend servers.
- Responses from the service layer are then forwarded back and propagated through the BLoC, which updates the UI accordingly.
- Navigation and routing layers tie together the different UI pages and ensure seamless transitions based on user actions or state changes.
- Configuration files and utility classes provide cross-cutting functionalities such as logging, error handling, theme management, and form validation.

##### Architectural Patterns
- The BLoC pattern is used extensively for state management, ensuring a clean separation between UI and business logic.
- Dependency injection is implemented (as seen in lib/config/get_it.dart) to manage services like the GRPC client and configuration.
- The modular project structure (with separate directories for pages, components, and blocs by feature) emphasizes domain-based segmentation.
- A multi-platform approach is evident by having distinct directories for Android, iOS, and web – each with tailored configurations and resources.

##### Key Technologies and Frameworks
- Flutter – for cross-platform UI development.
- BLoC Pattern – for state management (using Cubits and Blocs).
- gRPC – for communication with the backend, with protocol buffers driving serialization and service definitions.
- Dependency Injection – likely managed using get_it.
- Platform-specific integrations – Android (native Kotlin code), iOS (Swift), and Web configurations.

##### Specific Elements
- External platforms (Android, iOS, Web) as entry nodes that feed into the shared application code.
- Labels for protocols (gRPC, protocol buffers) and add notes about dependency injection and utility modules.

##### Additional Diagramming Advice
- Use clear and consistent labeling for every component.
- Configuration or build steps briefly (like proto file generation and CI/CD workflows) to provide context on how the code is compiled and deployed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Modules and Integrations
    subgraph "External Modules and Integrations"
        Android["Android"]:::infra
        iOS["iOS"]:::infra
        Web["Web"]:::infra
        Assets["Assets"]:::infra
        Dockerfile["Dockerfile"]:::infra
        Workflows[".github/workflows"]:::infra
        BuildProto["build_proto.sh"]:::infra
    end

    %% Flutter UI / Presentation Layer
    subgraph "Flutter UI / Presentation Layer"
        Pages["lib/pages"]:::ui
        Components["lib/components"]:::ui
        Theme["lib/theme"]:::ui
        Navigation["lib/navigation"]:::ui
    end

    %% BLoC / Business Logic Layer
    subgraph "BLoC / Business Logic Layer"
        Blocs["lib/blocs"]:::bloc
    end

    %% Service / Data Access Layer
    subgraph "Service / Data Access Layer"
        GRPC["lib/grpc"]:::service
        Proto["proto"]:::service
        Models["lib/models"]:::service
        Config["lib/config"]:::service
        ConfigExample["config.example.json"]:::service
    end

    %% Connections between External Modules and UI
    Android -->|"feeds"| Pages
    iOS -->|"feeds"| Pages
    Web -->|"feeds"| Pages
    Assets -->|"supplies"| Pages

    %% Connections within UI and Navigation
    Pages -->|"userEvents"| Blocs
    Pages -->|"navigates"| Navigation

    %% Connections between BLoC and Service Layer
    Blocs -->|"callsGRPC"| GRPC
    GRPC -->|"returnsData"| Blocs

    %% Dependency Injection and Build Process
    Config -->|"injects"| GRPC
    Config -->|"injects"| Models
    BuildProto -->|"generates"| Proto

    %% UI Update Flow
    Blocs -->|"updatesUI"| Pages

    %% Styling Classes
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef bloc fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef infra fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events for UI/Presentation Layer
    click Pages "https://github.com/delta/dalal-street-client/tree/master/lib/pages"
    click Components "https://github.com/delta/dalal-street-client/tree/master/lib/components"
    click Theme "https://github.com/delta/dalal-street-client/tree/master/lib/theme"
    click Navigation "https://github.com/delta/dalal-street-client/tree/master/lib/navigation"

    %% Click Events for Business Logic Layer (BLoC)
    click Blocs "https://github.com/delta/dalal-street-client/tree/master/lib/blocs"

    %% Click Events for Service & Data Access Layer
    click GRPC "https://github.com/delta/dalal-street-client/tree/master/lib/grpc"
    click Proto "https://github.com/delta/dalal-street-client/tree/master/proto"
    click Models "https://github.com/delta/dalal-street-client/tree/master/lib/models"
    click Config "https://github.com/delta/dalal-street-client/tree/master/lib/config"
    click ConfigExample "https://github.com/delta/dalal-street-client/blob/master/config.example.json"

    %% Click Events for External Modules and Integrations
    click Android "https://github.com/delta/dalal-street-client/tree/master/android"
    click iOS "https://github.com/delta/dalal-street-client/tree/master/ios"
    click Web "https://github.com/delta/dalal-street-client/tree/master/web"
    click Assets "https://github.com/delta/dalal-street-client/tree/master/assets"
    click Dockerfile "https://github.com/delta/dalal-street-client/tree/master/Dockerfile"
    click Workflows "https://github.com/delta/dalal-street-client/tree/master/.github/workflows"
    click BuildProto "https://github.com/delta/dalal-street-client/blob/master/build_proto.sh"
```
