# wuvictor-95/boards architecture

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

- Interactive diagram: https://gitdiagram.com/wuvictor-95/boards
- Repository: https://github.com/wuvictor-95/boards

## Overview

Based on our analysis of the provided file tree and README, Boards is a collaborative, event-driven, full-stack web application built using a microservices architecture. It consists of two primary backend services (backend-core and backend-notification), a frontend web client built with Next.js and Tailwind CSS, and a number of supporting infrastructure components (PostgreSQL, Redis for real-time pub/sub, RabbitMQ, and Kubernetes for orchestration).

##### Main Components
- Frontend Service: Represent the web client developed with Next.js, Tailwind CSS, and React DnD. This is the user interface where users create and interact with boards.
- Backend-core Service: This is the core API which handles user authentication, board/post management, and real-time communication via WebSockets (using Gorilla WebSockets) and uses routing (Chi Router). It also contains the DB layer (PostgreSQL) with migrations (“golang-migrate” and sqlc for SQL).
- Backend-notification Service: A separate microservice responsible for handling notifications. It leverages RabbitMQ tasks and integrates with email systems, along with interacting with the boards and other event sources.
- Real-Time Communication: This includes two key parts:
- Redis Pub/Sub: Used to synchronize data across client connections.
- WebSockets: For real-time events like creating, moving, or editing posts.

##### Relationships and Interactions
- That backend-core directly interacts with the PostgreSQL database (for CRUD operations), and that it employs Redis Pub/Sub and WebSocket events to push real-time updates back to the Frontend.
- Backend-notification should be shown as a consumer of task requests (triggered from the backend-core) – these tasks might involve sending emails, posting notifications, or handling board events – queued via RabbitMQ.
- Additionally, indicate that both backend services use shared libraries/components (e.g., logger, security, and AMQP wrappers) when integrating with infrastructure services.
- That container orchestration is managed by Kubernetes, which deploys all services and maintains configurations (as seen in the kubernetes directory).

##### Important Architectural Patterns and Design Principles
- Microservices pattern: Separate responsibilities between core application logic and notifications.
- Event-driven communication: Emphasize the use of RabbitMQ and Redis for asynchronous communication and real-time synchronization.
- Clean architecture: With separation between API routes (controllers), business logic (services), and data access layers (repositories/models).
- Containerization and orchestration: Use Docker images for building the services and Kubernetes for scaling, managing deployments, and networking.

##### Technologies, Frameworks, and Libraries
- Frontend: Next.js 13, Tailwind CSS, React DnD.
- Backend: Go (Golang), Chi Router, Gorilla WebSockets, JWT authentication, PostgreSQL (with pgx), sqlc, and golang-migrate.
- Infrastructure: Docker, Kubernetes (YAML configs for deployments and services), RabbitMQ, Redis.
- Additional Utilities: AMQP wrappers, logger and validator packages.

##### Additional Notes
- Since the project has extensive documentation and blog posts related to WebSockets and event processing, consider highlighting the event flow (publish/subscribe model) for real-time updates.
- Mention any test/mock modules (visible in the file tree) to underline that the design supports unit testing and integration testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interaction Layer"
        F["Frontend Web Client"]:::frontend
        Fws["WebSocket Client"]:::frontend
    end

    subgraph "Backend Services"
        BC["Backend-core API"]:::backend
        BC_db["Database Module"]:::backend
        BC_ws["Real-Time (WS & Redis)"]:::backend
        BN["Backend-notification Service"]:::backend
    end

    subgraph "Data & Messaging"
        DB["PostgreSQL Database"]:::db
        RMQ["RabbitMQ Message Broker"]:::messaging
        AMQP["AMQP Wrappers"]:::messaging
    end

    subgraph "Containerization"
        D_frontend["Dockerfile (Frontend)"]:::infra
        D_backend["Dockerfile (Backend-core)"]:::infra
        D_notification["Dockerfile (Backend-notification)"]:::infra
        COMPOSE["docker-compose.yml"]:::infra
    end

    subgraph "Orchestration"
        K8s["Kubernetes Cluster"]:::infra
    end

    %% Connections between layers
    F -->|"HTTP/REST"| BC
    BC -->|"calls_module"| BC_db
    BC_db -->|"Queries/Migrations"| DB
    BC -->|"RealTime_Events"| BC_ws
    BC_ws -->|"Push_Updates"| Fws
    BC -->|"Publishes_Tasks"| RMQ
    RMQ -->|"Processes_Tasks"| BN
    BC -->|"Uses_AMQP"| AMQP
    BN -->|"Uses_AMQP"| AMQP

    %% Containerization relations
    D_frontend -->|"Builds"| F
    D_backend -->|"Builds"| BC
    D_notification -->|"Builds"| BN
    COMPOSE -->|"Orchestrates"| K8s

    %% Kubernetes deploying services
    K8s --> BC
    K8s --> BN
    K8s --> F
    K8s --> DB
    K8s --> RMQ

    %% Click Events
    click F "https://github.com/wuvictor-95/boards/tree/main/frontend/"
    click Fws "https://github.com/wuvictor-95/boards/tree/main/frontend/src/ws"
    click BC "https://github.com/wuvictor-95/boards/tree/main/backend-core/"
    click BC_db "https://github.com/wuvictor-95/boards/tree/main/backend-core/db/"
    click BC_ws "https://github.com/wuvictor-95/boards/tree/main/backend-core/internal/ws/"
    click BN "https://github.com/wuvictor-95/boards/tree/main/backend-notification/"
    click RMQ "https://github.com/wuvictor-95/boards/blob/main/kubernetes/configs/rabbitmq-config.yaml"
    click AMQP "https://github.com/wuvictor-95/boards/tree/main/wrappers/amqp/"
    click D_frontend "https://github.com/wuvictor-95/boards/tree/main/frontend/Dockerfile"
    click D_backend "https://github.com/wuvictor-95/boards/tree/main/backend-core/Dockerfile"
    click D_notification "https://github.com/wuvictor-95/boards/tree/main/backend-notification/Dockerfile"
    click COMPOSE "https://github.com/wuvictor-95/boards/blob/main/docker-compose.yml"
    click K8s "https://github.com/wuvictor-95/boards/tree/main/kubernetes/"

    %% Styling
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef db fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef messaging fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef infra fill:#98FB98,stroke:#000,stroke-width:2px;
```
