# domylan/my-pets architecture

> Architecture diagram of the GitHub repository domylan/my-pets, 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/domylan/my-pets
- Repository: https://github.com/domylan/my-pets

## Overview

##### The mobile client built with Flutter (located in the “client” directory).
2. The admin web panel built with a modern JavaScript framework (in the “admin” directory, using React – note the .jsx files, SCSS styling, and organized component/pages).

Even though the backend folder isn’t clearly visible in the file tree, the README instructs running a “backend” process (via yarn commands) suggesting there is or will be a separate Node.js backend that exposes API endpoints. In addition, there is integration with third-party services such as the VNPAY payment gateway to handle secure transactions.

##### Main system components
- Mobile Client (Flutter): Represents the consumer-facing mobile application.
- Admin Panel (React): Acts as a web-based control interface for pet centers and management.
- Backend/API Server: Although not explicitly shown as a separate folder, treat this as the central server that handles business logic, database interactions, authentication, and third-party integrations.
- External Services: VNPAY (for secure payment processing) and any notification or social networking services the system may use.
- (Implicit) Database & Storage: This layer (not fully shown in files) would handle data for users, pets, orders, and other transactional details.

##### Relationships and interactions
- The Mobile Client and the Admin Panel both communicate with the Backend Server via RESTful APIs.
- The Backend Server handles authentication (possibly using token management as seen in admin/src/services/token.js) and business logic for pet transactions, user profile management, posts, notifications, etc.
- External integrations such as VNPAY are called from the Backend when processing payments.
- The Admin Panel also includes client-side state management (using Redux under admin/src/redux) and service layers (in admin/src/services/apis) for communication with the Backend.
- The Flutter client organizes its code into screens, services, and models which define the mobile UI, logic, and data structures; it similarly communicates with the backend.

##### Important architectural patterns
- Separation of Concerns: There is a clear separation between the front-end layers (mobile UI and admin web UI) and the centralized backend.
- MVC/MVVM-like organization: The Flutter client segregates UI (screens) from models and services; the admin panel organizes components, pages, routes, and Redux state.
- API Driven Architecture: Both front ends consume backend APIs. The services directories in both projects encapsulate REST API calls.
- Modular and Scalable: The detailed folder structures (for components, assets, routes, and services) indicate that the system is designed to be easily extended through clearly defined modules.

##### Technologies and frameworks
- Flutter & Dart for the client mobile application.
- React (with JSX) alongside Redux for the admin panel.
- Node.js (implied by yarn commands and npm scripts) for the backend server.
- SCSS for styling on the admin web interface.
- Third-party integrations like VNPAY for payments.
- Additional libraries for notifications, post and user management, and media (video/image uploads) in both client and admin.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Clients
    MC["Mobile Client (Flutter)"]:::mobile
    AP["Admin Panel (React)"]:::admin

    %% Backend/API Server Subgraph
    subgraph "Backend/API Server"
        BE["Central Server (Node.js)"]:::backend
        TS["Token Service"]:::backend
        API["Account API Service"]:::backend
        BE -->|"manages"| TS
        BE -->|"manages"| API
    end

    %% External and Database Components
    EX["External Services (VNPAY Payment Gateway)"]:::external
    DB["Database (Storage)"]:::database

    %% Connections from Frontend to Backend
    MC -->|"REST_API"| BE
    AP -->|"REST_API"| BE

    %% Connections from Backend to External Services and Database
    BE -->|"calls"| EX
    BE -->|"queries"| DB

    %% Click Events
    click MC "https://github.com/domylan/my-pets/tree/main/client"
    click AP "https://github.com/domylan/my-pets/tree/main/admin"
    click TS "https://github.com/domylan/my-pets/blob/main/admin/src/services/token.js"
    click API "https://github.com/domylan/my-pets/blob/main/admin/src/services/apis/accountAPI/accountAPI.js"
    click EX "https://github.com/domylan/my-pets/blob/main/client/lib/screens/payment_VNPAY.dart"

    %% Styles
    classDef mobile fill:#add8e6,stroke:#000,stroke-width:2px
    classDef admin fill:#90ee90,stroke:#000,stroke-width:2px
    classDef backend fill:#ffcc99,stroke:#000,stroke-width:2px
    classDef external fill:#d8bfd8,stroke:#000,stroke-width:2px
    classDef database fill:#f4a460,stroke:#000,stroke-width:2px
```
