# nqkhanh020903/caythuocdongyvietnam architecture

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

- Interactive diagram: https://gitdiagram.com/nqkhanh020903/caythuocdongyvietnam
- Repository: https://github.com/nqkhanh020903/caythuocdongyvietnam

## Overview

##### Project type and purpose
- This is a native Android mobile application (“CayThuocDongYVietNam”) for browsing, searching, and saving information about Vietnamese traditional medicinal plants and recipes.
- It’s a full-client app built in Java/Kotlin in Android Studio, relying on Firebase as its back-end for authentication, data storage, and potentially other services (analytics, storage).

##### File structure
- Top-level gradle files and wrappers show a standard Android/Gradle project.
- `app/src/main/java/com/example/doanchuyennghanh/Activity` and `Fragment`: UI layer implemented with Activities and Fragments.
- `.../Adapter`: RecyclerView adapters providing the glue between domain models and UI lists or pagers.
- `.../Domain`: Plain-old Java objects (models) for Herb, Post, Comment, User, etc.
- `res/`: standard resource folders (layouts, drawables, menus, values) providing XML UIs, styling, and assets.
- No custom server code; external integration is with Firebase (implied by `google-services.json` and gradle dependencies).

##### README
- Confirms purpose (lookup of plants, details, user favorites).
- Lists features: search by name or disease, detailed views, user authentication & favorites.
- Technologies: Android Studio, Firebase, Java.

##### Detailed capture of essential architecture
- Sketch a vertical layered view for the mobile client:
Top: Activities & Fragments
Middle: Adapters & Domain Models
Bottom: Data Access / Repository interfaces
- Repository layer to each Firebase service.
- Common endpoints or collection names (e.g., `/herbs`, `/posts`, `/users/{uid}/favorites`).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client Layers
    subgraph "Android Mobile Client"
        subgraph "Presentation/UI Layer"
            Activities["Activities & Fragments"]:::ui
            Fragments["Fragments (UI pages)"]:::ui
        end
        subgraph "View Binding"
            Adapters["RecyclerView/ViewPager Adapters"]:::mobile
        end
        subgraph "Domain Models"
            Domain["Domain Objects (Herb, Post, User, etc.)"]:::domain
        end
        subgraph "Themed UI"
            ThemedUI["UI Theming (Jetpack Compose)"]:::ui
        end
        subgraph "Resources"
            Resources["Android Resources (res/)"]:::mobile
        end
        subgraph "Testing"
            InstrumentedTests["Instrumented UI Tests"]:::test
            UnitTests["Unit Tests"]:::test
        end
        subgraph "Build Configuration"
            GradleWrapper["Gradle & Wrapper"]:::config
        end
        subgraph "Data Access Layer"
            Repository["Data Access / Repository"]:::data
            FirebaseConfig["Firebase Config (google-services.json)"]:::data
            FirebaseSDK["Firebase SDK Init (build.gradle.kts)"]:::data
        end
    end

    %% Firebase Backend
    subgraph "Firebase Backend"
        Auth["Firebase Authentication"]:::external
        Database["Firestore/Realtime Database"]:::external
        Storage["Firebase Storage"]:::external
    end

    %% Data Flows
    Activities -->|uses| Adapters
    Fragments -->|uses| Adapters
    Adapters -->|binds| Domain
    Domain -->|requests| Repository
    Repository -->|"AUTH request"| Auth
    Repository -->|"DATA READ/WRITE"| Database
    Repository -->|"STORAGE operations"| Storage
    Auth -->|"token"| Repository
    Database -->|"sync updates"| Repository
    Repository -->|returns data| Domain
    Domain -->|renders| Adapters
    Adapters -->|updates UI| Fragments
    Adapters -->|updates UI| Activities

    %% Testing & Build Config connections
    InstrumentedTests -.-> Activities
    UnitTests -.-> Domain
    GradleWrapper -.-> FirebaseSDK
    GradleWrapper -.-> Repository

    %% Click Events
    click Activities "https://github.com/nqkhanh020903/caythuocdongyvietnam/tree/master/app/src/main/java/com/example/doanchuyennghanh/Activity"
    click Fragments "https://github.com/nqkhanh020903/caythuocdongyvietnam/tree/master/app/src/main/java/com/example/doanchuyennghanh/Fragment"
    click Adapters "https://github.com/nqkhanh020903/caythuocdongyvietnam/tree/master/app/src/main/java/com/example/doanchuyennghanh/Adapter"
    click Domain "https://github.com/nqkhanh020903/caythuocdongyvietnam/tree/master/app/src/main/java/com/example/doanchuyennghanh/Domain"
    click ThemedUI "https://github.com/nqkhanh020903/caythuocdongyvietnam/tree/master/app/src/main/java/com/example/doanchuyennghanh/ui/theme"
    click Resources "https://github.com/nqkhanh020903/caythuocdongyvietnam/tree/master/app/src/main/res"
    click FirebaseConfig "https://github.com/nqkhanh020903/caythuocdongyvietnam/blob/master/app/google-services.json"
    click FirebaseSDK "https://github.com/nqkhanh020903/caythuocdongyvietnam/blob/master/app/build.gradle.kts"
    click InstrumentedTests "https://github.com/nqkhanh020903/caythuocdongyvietnam/blob/master/app/src/androidTest/java/com/example/doanchuyennghanh/ExampleInstrumentedTest.kt"
    click UnitTests "https://github.com/nqkhanh020903/caythuocdongyvietnam/blob/master/app/src/test/java/com/example/doanchuyennghanh/ExampleUnitTest.kt"

    %% Styles
    classDef ui fill:#E3F2FD,stroke:#90CAF9,stroke-width:1px
    classDef mobile fill:#BBDEFB,stroke:#64B5F6,stroke-width:1px
    classDef domain fill:#C8E6C9,stroke:#81C784,stroke-width:1px
    classDef data fill:#FFF9C4,stroke:#FFF176,stroke-width:1px
    classDef external fill:#FFCDD2,stroke:#E57373,stroke-width:1px
    classDef test fill:#F0F4C3,stroke:#E6EE9C,stroke-width:1px
    classDef config fill:#D1C4E9,stroke:#B39DDB,stroke-width:1px
```
