# sanzashi987/nino-work-mono architecture

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

- Interactive diagram: https://gitdiagram.com/sanzashi987/nino-work-mono
- Repository: https://github.com/sanzashi987/nino-work-mono

## Overview

##### Project Type & Purpose
- This is a multi-domain, microservices-oriented system built primarily in Go with a separate frontend managed in a monorepo style. The project supports several distinct applications (such as “canvix”, “chat”, “config-center”, “storage”, and “user”) which likely each represent a microservice responsible for a distinct business domain.
- It uses Protocol Buffers and gRPC for service definition and inter-service communication (as evidenced by the proto files and README instructions on installing the protoc plugins). There are also frontend applications written in TypeScript/React (inside the “frontend” directory with apps like main, root, and storage), indicating a full-stack solution with independent teams for backend and UI.

##### Analyzing the File Structure
- Shared/Utility Code: The “pkg” folder holds controllers, database utilities, and shared functionalities that may be reused across microservices.
- Common Protocol Definitions: The “proto” directory holds Protocol Buffer definitions (for chat, storage, user, and error handling) which standardize inter-service communication.
- Frontend: The “frontend” directory is organized by subprojects (e.g., “canvix”, “main”, “root”, “storage”) and further subdivided into modules for configuration, UI components, API layers, etc. This structure indicates that the frontend is split into different applications, each interfacing with one or more backend services.
- External Dependencies: The README instructs setup of etcd (for service discovery/configuration) and Typesense (a vector database). The presence of these services indicates that your system is not only internally consistent but relies on external components for configuration management and possibly search or real-time features.

- Main Components:
- Shared Package/Library: A block representing “pkg” that provides common functionality across microservices.
- Frontend Applications: Represent the separate frontend applications (canvix, main, root, storage) which interact with the backend services.
- Infrastructure Services: Represent external or supplemental systems like etcd (for configuration/service discovery), and Typesense (for vector search or specialized DB features).

- Relationships and Interactions:
- Within the backend section, you might show internal flows: for example, an HTTP request enters a microservice, passes through middleware (as seen with auth in canvix/http/middleware/auth.go), then reaches the service logic, and finally interacts with the database via DAO/model patterns.
- Bi-directional or service-to-service communication where applicable (e.g., if a microservice needs to communicate with the config-center for configuration data).
- Shared “pkg” to the microservices that import it.
- That gRPC interfaces are generated by using Protocol Buffers (annotate the communication channels between clients and microservices accordingly).

- Important Architectural Patterns & Design Principles:
- A microservice architecture that separates concerns by business domain (with a clear separation between the presentation layer, service logic, and data access layers).
- Use of gRPC for efficient, language-agnostic inter-service communication.
- Separation between backend and frontend responsibilities, where the frontend applications are treated as individual “apps” in a modular workspace.
- The design also hints at scalability and modularity; each microservice is developed in isolation yet leverages common shared libraries from the “pkg” directory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global shared nodes
    Proto["Protocol Buffers Definitions"]:::shared
    SharedPkg["Shared Packages & Utilities"]:::shared
    Etcd["etcd"]:::external
    Typesense["Typesense"]:::external

    %% Frontend Applications
    subgraph "Frontend Applications"
        FC["Frontend Canvix"]:::frontend
        FM["Frontend Main"]:::frontend
        FR["Frontend Root"]:::frontend
        FS["Frontend Storage"]:::frontend
    end

    %% Backend Microservices
    subgraph "Backend Microservices"
        %% Canvix Service
        subgraph "Canvix Service"
            C_HTTP["HTTP API"]:::backend
            C_Service["Service Logic"]:::backend
            C_DAO["DAO/Models"]:::backend
            C_HTTP -->|"calls"| C_Service
            C_Service -->|"calls"| C_DAO
            C_Service -->|"grpc"| Proto
            C_Service -->|"uses"| SharedPkg
        end

        %% Chat Service
        subgraph "Chat Service"
            CH_HTTP["HTTP API"]:::backend
            CH_Service["Service Logic"]:::backend
            CH_DAO["DAO/Models"]:::backend
            CH_HTTP -->|"calls"| CH_Service
            CH_Service -->|"calls"| CH_DAO
            CH_Service -->|"grpc"| Proto
            CH_Service -->|"uses"| SharedPkg
        end

        %% Config-Center Service
        subgraph "Config-Center Service"
            CC_HTTP["HTTP API"]:::backend
            CC_Service["Service Logic"]:::backend
            CC_DAO["DAO/Models"]:::backend
            CC_HTTP -->|"calls"| CC_Service
            CC_Service -->|"calls"| CC_DAO
            CC_Service -->|"grpc"| Proto
            CC_Service -->|"uses"| SharedPkg
            CC_HTTP -->|"config"| Etcd
        end

        %% Storage Service
        subgraph "Storage Service"
            ST_HTTP["HTTP API"]:::backend
            ST_Service["Service Logic"]:::backend
            ST_DAO["DAO/Models"]:::backend
            ST_HTTP -->|"calls"| ST_Service
            ST_Service -->|"calls"| ST_DAO
            ST_Service -->|"grpc"| Proto
            ST_Service -->|"uses"| SharedPkg
            ST_HTTP -->|"search"| Typesense
        end

        %% User Service
        subgraph "User Service"
            U_HTTP["HTTP API"]:::backend
            U_Service["Service Logic"]:::backend
            U_DAO["DAO/Models"]:::backend
            U_HTTP -->|"calls"| U_Service
            U_Service -->|"calls"| U_DAO
            U_Service -->|"grpc"| Proto
            U_Service -->|"uses"| SharedPkg
        end
    end

    %% Frontend to Backend Interactions
    FC -->|"HTTP/gRPC"| C_HTTP
    FR -->|"HTTP/gRPC"| CH_HTTP
    FS -->|"HTTP/gRPC"| ST_HTTP
    FM -->|"HTTP/gRPC"| U_HTTP

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef shared fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;

    %% Click Events
    click C_HTTP "https://github.com/sanzashi987/nino-work-mono/tree/main/apps/canvix"
    click CH_HTTP "https://github.com/sanzashi987/nino-work-mono/tree/main/apps/chat"
    click CC_HTTP "https://github.com/sanzashi987/nino-work-mono/tree/main/apps/config-center"
    click ST_HTTP "https://github.com/sanzashi987/nino-work-mono/tree/main/apps/storage"
    click U_HTTP "https://github.com/sanzashi987/nino-work-mono/tree/main/apps/user"
    click SharedPkg "https://github.com/sanzashi987/nino-work-mono/tree/main/pkg"
    click Proto "https://github.com/sanzashi987/nino-work-mono/tree/main/proto"
    click FC "https://github.com/sanzashi987/nino-work-mono/tree/main/frontend/apps/canvix"
    click FM "https://github.com/sanzashi987/nino-work-mono/tree/main/frontend/apps/main"
    click FR "https://github.com/sanzashi987/nino-work-mono/tree/main/frontend/apps/root"
    click FS "https://github.com/sanzashi987/nino-work-mono/tree/main/frontend/apps/storage"
```
