# nguyen1976/cse702025-n04-nhom-10 architecture

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

- Interactive diagram: https://gitdiagram.com/nguyen1976/cse702025-n04-nhom-10
- Repository: https://github.com/nguyen1976/cse702025-n04-nhom-10

## Overview

##### Project type and purpose
- This is a full-stack task management application.
- Frontend: Native Android app (“Taskify”) built with Kotlin, MVVM, Repository, DI (Hilt/Koin) patterns.
- Backend: Node.js/Express REST API providing user authentication (JWT) and task CRUD.
- Database (implied by .env config and Mongoose-style models): stores users and tasks.
- A Postman collection in `documents` confirms the REST endpoints.

##### Main components
a. Android Mobile Client
– Presentation layer (Activities, Composables in `presentation/…`)
– ViewModels (`data/viewmodel`)
– Repositories (`data/repository`)
– Data sources
- Remote: Retrofit interfaces (`data/remote/*.kt`) + OkHttp interceptors (`AuthInterceptor`, `TokenExpirationInterceptor`)
- Local: DataStore for tokens and preferences (`data/local`)
– Domain models (`domain/model`)
– DI modules (`di/AppModule.kt`)
b. Backend API Server
– Entry point: `server.js`
– Configuration: env loader (`config/environment.js`)
– Routing layers (`routes/v1`, `routes/v2`)
– Controllers (`controllers/*Controller.js`)
– Services (`services/*Service.js`)
– Data models (`models/*Model.js`)
– Middleware: authentication, error handling
– JWT provider (`providers/JwtProvider.js`)
– Utilities: formatters, validators, ApiError
c. Database
– Collections / tables: Users, Tasks
– Managed via ORM/ODM in `models/`
d. External/development tools
– Postman (collection file)
– Build tools: Gradle (Android), npm/Node (backend)

##### Relationships and data flow
1. User interacts with Android UI → triggers ViewModel
2. ViewModel calls Repository → decides between remote/local
3. Remote calls go through Retrofit → OkHttp Interceptors → HTTP request to Backend
4. Backend receives request → Router → Controller → Service → Model (DB) → Service → Controller → JSON response
5. Response passes back through network interceptor to Repository → ViewModel → UI
6. Local data (tokens/preferences) go through DataStore

##### Architectural patterns & design principles
- Frontend uses MVVM, Repository, DI, separation of concerns.
- Backend uses layered architecture: Routing → Controller → Service → Data Model.
- RESTful design, stateless JWT authentication.
- Error handling via centralized middleware.

##### Detail orientation
- Every folder/layer sufficiently: e.g., interceptors in the Android network layer, middleware in the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client Layer
    subgraph "Mobile Client"
        UI["UI (Activities/Composables)"]:::mobile
        VM["ViewModel"]:::mobile
        Repo["Repository"]:::mobile
        Remote["Remote DataSource (Retrofit Interfaces)"]:::mobile
        Interceptors["Network Interceptors"]:::mobile
        LocalDS["Local DataSource (DataStore)"]:::mobile
        Domain["Domain Models"]:::mobile
        DI["DI Module"]:::mobile
    end

    %% Backend API Layer
    subgraph "Backend API"
        Entry["Entry Point (server.js)"]:::api
        Config["Environment Config"]:::api
        Middleware["Middleware"]:::api
        Routes1["Routes v1"]:::api
        Routes2["Routes v2"]:::api
        Controllers["Controllers"]:::api
        Services["Services"]:::api
        Models["Data Models"]:::api
        JWT["JWT Provider"]:::api
        Utils["Utilities"]:::api
        Validations["Validations"]:::api
    end

    %% Database Layer
    subgraph "Database"
        DB["Database (Users, Tasks)"]:::db
    end

    %% External Tools
    subgraph "External/Development Tools"
        Postman["Postman Collection"]:::external
        Gradle["Android Gradle Scripts"]:::external
        Npm["Backend npm"]:::external
    end

    %% Data Flow
    UI --> VM
    VM --> Repo
    Repo --> Remote
    Repo --> LocalDS
    Remote -->|HTTP Request| Entry
    Entry -->|HTTP Response| Remote
    UI --> Domain
    VM --> Domain
    DI --> VM
    DI --> Repo
    DI --> Remote
    DI --> LocalDS
    DI --> Domain

    %% Backend Flow
    Entry --> Config
    Entry --> Middleware
    Entry --> Routes1
    Entry --> Routes2
    Routes1 --> Controllers
    Routes2 --> Controllers
    Controllers --> Services
    Services --> Models
    Models --> DB
    Services --> JWT
    Services --> Utils
    Services --> Validations
    JWT --> Middleware
    Middleware --> Controllers
    Utils --> Controllers
    Validations --> Controllers
    Postman --> Entry
    Gradle --> UI
    Npm --> Entry

    %% Click Events
    click UI "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/presentation"
    click VM "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/data/viewmodel"
    click Repo "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/data/repository"
    click Remote "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/data/remote"
    click Interceptors "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/data/network"
    click LocalDS "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/data/local"
    click Domain "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/frontend/app/src/main/java/com/example/taskify/domain/model"
    click DI "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/frontend/app/src/main/java/com/example/taskify/di/AppModule.kt"
    click Entry "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/backend/src/server.js"
    click Config "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/backend/src/config/environtment.js"
    click Routes1 "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/routes/v1"
    click Routes2 "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/routes/v2"
    click Controllers "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/controllers"
    click Services "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/services"
    click Models "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/models"
    click Middleware "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/middlewares"
    click JWT "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/backend/src/providers/JwtProvider.js"
    click Utils "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/utils"
    click Validations "https://github.com/nguyen1976/cse702025-n04-nhom-10/tree/main/backend/src/validations"
    click Postman "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/documents/Note_App_KTPM.postman_collection.json"
    click Gradle "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/frontend/build.gradle.kts"
    click Npm "https://github.com/nguyen1976/cse702025-n04-nhom-10/blob/main/backend/package.json"

    %% Styles
    classDef mobile fill:#bbdefb,stroke:#2196f3,color:#000
    classDef api fill:#c8e6c9,stroke:#4caf50,color:#000
    classDef db fill:#ffe0b2,stroke:#fb8c00,color:#000
    classDef external fill:#eeeeee,stroke:#9e9e9e,color:#000
```
