# kou050223/animeishi architecture

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

- Interactive diagram: https://gitdiagram.com/kou050223/animeishi
- Repository: https://github.com/kou050223/animeishi

## Overview

##### プロジェクトの種類と目的
- 本プロジェクトは「アニ名刺」というFlutter製のクロスプラットフォームアプリケーションです。
- 視聴したアニメ一覧を交換し、会話のきっかけにすることを目的としたSNS的要素をもつフルスタック（クライアント＋バックエンド）アプリです。
- バックエンドにはFirebase（Authentication, Firestore, Hostingなど）を利用しています。

##### ファイル構造の概要
- プラットフォーム別コード：android/, ios/, linux/, macos/, windows/, web/
- 共通ビジネスロジック・UI：lib/ 以下
- lib/main.dart や lib/app.dart：エントリポイント
- lib/config/firebase_options.dart：Firebase初期化設定
- lib/model：ドメインモデルとファクトリ
- lib/ui：MVVM的構成（view／view_model）および共通コンポーネント
- テスト：test/widget_test.dart
- Firebase 設定：firebase.json, .firebaserc, firestore.rules, firestore.indexes.json

##### READMEから得られる補足
- 「アニ名刺」は主にアニメ視聴履歴をFirestoreで管理し、ユーザー同士で交換・共有する機能を持つ。
- 使用技術：Flutter, Firebase

##### システムデザイン図作成のガイドライン
a. 主なコンポーネントを洗い出す
- クライアントアプリ（Flutter）
・UI レイヤ（view）
・ビジネスロジック／状態管理（view_model）
・データモデル（model）
・共通コンポーネント（background_animation, カメラ／QR などプラグイン）
- バックエンド（Firebase）
・Authentication
・Cloud Firestore
・Hosting（Web版用）
・Optional: Cloud Functions（拡張用）
- 外部ライブラリ／サービス
・camera, qr_code_scannerプラグイン
・state_notifier等の状態管理ライブラリ
b. コンポーネント間の関係とデータフロー
- Flutter UI ←→ ViewModel：StateNotifer等で双方向バインド
- ViewModel → Firebase Auth：ログイン／サインアップ処理
- ViewModel → Firestore：ドキュメント CRUD（アニメ一覧、プロフィール、友達リストなど）
- Camera プラグイン → QR スキャン → ViewModel に結果渡し → Firestore へ保存
- Web 版は同じViewModelをFirebase Hosting経由で提供
c. 採用アーキテクチャ／設計原則
- MVVM パターン（view／view_model／model の三層）
- 単一責任の原則：factoryクラスはモデル生成のみ、view_modelは状態管理のみ
- プラットフォーム依存コードとビジネスロジックの分離
d. 主要技術スタック
- Flutter（Dart）
- Firebase Authentication / Firestore / Hosting
- state_notifier（または Riverpod など）
- camera, qr_code_scanner 等のネイティブプラグイン

##### 図に必ず含める要素
- 各コンポーネントの明確なラベル（例：「Flutter Client」「Firestore DB」など）
- 方向付き矢印でデータフロー／依存関係を可視化
- 色分けまたは図形使い分け：
・クライアント層（青系）
・ビジネスロジック層（緑系）
・データ層／外部サービス（オレンジ系）

##### プロジェクト固有の注意点
- マルチプラットフォーム対応：各プラットフォームごとの起動フロー（android/app → MainActivity、ios/Runner → AppDelegate、web/index.html → main.dart）をサブフローで示すと詳細度が増します。
- Firebase 初期化：lib/config/firebase_options.dart に記載された環境別設定もアイコンや注釈で示すとよいでしょう。
- QR コード交換機能：カメラプラグイン→QR解析→Firestore 更新という流れを、コメント付きで明示する

##### 図作成のポイント
- 全体像を俯瞰できるレイアウトを最初に配置し、下層に詳細フローを分割して描く
- 各レイヤーごとに矩形で囲み、レイヤ間インタフェースを太線で強調
- READMEにない内部モジュール（model/factory, view_model）も必ず表示し、責務を注記
- 将来の拡張ポイント（Cloud Functions, Push Notification など）は点線の枠で示し、拡張性をアピール

