# shreya-scode/learn-api architecture

> Architecture diagram of the GitHub repository shreya-scode/learn-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shreya-scode/learn-api
- Repository: https://github.com/shreya-scode/learn-api

## Overview

##### Project type and purpose
- This is a cross-platform Flutter client application (“learn_api”) whose primary function is to fetch blood-pressure data from an external HTTP API and render it on multiple platforms (Android, iOS, Web, Windows, macOS, Linux).
- The app uses the BLoC (Business Logic Component) pattern for state management, a repository layer to encapsulate data-access logic, and a set of UI screens and widgets to present charts and information.

##### File structure
- Top-level platform folders (android/, ios/, web/, windows/, macos/, linux/) each hold native build configurations and platform integration code (Gradle, Xcode, CMake, etc.).
- lib/ is the Dart application code:
- bloc/ → BLoC components (fetchbloodpressure_bloc.dart, events, states)
- model/ → data model classes (bloodpressuredata.dart)
- repos/ → repository and API client (fetchbloodpressureapi.dart)
- screens/ → UI pages (home.dart)
- widgets/ → reusable UI pieces (bloodpressurechart.dart)
- main.dart → app entrypoint and widget tree wiring
- test/ contains widget tests.
- pubspec.yaml defines dependencies (flutter, flutter_bloc, http, charts, etc.).

##### README
- It’s the standard Flutter boilerplate README; it confirms no backend or complex architecture documentation is included. The main insights come from code organization.

- Platform Layers (Android, iOS, Web, Desktop)
- Flutter Engine & Embedder (Dart VM, Skia, Platform Channels)
- Application Layers:
– UI Layer (Screens + Widgets)
– State Management Layer (BLoC)
– Data Layer (Repository + HTTP API Client)
- External Service (Blood Pressure REST API)
b. Relationships & interactions:
1. User interacts with UI Screens/Widgets → triggers UI events.
2. UI dispatches Events into the BLoC → BLoC processes Events, emits new States.
3. On certain Events, BLoC calls the Repository.
4. Repository uses the HTTP API Client (fetchbloodpressureapi) to perform network calls.
5. HTTP Client communicates with External REST API → receives JSON data.
6. JSON is mapped to Model classes (BloodPressureData) → returned to Repository → BLoC → UI updates with new State.
7. Build tools (Gradle, Xcode, CMake) compile the Dart/Flutter code for each platform.
c. Architectural patterns & principles:
- BLoC pattern for strict separation of UI and business logic.
- Repository pattern abstracts data-access and network concerns behind a stable interface.
- Layered architecture: Presentation (UI) → Business Logic → Data.
- Single source of truth: States from BLoC drive the UI.
d. Key technologies & frameworks:
- Flutter framework (Dart)
- flutter_bloc (for BLoC)
- http (for REST calls)
- charts_flutter or equivalent charting library (used in widgets)
- Platform-specific toolchains: Gradle (Android), Xcode (iOS/macOS), CMake (desktop), web compiler

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Layers
    subgraph "Platforms"
        direction TB
        Android["Android"]:::external
        IOS["iOS"]:::external
        Web["Web"]:::external
        Linux["Linux"]:::external
        MacOS["macOS"]:::external
        Windows["Windows"]:::external
    end

    %% Flutter Engine & Embedder
    FlutterEngine["Flutter Engine & Embedder"]:::external

    %% Application Entry Point
    Main["main.dart"]:::logic

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        HomeScreen["Home Screen"]:::ui
        ChartWidget["BloodPressureChart Widget"]:::ui
    end

    %% State Management Layer
    subgraph "State Management (BLoC)"
        direction TB
        FetchBloc["FetchBloodPressureBLoC"]:::logic
        BlocEvent["Fetch Events"]:::logic
        BlocState["Fetch States"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Repository["Repository & HTTP Client"]:::data
        Model["BloodPressureData Model"]:::data
    end

    %% External Service
    ExternalAPI["External REST API"]:::external

    %% Testing
    Testing["Widget Tests"]:::test

    %% Connections
    Android --> FlutterEngine
    IOS --> FlutterEngine
    Web --> FlutterEngine
    Linux --> FlutterEngine
    MacOS --> FlutterEngine
    Windows --> FlutterEngine

    FlutterEngine --> Main
    Main --> HomeScreen
    Main --> FetchBloc

    HomeScreen --> ChartWidget
    HomeScreen --> FetchBloc
    FetchBloc --> BlocEvent
    FetchBloc --> BlocState
    FetchBloc --> Repository
    Repository --> ExternalAPI
    ExternalAPI --> Repository
    Repository --> Model
    Repository --> FetchBloc
    FetchBloc --> HomeScreen

    Testing --> HomeScreen
    Testing --> FetchBloc

    %% Click Events
    click HomeScreen "https://github.com/shreya-scode/learn-api/blob/master/lib/screens/home.dart"
    click ChartWidget "https://github.com/shreya-scode/learn-api/blob/master/lib/widgets/bloodpressurechart.dart"
    click FetchBloc "https://github.com/shreya-scode/learn-api/blob/master/lib/bloc/fetchbloodpressure/fetchbloodpressure_bloc.dart"
    click BlocEvent "https://github.com/shreya-scode/learn-api/blob/master/lib/bloc/fetchbloodpressure/fetchbloodpressure_event.dart"
    click BlocState "https://github.com/shreya-scode/learn-api/blob/master/lib/bloc/fetchbloodpressure/fetchbloodpressure_state.dart"
    click Repository "https://github.com/shreya-scode/learn-api/blob/master/lib/repos/fetchbloodpressureapi.dart"
    click Model "https://github.com/shreya-scode/learn-api/blob/master/lib/model/bloodpressuredata.dart"
    click Main "https://github.com/shreya-scode/learn-api/blob/master/lib/main.dart"
    click Testing "https://github.com/shreya-scode/learn-api/blob/master/test/widget_test.dart"
    click Android "https://github.com/shreya-scode/learn-api/tree/master/android/"
    click IOS "https://github.com/shreya-scode/learn-api/tree/master/ios/"
    click Web "https://github.com/shreya-scode/learn-api/tree/master/web/"
    click Linux "https://github.com/shreya-scode/learn-api/tree/master/linux/"
    click MacOS "https://github.com/shreya-scode/learn-api/tree/master/macos/"
    click Windows "https://github.com/shreya-scode/learn-api/tree/master/windows/"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000;
    classDef logic fill:#90EE90,stroke:#000;
    classDef data fill:#FFA500,stroke:#000;
    classDef external fill:#D3D3D3,stroke:#000,stroke-dasharray: 5 5;
    classDef test fill:#FFC0CB,stroke:#000;
```
