# nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain architecture

> Architecture diagram of the GitHub repository nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain
- Repository: https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain

## Overview

##### Major Components
- Mobile Apps: There are two main mobile applications – one for admin (mobile/admin) and one for client users (mobile/client). They share a similar folder structure with assets, components, hooks, etc. (likely built using a React Native/Web framework).
- Web Applications:
– Web Admin: Under web/admin1, you have an administrative interface with its own React/Vite-based application.
– Web Client: There is also a web/client directory, likely representing the customer-facing web interface.
- Backend API: Located under web/backend, this is the central Node.js/TypeScript service, implementing REST (or similar) endpoints. It is composed of controllers, models, routes, services, and a modular structure with many business domains such as account, food, order, cart, reviews, and even integrations like RabbitMQ and blockchain.
- External & Supporting Services:
– Database: There are several DB-config and migration files (for example, ormconfig.json and migrations) indicating a relational database.
– Caching: Note the RedisCache module under “cache”.
– Messaging & Integration: RabbitMQ scripts for sending/receiving messages are present, and there are blockchain service integrations.
– Docker & Environment Tools: Dockerfiles in several modules and a docker-compose.yml indicate containerization and deployment configuration.

##### Relationships and Interactions
- The mobile and web front-ends (admin and client) are consumers of the backend API. They exchange data via RESTful endpoints.
- The backend itself is separated into multiple modules (using a modular design pattern) such as account, food, cart, etc., each comprised of controllers, models, routes, services, and utilities.
- The backend communicates with a database for persistence. It may also interact with external services like a Redis cache for performance, RabbitMQ for asynchronous processing, and blockchain interfaces.

##### Architectural Patterns
- Separation of Concerns: There is a clear separation between presentation layers (mobile/web apps) and business logic (backend).
- Modular Architecture: The “backend” is split into many modules, each handling specific business domains.
- API Gateway/Service Communication: The front-end applications (mobile and web) communicate via APIs hosted in the backend.
- Containerization and CI/CD: The use of Dockerfiles and docker-compose indicates an infrastructure managed with containers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Components
    subgraph "Frontends"
        direction TB
        MobileAdmin["Mobile Admin App"]:::mobile
        MobileClient["Mobile Client App"]:::mobile
        WebAdmin["Web Admin App"]:::web
        WebClient["Web Client App"]:::web
    end

    %% Backend API and Modules
    subgraph "Backend API"
        direction TB
        API["Backend API Services"]:::backend
        subgraph "Backend Modules"
            direction TB
            DB["Database Service"]:::database
            Cache["Redis Cache"]:::cache
            MQ["RabbitMQ Messaging"]:::messaging
            BC["Blockchain Integration"]:::blockchain
        end
    end

    %% Deployment and Containerization
    subgraph "Deployment & Containerization"
        direction TB
        DeployBackend["Backend Dockerfile"]:::deploy
        Compose["Docker Compose"]:::deploy
        DeployWebAdmin["Web Admin Dockerfile"]:::deploy
    end

    %% Relationships from Frontends to Backend API
    MobileAdmin -->|"REST"| API
    MobileClient -->|"REST"| API
    WebAdmin -->|"REST"| API
    WebClient -->|"REST"| API

    %% Relationships from Backend API to its Modules
    API -->|"uses"| DB
    API -->|"uses"| Cache
    API -->|"uses"| MQ
    API -->|"uses"| BC

    %% Indicate containerization connections
    API -->|"containerized"| Compose
    WebAdmin -->|"containerized"| DeployWebAdmin

    %% Click Events
    click MobileAdmin "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/mobile/admin"
    click MobileClient "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/mobile/client"
    click WebAdmin "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/admin1"
    click WebClient "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/client"
    click API "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/backend"
    click DB "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/backend/config"
    click Cache "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/blob/master/web/backend/cache/RedisCache.ts"
    click MQ "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/backend/rabbitmq"
    click BC "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/blob/master/web/backend/services/blockchain.ts"
    click DeployBackend "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/backend/Dockerfile"
    click Compose "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/blob/master/web/backend/docker-compose.yml"
    click DeployWebAdmin "https://github.com/nguyennhuty/yfood-react-nodejs-mongoose-graphql-microservice-firebase-blockchain/tree/master/web/admin1/Dockerfile"

    %% Styles
    classDef mobile fill:#FFC107,stroke:#333,stroke-width:2px;
    classDef web fill:#03A9F4,stroke:#333,stroke-width:2px;
    classDef backend fill:#4CAF50,stroke:#333,stroke-width:2px,color:#fff;
    classDef database fill:#FF5722,stroke:#333,stroke-width:2px,color:#fff;
    classDef cache fill:#FF9800,stroke:#333,stroke-width:2px,color:#fff;
    classDef messaging fill:#9C27B0,stroke:#333,stroke-width:2px,color:#fff;
    classDef blockchain fill:#607D8B,stroke:#333,stroke-width:2px,color:#fff;
    classDef deploy fill:#009688,stroke:#333,stroke-width:2px,color:#fff;
```
