# juanmproyect/coinflow architecture

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

- Interactive diagram: https://gitdiagram.com/juanmproyect/coinflow
- Repository: https://github.com/juanmproyect/coinflow

## Overview

##### Project Overview
- CoinFlow is a full-featured mobile application built with Flutter/Dart and designed for real-time currency conversion.
- Its main functionalities include real-time conversion (via Exchangerate-API), favorite currencies management, conversion history, offline mode, and theme customization.
- It integrates with Firebase Firestore for storing user history and settings.

##### Main Components
- Frontend (Flutter UI/UX Layer):
- Screens: Located in lib/Screens (home, favorites, history, loading, settings).
- UX & Theme components: lib/UX (home_design.dart, theme_manager.dart) providing the presentation layer and theme controls.
- Services (Business Logic & Data Layer):
- API Service: lib/Services/api_service.dart handling calls to Exchangerate-API.
- Currency Data Service: lib/Services/currency_data.dart for managing conversion logic.
- Firebase Options: lib/Services/firebase_options.dart, including Firebase configuration details.
- External Systems:
- Exchangerate-API: The third-party currency conversion API.
- Firebase Firestore: For syncing conversion history, user settings, and possible offline data synchronization.
- Platform-specific Layers:
- Multiple folders (android, ios, linux, macos, windows, web) show how Flutter compiles to different platforms, though the core business logic resides in lib.
- State Management:
- Although not explicitly visible, the use of “Provider” in the requirements hints that state management is implemented to sync UI components with underlying data/services.

##### Relationships and Interactions
- UI components interact with the Services layer (API calls, state updates, theme switching).
- The API Service fetches conversion rates from Exchangerate-API and passes the data to the UI.
- The Firebase service saves and retrieves user data (conversion history, favorites, theme settings) ensuring real-time updates.
- An offline mode mechanism would likely cache data locally so that network interruptions do not cause a critical failure.

##### Architectural Patterns and Technologies
- Separation of Concerns: Clear distinction between UI (lib/Screens, lib/UX) and business logic/services (lib/Services).
- Use of Provider: Suggests a reactive programming model where UI reacts to state changes.
- Cross-Platform Design: The project structure indicates target exports on Android, iOS, web, and desktop, all driven by the same Flutter code in lib.
- Third-Party Integration: Firebase Firestore for database needs and Exchangerate-API for external data.
- Offline Handling: Although implementation details might reside in the business logic, the design should account for local caching.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI_Screens["UI Screens"]:::frontend
        UX_Theme["UX & Theme"]:::frontend
    end

    %% Services/Business Logic Layer
    subgraph "Services/Business Logic"
        API_Service["API Service"]:::business
        Currency_Logic["Currency Conversion Logic"]:::business
        Firebase_Config["Firebase Options"]:::business
    end

    %% External Systems
    subgraph "External Systems"
        Exchangerate_API["Exchangerate-API"]:::external
        Firebase_FS["Firebase Firestore"]:::external
    end

    %% Cross-Platform Deployment
    subgraph "Cross-Platform Deployment"
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        Linux["Linux"]:::platform
        macOS["macOS"]:::platform
        Windows["Windows"]:::platform
        Web["Web"]:::platform
    end

    %% Data Flows and Relationships
    UI_Screens -->|"UserInteraction"| API_Service
    UI_Screens -->|"ConversionRequest"| Currency_Logic
    UI_Screens -->|"SettingsUpdate"| Firebase_Config
    UX_Theme -->|"ThemeControl"| UI_Screens

    API_Service -->|"FetchRates"| Exchangerate_API
    Currency_Logic -->|"ComputeConversion"| Exchangerate_API

    Firebase_Config -->|"SyncData"| Firebase_FS
    Firebase_FS -->|"PushUpdates"| UI_Screens

    %% Platform connectivity
    UI_Screens ---|"RunsOn"| Android
    UI_Screens ---|"RunsOn"| iOS
    UI_Screens ---|"RunsOn"| Linux
    UI_Screens ---|"RunsOn"| macOS
    UI_Screens ---|"RunsOn"| Windows
    UI_Screens ---|"RunsOn"| Web

    %% Click Events
    click UI_Screens "https://github.com/juanmproyect/coinflow/tree/main/lib/Screens"
    click UX_Theme "https://github.com/juanmproyect/coinflow/tree/main/lib/UX"
    click API_Service "https://github.com/juanmproyect/coinflow/blob/main/lib/Services/api_service.dart"
    click Currency_Logic "https://github.com/juanmproyect/coinflow/blob/main/lib/Services/currency_data.dart"
    click Firebase_Config "https://github.com/juanmproyect/coinflow/blob/main/lib/Services/firebase_options.dart"
    click Android "https://github.com/juanmproyect/coinflow/tree/main/android"
    click iOS "https://github.com/juanmproyect/coinflow/tree/main/ios"
    click Linux "https://github.com/juanmproyect/coinflow/tree/main/linux"
    click macOS "https://github.com/juanmproyect/coinflow/tree/main/macos"
    click Windows "https://github.com/juanmproyect/coinflow/tree/main/windows"
    click Web "https://github.com/juanmproyect/coinflow/tree/main/web"

    %% Styles
    classDef frontend fill:#a8d0e6,stroke:#333,stroke-width:2px;
    classDef business fill:#f76c6c,stroke:#333,stroke-width:2px;
    classDef external fill:#f8e473,stroke:#333,stroke-width:2px;
    classDef platform fill:#d3e0ea,stroke:#333,stroke-width:2px;
```
