# arafipro/jpstockminimemo architecture

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

- Interactive diagram: https://gitdiagram.com/arafipro/jpstockminimemo
- Repository: https://github.com/arafipro/jpstockminimemo

## Overview

##### Project Type and Purpose
- Type: Cross-platform mobile application built with Flutter (Dart) targeting Android and iOS.
- Purpose: Allow users to locally record short investment memos for Japanese stocks (supporting market reorg and alphanumeric codes).

##### High-Level Architectural Layers
Layer 1 (UI / Presentation)
Layer 2 (ViewModel / Business Logic)
Layer 3 (Data / Persistence)
Layer 4 (Platform & Deployment)

##### Main Components
a. Presentation Layer
– Views (lib/views/*): LoadPage, ListPage, EditPage, SettingsPage, ErrorPage
– Components (lib/components/*): StockCard, CustomTextFormField, AdBanner, etc.
b. Business Logic Layer
– ViewModels (lib/viewmodels/*): ListModel, EditModel, SettingsModel
– Validators & Utilities (lib/utils/stock_code_validator.dart)
c. Data Layer
– Models (lib/models/stock_memo.dart)
– Local DB Helper (lib/utils/dbhelper.dart) – likely using sqflite or similar
d. Platform & Deployment
– Flutter Engine & Dart VM
– Android native project (android/)
– iOS native project (ios/)
– Build scripts (pubspec.yaml, android/gradle, ios/Podfile)
– Packaging & Distribution (Google Play, App Store links)

##### Relationships & Data Flow
1) User taps a button on View → View calls its ViewModel
2) ViewModel orchestrates validation (stock_code_validator) and calls DBHelper
3) DBHelper performs CRUD on local SQLite DB → returns Model objects
4) ViewModel formats data → notifies View to update UI
5) Settings toggle (e.g., “いきなり入力”) persists to local storage → read by LoadPage on startup

– UI→ViewModel (Invoke action)
– ViewModel→DBHelper (Data request)
– DBHelper→SQLite (Write/Read)
– DBHelper→ViewModel (Data response)
– ViewModel→UI (State update)

##### Important Architectural Patterns
- MVVM (Model-View-ViewModel) – separation of concerns between UI, state, and data.
- Repository pattern via DBHelper – isolate persistence logic behind an interface.
- Offline-first design – no external network calls. All storage is local.
- Flutter’s platform channels – embedding within native Android/iOS shells.

##### Final Checklist
– [ ] UI Components layer with Views & Widgets
– [ ] ViewModel layer showing state managers
– [ ] Data layer with Models & DB helper
– [ ] Native shells (android/, ios/) and Flutter engine boundary
– [ ] Call out important files or directories where relevant (e.g., lib/utils/dbhelper.dart)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI / Presentation Layer
    subgraph "UI / Presentation Layer"
        direction TB
        LoadPage["LoadPage"]:::ui
        ListPage["ListPage"]:::ui
        EditPage["EditPage"]:::ui
        SettingsPage["SettingsPage"]:::ui
        ErrorPage["ErrorPage"]:::ui
        StockCard["StockCard"]:::ui
        CustomTextFormField["CustomTextFormField"]:::ui
        AdBanner["AdBanner"]:::ui
        CustomAlertDialog["CustomAlertDialog"]:::ui
        AssetsIcons["Icons"]:::ui
        AssetsLauncher["Launcher Images"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        ListModel["ListModel"]:::logic
        EditModel["EditModel"]:::logic
        SettingsModel["SettingsModel"]:::logic
        StockCodeValidator["StockCodeValidator"]:::logic
    end

    %% Data / Persistence Layer
    subgraph "Data / Persistence Layer"
        direction TB
        StockMemo["StockMemo"]:::data
        DBHelper["DBHelper"]:::data
        Constants["Constants"]:::data
        SQLiteDB[(SQLite Database)]:::data
    end

    %% Platform & Deployment
    subgraph "Platform & Deployment"
        direction TB
        FlutterEngine["Flutter Engine & Dart VM"]:::platform
        AndroidShell["Android Shell (android/)"]:::platform
        iOSShell["iOS Shell (ios/)"]:::platform
        MainEntrypoint["main.dart"]:::platform
        Pubspec["pubspec.yaml"]:::platform
        Gradle["android/app/build.gradle"]:::platform
        Podfile["ios/Podfile"]:::platform
    end

    %% Relationships
    LoadPage -->|taps → invokes| ListModel
    ListPage -->|taps → invokes| ListModel
    EditPage -->|taps → invokes| EditModel
    SettingsPage -->|taps → invokes| SettingsModel
    ErrorPage -->|displays errors from| EditModel

    ListModel -->|uses| StockCodeValidator
    EditModel -->|uses| StockCodeValidator
    SettingsModel -->|uses| StockCodeValidator

    ListModel -->|calls| DBHelper
    EditModel -->|calls| DBHelper
    SettingsModel -->|calls| DBHelper

    DBHelper -->|CRUD| SQLiteDB
    SQLiteDB -->|returns data| DBHelper
    DBHelper -->|returns model| ListModel
    DBHelper -->|returns model| EditModel
    DBHelper -->|returns model| SettingsModel

    ListModel -->|updates UI| ListPage
    EditModel -->|updates UI| EditPage
    SettingsModel -->|updates UI| SettingsPage

    AssetsIcons -->|display in| LoadPage
    AssetsLauncher -->|app icons for| AndroidShell
    AssetsLauncher -->|app icons for| iOSShell

    Constants -->|provide styles/strings to| LoadPage
    Constants -->|provide styles/strings to| ListPage
    Constants -->|provide styles/strings to| EditPage
    Constants -->|provide styles/strings to| SettingsPage
    Constants -->|provide to| StockCard
    Constants -->|provide to| CustomTextFormField

    MainEntrypoint -->|boots| FlutterEngine
    FlutterEngine -->|hosted in| AndroidShell
    FlutterEngine -->|hosted in| iOSShell
    Pubspec -->|defines deps & assets| FlutterEngine
    Gradle -->|build config| AndroidShell
    Podfile -->|build config| iOSShell

    %% Click Events
    click LoadPage "https://github.com/arafipro/jpstockminimemo/blob/main/lib/views/load_page.dart"
    click ListPage "https://github.com/arafipro/jpstockminimemo/blob/main/lib/views/list_page.dart"
    click EditPage "https://github.com/arafipro/jpstockminimemo/blob/main/lib/views/edit_page.dart"
    click SettingsPage "https://github.com/arafipro/jpstockminimemo/blob/main/lib/views/settings_page.dart"
    click ErrorPage "https://github.com/arafipro/jpstockminimemo/blob/main/lib/views/error_page.dart"
    click StockCard "https://github.com/arafipro/jpstockminimemo/blob/main/lib/components/stock_card.dart"
    click CustomTextFormField "https://github.com/arafipro/jpstockminimemo/blob/main/lib/components/custom_text_form_field.dart"
    click AdBanner "https://github.com/arafipro/jpstockminimemo/blob/main/lib/components/adbanner.dart"
    click CustomAlertDialog "https://github.com/arafipro/jpstockminimemo/blob/main/lib/components/custom_alert_dialog.dart"
    click ListModel "https://github.com/arafipro/jpstockminimemo/blob/main/lib/viewmodels/list_model.dart"
    click EditModel "https://github.com/arafipro/jpstockminimemo/blob/main/lib/viewmodels/edit_model.dart"
    click SettingsModel "https://github.com/arafipro/jpstockminimemo/blob/main/lib/viewmodels/settings_model.dart"
    click StockCodeValidator "https://github.com/arafipro/jpstockminimemo/blob/main/lib/utils/stock_code_validator.dart"
    click StockMemo "https://github.com/arafipro/jpstockminimemo/blob/main/lib/models/stock_memo.dart"
    click DBHelper "https://github.com/arafipro/jpstockminimemo/blob/main/lib/utils/dbhelper.dart"
    click Constants "https://github.com/arafipro/jpstockminimemo/tree/main/lib/constants"
    click MainEntrypoint "https://github.com/arafipro/jpstockminimemo/blob/main/lib/main.dart"
    click Pubspec "https://github.com/arafipro/jpstockminimemo/blob/main/pubspec.yaml"
    click Gradle "https://github.com/arafipro/jpstockminimemo/blob/main/android/app/build.gradle"
    click Podfile "https://github.com/arafipro/jpstockminimemo/tree/main/ios/Podfile"

    %% Styles
    classDef ui fill:#CCEEFF,stroke:#333,stroke-width:1px
    classDef logic fill:#DDFFCC,stroke:#333,stroke-width:1px
    classDef data fill:#FFE5CC,stroke:#333,stroke-width:1px
    classDef platform fill:#EEEEEE,stroke:#333,stroke-width:1px
```
