# tuan2210/n10_kltn_taskobey architecture

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

- Interactive diagram: https://gitdiagram.com/tuan2210/n10_kltn_taskobey
- Repository: https://github.com/tuan2210/n10_kltn_taskobey

## Overview

##### Project Type and Purpose
- This is a full-stack mobile application targeted for Android devices.
- The application helps users manage tasks and time with functionalities such as CRUD operations on tasks, schedule views, and statistics.
- The backend server (built with Node.js/Express) interacts with a Cloud MongoDB database and uses JWT and Firebase for security and OTP verification.
- The mobile client is built using React Native, likely managed via Expo for Android deployment.

##### Analyzing the File Structure
- There are two major parts:
- “server”: Contains Node.js code, with directories for controllers, models, and routes. This indicates an MVC pattern for the backend API.
▪ Controllers (authController.js, taskController.js, etc.) handle the business logic.
▪ Models (Schedule.js, Task.js, etc.) represent the MongoDB data schemas.
▪ Routes (auth.js, task.js, user.js) define API endpoints that the frontend interacts with.
- “task_obey”: Contains the client-side code built with React Native (Expo).
▪ The “src” folder includes various components (screens like CalendarScreen, CreateTaskScreen, etc.), Redux state management files, and navigation routes.
▪ Assets directory holds sound effects and other media used in the app.
- Config files like package.json at different levels, babel.config.js, and others help manage dependencies and build processes.

##### README Insights
- The README highlights key functions: CRUD operations, task scheduling and statistics, phone verification with OTP, etc.
- It documents the use of MongoDB (hosted on Cloud MongoDB), Express in Node.js, and Firebase for phone number verification.
- The client, developed with React Native, runs on Android and is deployed through Expo.
- There is an indication that the server is deployed (e.g., on Render) and the mobile app through the Expo app.

a. Main Components:
- Mobile Client (React Native Application): Contains UI components, navigation (screens), Redux state management, and API request modules.
- Backend API Server (Node.js/Express): Contains controllers, models, and routes. Responsible for authentication (JWT), task operations, and user management.
- Database (Cloud MongoDB): Stores user data, tasks, schedules, etc.
- External Services:
- Firebase for phone verification (OTP).
- Possibly third-party services for notifications (inferred from sound assets) or analytics.

b. Relationships and Interactions:
- The Mobile Client makes API calls (using Redux and apiRequest modules) to the Backend API Server.
- The API Server validates requests (via controllers) and interacts with the MongoDB database to store/retrieve data.
- Authentication flows use JWT tokens to secure endpoints, and integration with Firebase ensures users verify their phone numbers.

c. Architectural Patterns and Design Principles:
- MVC Pattern in the server-side: Models, Views (data/response formatting), and Controllers managing business logic.
- Separation of concerns: Frontend (presentation logic and state management via Redux in React Native) is clearly separated from the Backend (API logic, routing, and database interaction).
- RESTful API design for clear, stateless communication.
- Use of JWT for secure authentication, and integration with Firebase as an external identity verification service.

d. Technologies, Frameworks, and Libraries:
- Backend: Node.js, Express, MongoDB, JWT, and likely Mongoose (for MongoDB interaction).
- Frontend: JavaScript, React Native, Expo, Redux for state management.
- External: Firebase for OTP phone number verification services.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Mobile Client Section
    MC["Mobile Client (React Native/Expo)"]:::client
    UI["UI Components & Screens"]:::client
    RS["Redux State Management"]:::client
    AR["API Request Modules"]:::client

    MC -->|"calls"| UI
    UI -->|"updates"| RS
    RS -->|"triggers"| AR

    %% Connection from Mobile Client to Backend API Server
    AR -->|"API_calls"| RT

    %% Backend Server Section
    Server["Backend API Server (Node.js/Express)"]:::server
    Server --> RT

    RT["Routes"]:::server
    RT -->|"routes_to"| CT

    CT["Controllers"]:::server
    CT -->|"handles"| MD

    MD["Models"]:::server
    MD -->|"CRUD_ops"| CloudDB["Cloud MongoDB"]:::database

    %% External Service Connection
    CT -->|"OTP_Verification"| Firebase["Firebase"]:::external

    %% Click Events
    click MC "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/task_obey/"
    click UI "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/task_obey/src/components/screens/"
    click RS "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/task_obey/src/redux/"
    click AR "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/task_obey/src/redux/apiRequest/"
    click Server "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/server/"
    click RT "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/server/routes/"
    click CT "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/server/controllers/"
    click MD "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/server/models/"
    click Firebase "https://github.com/tuan2210/n10_kltn_taskobey/blob/master/task_obey/src/config/firebase-config.js"
    click CloudDB "https://github.com/tuan2210/n10_kltn_taskobey/tree/master/server/models/"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef server fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