以上を踏まえ、プロジェクト専用のシステムデザイン図を作成してください。
細部まで分割し、コンポーネントとデータフローを明確に可視化することで、チーム全体の理解共有がスムーズになります。

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Multi-Platform Entry Points
    subgraph "Multi-Platform Entry" 
        direction TB
        Android("Android MainActivity"):::frontend
        iOS("iOS AppDelegate"):::frontend
        Web("Web index.html"):::frontend
        Linux("Linux main.cc"):::frontend
        macOS("macOS MainFlutterWindow"):::frontend
        Windows("Windows main.cpp"):::frontend
    end

    %% Flutter Client
    subgraph "Flutter Client" 
        direction TB

        %% Entry
        subgraph "Entry Points" 
            direction TB
            MainDart("main.dart"):::frontend
            AppDart("app.dart"):::frontend
        end

        %% Configuration
        subgraph "Firebase Init" 
            direction TB
            FirebaseOpts("firebase_options.dart"):::data
            FI_JSON("firebase.json"):::data
            RC(".firebaserc"):::data
            Rules("firestore.rules"):::data
            Indexes("firestore.indexes.json"):::data
        end

        %% Model Layer
        subgraph "Model Layer" 
            direction TB
            AnimeModel("anime_list_model.dart"):::logic
            CounterModel("counter_model.dart"):::logic
            AnimeFactory("anime_list_factory.dart"):::logic
        end

        %% ViewModel Layer
        subgraph "ViewModel Layer" 
            direction TB
            AnimeVM("anime_list_view_model.dart"):::logic
            AuthVM("auth_view_model.dart"):::logic
        end

        %% UI Layer
        subgraph "UI Layer" 
            direction TB
            subgraph Authentication
                AuthPage("auth_page.dart"):::frontend
                SignIn("sign_in_page.dart"):::frontend
                EmailLogin("email_login_page.dart"):::frontend
                EmailSignUp("email_sign_up_page.dart"):::frontend
                AccountSetting("account_setting_page.dart"):::frontend
            end
            HomePage("home_page.dart"):::frontend
            ProfilePage("profile_page.dart"):::frontend
            ProfileEdit("profile_edit_page.dart"):::frontend
            AnimeListPage("anime_list_page.dart"):::frontend
            WatchList("watch_list.dart"):::frontend
            WatchAnime("watch_anime.dart"):::frontend
            SNSPage("SNS_page.dart"):::frontend
            FriendWatch("friend_watch_list_page.dart"):::frontend
            QRPage("qr_page.dart"):::frontend
            ScanData("scandata.dart"):::frontend
            Background("background_animation.dart"):::frontend
        end

    end

    %% External Services
    subgraph "Firebase Services" 
        direction TB
        AuthService("Authentication"):::external
        Firestore("Cloud Firestore"):::external
        Hosting("Hosting (Web)"):::external
        Functions("Cloud Functions (Optional)"):::external,dashed
    end

    subgraph "Plugins & Libraries"
        direction TB
        CameraPlugin("camera & qr_code_scanner"):::external
        StateLib("state_notifier"):::external
    end

    %% Testing
    Test("widget_test.dart"):::external

    %% Data Flows
    MainDart -->|boots App| AppDart
    Android -->|launches| MainDart
    iOS -->|launches| MainDart
    Web -->|loads| MainDart
    Linux -->|launches| MainDart
    macOS -->|launches| MainDart
    Windows -->|launches| MainDart

    AppDart -->|init Firebase| FirebaseOpts
    ApolloFlow1([ ]):::invisible

    %% UI <-> VM
    AuthPage -->|binds| AuthVM
    SignIn -->|binds| AuthVM
    EmailLogin -->|binds| AuthVM
    EmailSignUp -->|binds| AuthVM
    AccountSetting -->|binds| AuthVM
    HomePage -->|binds| AnimeVM
    AnimeListPage -->|binds| AnimeVM
    WatchList -->|binds| AnimeVM
    WatchAnime -->|binds| AnimeVM
    SNSPage -->|binds| AnimeVM
    FriendWatch -->|binds| AnimeVM
    QRPage -->|binds| AnimeVM
    ScanData -->|binds| AnimeVM

    %% VM -> Firebase
    AuthVM -->|login/signup| AuthService
    AnimeVM -->|CRUD| Firestore
    QRPage -->|scan data| CameraPlugin
    CameraPlugin -->|result| AnimeVM
    AnimeVM -->|save scan| Firestore

    %% Model Factory
    AnimeFactory -->|creates| AnimeModel
    AnimeFactory -->|creates| CounterModel

    %% ViewModel uses Model
    AnimeVM -->|uses| AnimeFactory
    AuthVM -->|uses| AnimeFactory

    %% Hosting for Web
    Web -->|deployed on| Hosting

    %% Testing
    Test -->|tests| AppDart
    Test -->|tests| AuthVM
    Test -->|tests| AnimeVM

    %% Click Events
    click MainDart "https://github.com/kou050223/animeishi/blob/main/lib/main.dart"
    click AppDart "https://github.com/kou050223/animeishi/blob/main/lib/app.dart"
    click FirebaseOpts "https://github.com/kou050223/animeishi/blob/main/lib/config/firebase_options.dart"
    click FI_JSON "https://github.com/kou050223/animeishi/blob/main/firebase.json"
    click RC "https://github.com/kou050223/animeishi/blob/main/.firebaserc"
    click Rules "https://github.com/kou050223/animeishi/blob/main/firestore.rules"
    click Indexes "https://github.com/kou050223/animeishi/blob/main/firestore.indexes.json"
    click AnimeModel "https://github.com/kou050223/animeishi/blob/main/lib/model/anime_list_model.dart"
    click CounterModel "https://github.com/kou050223/animeishi/blob/main/lib/model/counter_model.dart"
    click AnimeFactory "https://github.com/kou050223/animeishi/blob/main/lib/model/factory/anime_list_factory.dart"
    click AnimeVM "https://github.com/kou050223/animeishi/blob/main/lib/ui/animes/view_model/anime_list_view_model.dart"
    click AuthVM "https://github.com/kou050223/animeishi/blob/main/lib/ui/auth/view_model/auth_view_model.dart"
    click AuthPage "https://github.com/kou050223/animeishi/blob/main/lib/ui/auth/view/auth_page.dart"
    click SignIn "https://github.com/kou050223/animeishi/blob/main/lib/ui/auth/view/sign_in_page.dart"
    click EmailLogin "https://github.com/kou050223/animeishi/blob/main/lib/ui/auth/view/email_login_page.dart"
    click EmailSignUp "https://github.com/kou050223/animeishi/blob/main/lib/ui/auth/view/email_sign_up_page.dart"
    click AccountSetting "https://github.com/kou050223/animeishi/blob/main/lib/ui/auth/view/account_setting_page.dart"
    click HomePage "https://github.com/kou050223/animeishi/blob/main/lib/ui/home/view/home_page.dart"
    click ProfilePage "https://github.com/kou050223/animeishi/blob/main/lib/ui/profile/view/profile_page.dart"
    click ProfileEdit "https://github.com/kou050223/animeishi/blob/main/lib/ui/profile/view/profile_edit_page.dart"
    click AnimeListPage "https://github.com/kou050223/animeishi/blob/main/lib/ui/animes/view/anime_list_page.dart"
    click WatchList "https://github.com/kou050223/animeishi/blob/main/lib/ui/watch/view/watch_list.dart"
    click WatchAnime "https://github.com/kou050223/animeishi/blob/main/lib/ui/watch/view/watch_anime.dart"
    click SNSPage "https://github.com/kou050223/animeishi/blob/main/lib/ui/SNS/view/SNS_page.dart"
    click FriendWatch "https://github.com/kou050223/animeishi/blob/main/lib/ui/SNS/view/friend_watch_list_page.dart"
    click QRPage "https://github.com/kou050223/animeishi/blob/main/lib/ui/camera/view/qr_page.dart"
    click ScanData "https://github.com/kou050223/animeishi/blob/main/lib/ui/camera/view/scandata.dart"
    click Background "https://github.com/kou050223/animeishi/blob/main/lib/ui/components/background_animation.dart"
    click Test "https://github.com/kou050223/animeishi/blob/main/test/widget_test.dart"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#00838F,color:#004D40
    classDef logic fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef external fill:#FFF3E0,stroke:#EF6C00,color:#E65100
    classDef invisible fill:none,stroke:none;color:none
```
