# bill-gd/fpt_jp architecture

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

- Interactive diagram: https://gitdiagram.com/bill-gd/fpt_jp
- Repository: https://github.com/bill-gd/fpt_jp

## Overview

##### Project Type & Purpose
- Type: A cross-platform Flutter mobile/desktop app (Android & Windows targets)
- Purpose: Track and revise Japanese coursework (kanji lessons, vocabulary), following an MVVM-style separation (even if simplified).

##### High-Level Architecture Overview
a. Platform & Runtime
– Android Runner & Windows Runner (bind the OS window, lifecycle → Flutter Engine)
– Flutter Engine (Dart VM, rendering)
b. Dart App Layers (lib/)
1. UI Layer (screens & widgets)
3. Data Layer
– Repositories (kanji, vocab, about)
– Database Handler (SQLite schema from database.sql)
4. Domain Layer (pure models: KanjiLesson, Vocab, etc.)
5. Utilities & Assets (helpers, extensions, fonts/images)

##### File Structure
- android/, windows/: Platform-specific runners & build scripts.
- lib/main.dart: App entry point → initializes platform channels, DI, routes.
- lib/ui/: Flutter screens (home, kanji, vocab, about) composes widgets.
- lib/data/repositories/: Abstracts all data operations.
- lib/utils/handlers/database_handler.dart: Manages raw DB connections & queries.
- assets/: Static resources (fonts, images).

##### Key Architectural Patterns & Flows
- MVVM-style (View ↔ ViewModel ↔ Model).
- Repository Pattern isolating data sources.
- Single local SQLite database as the only persistence layer.
- No external network services.
- Flutter’s widget tree + custom styling in lib/ui/core/styling.

– Android Runner / Windows Runner
– Flutter Engine
– UI Layer (group lib/ui/…)
– ViewModel Layer (if present)
– Repository Layer (lib/data/repositories)
– Database (SQLite)
– Domain Models (lib/domain/models)
– Utilities & Assets

1. Platform Runners → Flutter Engine.
2. Flutter Engine → main.dart → initialize ViewModels or DI.
3. UI Layer → calls into ViewModels or directly into Repositories.
4. Repositories → Database Handler → SQLite store.
5. Database → returns raw rows → Repositories → map to Domain Models → back up to UI.

c. Patterns:
– Repository Pattern between UI/ViewModel and DB.
– Domain Models locked in a separate layer.

d. Technologies & Frameworks:
– Flutter (Dart)
– SQLite (via raw SQL in database.sql)
– MVVM concepts
– Flutter’s Navigator & Material widgets

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Platform & Runtime"
        AndroidRunner["Android Runner"]:::platform
        WindowsRunner["Windows Runner"]:::platform
        FlutterEngine["Flutter Engine"]:::engine
    end
    AndroidRunner --> FlutterEngine
    WindowsRunner --> FlutterEngine

    FlutterEngine --> MainApp["main.dart"]:::entry

    subgraph "Dart App"
        subgraph "UI Layer"
            HomeScreen["Home Screen"]:::ui
            KanjiScreens["Kanji Screens"]:::ui
            VocabScreen["Vocab Screen"]:::ui
            AboutScreens["About Screens"]:::ui
            CoreUI["Core UI & Styling"]:::ui
        end
        subgraph "ViewModel Layer"
            ViewModel["ViewModel (optional)"]:::vm
        end
        subgraph "Repository Layer"
            KanjiRepo["KanjiRepository"]:::repo
            VocabRepo["VocabRepository"]:::repo
            AboutRepo["AboutRepository"]:::repo
        end
        subgraph "Data Layer"
            DBHandler["DatabaseHandler"]:::data
            SQLiteDB["SQLite Database"]:::db
        end
        subgraph "Domain Layer"
            DomainModels["Domain Models"]:::domain
        end
        subgraph "Utilities & Assets"
            Utils["Utilities & Helpers"]:::utils
            Assets["Assets (fonts & images)"]:::assets
        end
    end

    MainApp --> HomeScreen
    HomeScreen --> ViewModel
    KanjiScreens --> ViewModel
    VocabScreen --> ViewModel
    AboutScreens --> ViewModel
    CoreUI --> HomeScreen

    ViewModel --> KanjiRepo
    ViewModel --> VocabRepo
    ViewModel --> AboutRepo

    KanjiRepo --> DBHandler
    VocabRepo --> DBHandler
    AboutRepo --> DBHandler

    DBHandler --> SQLiteDB
    SQLiteDB --> DBHandler
    DBHandler -->|maps rows| DomainModels
    DomainModels -->|used by| HomeScreen

    Utils --> MainApp
    Assets --> HomeScreen

    click AndroidRunner "https://github.com/bill-gd/fpt_jp/blob/main/android/app/src/main/kotlin/com/billgd/fpt_jp/MainActivity.kt"
    click WindowsRunner "https://github.com/bill-gd/fpt_jp/tree/main/windows/runner/"
    click MainApp "https://github.com/bill-gd/fpt_jp/blob/main/lib/main.dart"
    click HomeScreen "https://github.com/bill-gd/fpt_jp/blob/main/lib/ui/home/home_screen.dart"
    click KanjiScreens "https://github.com/bill-gd/fpt_jp/tree/main/lib/ui/kanji/"
    click VocabScreen "https://github.com/bill-gd/fpt_jp/blob/main/lib/ui/vocab/vocab_screen.dart"
    click AboutScreens "https://github.com/bill-gd/fpt_jp/tree/main/lib/ui/about/"
    click CoreUI "https://github.com/bill-gd/fpt_jp/tree/main/lib/ui/core/"
    click KanjiRepo "https://github.com/bill-gd/fpt_jp/blob/main/lib/data/repositories/kanji_repository.dart"
    click VocabRepo "https://github.com/bill-gd/fpt_jp/blob/main/lib/data/repositories/vocab_repository.dart"
    click AboutRepo "https://github.com/bill-gd/fpt_jp/blob/main/lib/data/repositories/about_repository.dart"
    click DBHandler "https://github.com/bill-gd/fpt_jp/blob/main/lib/utils/handlers/database_handler.dart"
    click SQLiteDB "https://github.com/bill-gd/fpt_jp/blob/main/lib/database/database.sql"
    click DomainModels "https://github.com/bill-gd/fpt_jp/tree/main/lib/domain/models/"
    click Utils "https://github.com/bill-gd/fpt_jp/tree/main/lib/utils/"
    click Assets "https://github.com/bill-gd/fpt_jp/tree/main/assets/"

    classDef platform fill:#E8DAEF,stroke:#7D3C98
    classDef engine fill:#D6EAF8,stroke:#2874A6
    classDef entry fill:#FCF3CF,stroke:#B7950B
    classDef ui fill:#D5F5E3,stroke:#28B463
    classDef vm fill:#FADBD8,stroke:#CB4335
    classDef repo fill:#FCF3CF,stroke:#B7950B
    classDef data fill:#D6EAF8,stroke:#2874A6
    classDef db fill:#FDEBD0,stroke:#E67E22
    classDef domain fill:#F9E79F,stroke:#B7950B
    classDef utils fill:#F2F3F4,stroke:#979A9A
    classDef assets fill:#EBDEF0,stroke:#8E44AD
```
