# dat0309/manga-project architecture

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

- Interactive diagram: https://gitdiagram.com/dat0309/manga-project
- Repository: https://github.com/dat0309/manga-project

## Overview

##### Project Type and Purpose
- This is a native Android mobile application (“MangarReader”) whose primary purpose is to let users browse, read, rate, and comment on manga.
- There is no custom backend code in the repo; the app relies on Firebase (Realtime Database, Storage, Auth) and third-party SDKs (Google Sign-In, Facebook Login) for all server-side functionality.

##### High-Level Architectural Components
a. Android Client
- UI Layer: Activities (in package `viewmodel/`) + XML layouts + Adapters for RecyclerViews.
- Data Layer: Plain-old-Java model classes (`model/`) representing BannerManga, Manga, Chapter, User, Rating, etc.
- Utility Layer: `AppUtil`, `BookFlipPageTransformer`, plus resource files (drawables, fonts, animations).
- Third-Party Libraries: Glide (image loading), Android-SpinKit (loading indicators), PhotoView/EasyFlipView (image interactions), SpotsDialog, CircleImageView.
b. External Services
- Firebase Auth: user sign-in, Google & Facebook integration.
- Firebase Realtime Database: manga metadata, chapters, comments, ratings.
- Firebase Storage: storing and retrieving chapter images.
- Google Play Services Auth & Facebook SDK: social login flows.
c. Local Resources
- Raw JSON (`readabook.json`) for offline data or initial seed.
- UI assets (drawables, layouts, strings, themes).

##### Relationships and Data Flow
1. User opens app → `SplashScreen` → navigates to `LoginAct` / `RegisterAct`.
2. On login/register, Activity invokes Firebase Auth SDK; successful callback returns a FirebaseUser.
3. After auth, Activities (e.g., `MangaAct`, `CategoryAct`, `FavoriteAct`, `MangaDetailsAct`) query Realtime Database via the Firebase SDK.
4. Data snapshots are mapped into model objects.
5. Adapters (e.g., `MangaAdapter`, `ChapterAdapter`, `CommentAdapter`) bind model data to RecyclerView items.
6. Image URLs are handed to Glide/PhotoView/EasyFlipView to load and render chapter pages.
7. User actions (rating, commenting, favoriting) write back to Realtime Database and/or Storage.

##### Architectural Patterns and Design Principles
- Layered Architecture:
- Presentation (Activities & Adapters)
- Domain/Data (Model classes + Firebase SDK calls)
- Utility & Resources (common functions, animations)
- Separation of Concerns: UI logic lives in Activities, data-binding in Adapters, raw data definition in Model classes, Firebase interactions isolated to where they are invoked.

##### Final Checklist
- Separate the system into at least these components: UI, Business Logic, Data Layer, External Services, Local Resources.
- Names of critical libraries and SDKs where they integrate.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Android UI Layer"
        UI_Activities["Activities"]:::ui
        UI_Layouts["XML Layouts"]:::ui
        UI_Adapters["Adapters"]:::ui
    end

    subgraph "Business Logic Layer"
        Business["Activity Controllers"]:::biz
    end

    subgraph "Data Layer"
        Models["Model Classes"]:::data
        FirebaseSDK["Firebase SDK"]:::data
    end

    subgraph "Utilities & Resources"
        Util["Utilities"]:::res
        RawJSON["Local JSON"]:::res
        Drawables["Drawables & Fonts"]:::res
        Anims["Animations"]:::res
        Config["google-services.json"]:::res
    end

    subgraph "External Services"
        AuthService["Firebase Auth"]:::svc
        RealtimeDB["Firebase Realtime DB"]:::svc
        Storage["Firebase Storage"]:::svc
        GoogleAuth["Google Play Services Auth"]:::svc
        FacebookSDK["Facebook SDK"]:::svc
    end

    UI_Layouts --> UI_Activities
    UI_Activities --> Business
    UI_Adapters --> UI_Activities

    Business --> FirebaseSDK
    FirebaseSDK --> AuthService
    FirebaseSDK --> RealtimeDB
    FirebaseSDK --> Storage

    AuthService -.-> GoogleAuth
    AuthService -.-> FacebookSDK

    RealtimeDB --> Models
    Storage --> Models

    UI_Activities -->|GET Data via FirebaseSDK| FirebaseSDK
    FirebaseSDK -->|"snapshot ->"| Models
    Models --> UI_Adapters
    UI_Adapters --> UI_Activities

    UI_Activities -->|Image URLs| Storage
    Storage -->|"images"| UI_Activities

    Util --> UI_Activities
    RawJSON --> Models

    click UI_Activities "https://github.com/dat0309/manga-project/tree/main/MangarReader/app/src/main/java/com/dinhtrongdat/mangareaderapp/viewmodel"
    click UI_Layouts "https://github.com/dat0309/manga-project/tree/main/MangarReader/app/src/main/res/layout"
    click UI_Adapters "https://github.com/dat0309/manga-project/tree/main/MangarReader/app/src/main/java/com/dinhtrongdat/mangareaderapp/adapter"
    click Models "https://github.com/dat0309/manga-project/tree/main/MangarReader/app/src/main/java/com/dinhtrongdat/mangareaderapp/model"
    click Util "https://github.com/dat0309/manga-project/blob/main/MangarReader/app/src/main/java/com/dinhtrongdat/mangareaderapp/AppUtil.java"
    click RawJSON "https://github.com/dat0309/manga-project/blob/main/MangarReader/app/src/main/res/raw/readabook.json"
    click Drawables "https://github.com/dat0309/manga-project/tree/main/MangarReader/app/src/main/res/drawable"
    click Anims "https://github.com/dat0309/manga-project/tree/main/MangarReader/app/src/main/res/anim"
    click Config "https://github.com/dat0309/manga-project/blob/main/MangarReader/app/google-services.json"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef biz fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#FFFACD,stroke:#333,stroke-width:1px
    classDef svc fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef res fill:#D3D3D3,stroke:#333,stroke-width:1px
```
