# healing-community/fe architecture

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

- Interactive diagram: https://gitdiagram.com/healing-community/fe
- Repository: https://github.com/healing-community/fe

## Overview

##### And Label Key Components
- Frontend Service:
– Built with Next.js (observable in the “src/app” structure with distinct routes for public content, registered users, admins, experts, moderators, chat, music, etc.).
– Incorporates state management libraries (TanStack Query, Zustand) and interactive UI components.
- Backend Services:
– Microservices oriented backend built using .NET and Python following Clean Architecture and CQRS principles.
– Services to handle authentication, account management, expert consultations, payment processing, content moderation, and reporting.
– API endpoints for authentication, chat, and other functionalities are visible under “src/app/api” and “src/apiRequests.”
- Databases & Persistence Layers:
– Make a note to illustrate how these database systems play distinct roles (e.g., relational storage versus caching and real-time data).
- Messaging & Asynchronous Communication:
– RabbitMQ is used for communication between microservices.
– Also include Websocket and Webhook integrations to indicate real-time interaction and notifications.
- External Integrations and Third-Party Services:
– Incorporate external services like AI Gemini (for content moderation) and Jitsi Meet (for virtual consultations).
– Cloud hosting environments like GKE (Google Kubernetes Engine) and Railway should be shown as part of the deployment environment.
- Containerization & Deployment:
– Docker and Kubernetes are used to containerize and orchestrate the application across a secure deployment pipeline.

##### Relationships and Interactions
– User interactions in the front-end (Next.js) instantly communicate with backend services via API endpoints (GraphQL/REST endpoints).
– Backend services interact with databases (read/write flows) and RabbitMQ (for asynchronous processing or inter-service communication).
– Websockets provide real-time communication from backend and between clients.
- Integration points where third-party services (payment gateways, video conferencing, AI moderation) interact with the core services.

##### Architectural Patterns and Design Principles
- Microservices & Clean Architecture:
– Illustrate separate service modules for authentication, expert management, content moderation, and payment processing.
- CQRS:
– If applicable, show separation between command (write) and query (read) flows.
- Containerization:
– Emphasize that each service can be containerized with Docker; then orchestrated using Kubernetes.

##### Additional Notes
- Do not oversimplify – strive to break down the project into as many distinct components as possible to reflect all major functionalities such as chat, group management, user and moderator workflows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Next.js Frontend (Public,User,Admin,Expert,Moderator,Chat,Music)"]:::frontend
        FE_SM["State Management (TanStack Query, Zustand)"]:::frontend
        FE_UI["Interactive UI Components"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        API_Routes["API Endpoints"]:::backend
        API_Req["API Endpoints"]:::backend
    end

    %% Backend Services
    subgraph "Backend Services"
        Auth["Authentication Service (.NET)"]:::backend
        Acc["Account Management Service (.NET)"]:::backend
        Consult["Expert Consultation Service (.NET/Python)"]:::backend
        Payment["Payment Processing Service (Python)"]:::backend
        Moderation["Content Moderation Service (Python)"]:::backend
        Chat["Chat Service"]:::backend
    end

    %% Databases & Persistence Layer
    subgraph "Databases & Persistence"
        Postgres["Postgres Database"]:::database
        Mongo["MongoDB Database"]:::database
        Redis["Redis Cache"]:::database
    end

    %% Messaging & Real-Time Layer
    subgraph "Messaging & Real-Time"
        Rabbit["RabbitMQ Message Broker"]:::messaging
        WS["WebSocket & Webhook Service"]:::messaging
    end

    %% External Integrations
    subgraph "External Integrations"
        Gemini["AI Gemini (Content Moderation)"]:::external
        Jitsi["Jitsi Meet (Virtual Consultations)"]:::external
    end

    %% Deployment & Operations
    subgraph "Deployment & Operations"
        DockerFile["Docker Containerization"]:::container
        DockerIgnore["Container Config (.dockerignore)"]:::container
        K8s["Kubernetes Orchestration (GKE)"]:::deployment
        Railway["Railway Deployment"]:::deployment
    end

    %% Connections between layers
    User --> FE
    FE --> FE_SM
    FE_SM --> FE_UI
    FE_UI --> API_Routes
    FE_UI --> API_Req

    API_Routes --> Auth
    API_Routes --> Acc
    API_Routes --> Consult
    API_Routes --> Payment
    API_Routes --> Moderation
    API_Routes --> Chat

    API_Req --> Auth
    API_Req --> Acc
    API_Req --> Consult
    API_Req --> Payment
    API_Req --> Moderation
    API_Req --> Chat

    %% Backend Services to Databases
    Auth --> Postgres
    Acc --> Postgres
    Consult --> Mongo
    Payment --> Postgres
    Moderation --> Redis

    %% Backend Services to Messaging
    Chat --> Rabbit
    Chat --> WS

    %% External Integrations from specific services
    Moderation -->|"moderation_call"| Gemini
    Consult -->|"video_call"| Jitsi

    %% Deployment arrows from services to containerization
    FE -- "deployed_with" --> DockerFile
    Auth -- "deployed_with" --> DockerFile
    Acc -- "deployed_with" --> DockerFile
    Consult -- "deployed_with" --> DockerFile
    Payment -- "deployed_with" --> DockerFile
    Moderation -- "deployed_with" --> DockerFile
    Chat -- "deployed_with" --> DockerFile

    DockerFile --> DockerIgnore
    DockerIgnore --> K8s
    K8s --> Railway

    %% Click Events
    click FE "https://github.com/healing-community/fe/tree/main/src/app"
    click API_Routes "https://github.com/healing-community/fe/tree/main/src/app/api"
    click API_Req "https://github.com/healing-community/fe/tree/main/src/apiRequests"
    click DockerFile "https://github.com/healing-community/fe/tree/main/Dockerfile"
    click DockerIgnore "https://github.com/healing-community/fe/blob/main/.dockerignore"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef backend fill:#f1f8e9,stroke:#33691e,stroke-width:2px;
    classDef database fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef messaging fill:#ffebee,stroke:#c62828,stroke-width:2px;
    classDef external fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px;
    classDef deployment fill:#e3f2fd,stroke:#0d47a1,stroke-width:2px;
    classDef container fill:#fce4ec,stroke:#880e4f,stroke-width:2px;
    classDef user fill:#d1c4e9,stroke:#4a148c,stroke-width:2px;
    class User user;
```
