# xuxinzhi007/moe_social architecture

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

- Interactive diagram: https://gitdiagram.com/xuxinzhi007/moe_social
- Repository: https://github.com/xuxinzhi007/moe_social

## Overview

Moe Social is a Flutter social-network client backed by Go API and RPC services. Its principal workflow is client interaction with authenticated API endpoints, domain operations in the RPC service, and persisted social/account state; the API also exposes real-time chat and LLM features. README capabilities and the route tree support the domain branches shown, while sampled code confirms API-to-RPC setup, RPC database initialization, and raw Ollama forwarding. Flutter implementation details and most handler-to-RPC call sites were not sampled, so those internal links are intentionally summarized or omitted.

Main entry points: [`backend/api/internal/handler/routes.go`](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/handler/routes.go) (REST routes), [`backend/api/internal/svc/servicecontext.go`](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/svc/servicecontext.go) (Super RPC client), [`lib/main.dart`](https://github.com/xuxinzhi007/moe_social/blob/main/lib/main.dart) (Flutter app), [`backend/api/internal/handler/user`](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/user) (Accounts & profiles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Flutter client"]
  node_flutter["Flutter app<br/>[main.dart]"]
end

subgraph group_api["HTTP API"]
  node_http["REST routes<br/>[routes.go]"]
  node_identity["Accounts &amp; profiles"]
  node_social["Posts &amp; groups"]
  node_messaging["Messages &amp; notices"]
  node_commerce["Virtual goods"]
  node_media["Image service"]
  node_api_context["API service context<br/>[servicecontext.go]"]
  node_rpc_client["Super RPC client<br/>[servicecontext.go]"]
end

subgraph group_rpc["RPC services"]
  node_rpc_server["RPC server<br/>[superserver.go]"]
  node_rpc_logic["Domain operations"]
  node_rpc_context["RPC service context<br/>[servicecontext.go]"]
  node_models[("Domain records<br/>[user.go]")]
end

subgraph group_realtime["Real-time"]
  node_websocket["WebSocket manager<br/>[manager.go]"]
  node_chat_routes["Chat endpoints"]
end

subgraph group_ai["AI integration"]
  node_ollama_routes["LLM endpoints"]
  node_ollama_raw["Raw chat proxy<br/>[rawchathandler.go]"]
end

node_user(("App user"))
node_ollama["Ollama service"]

node_user -->|"uses"| node_flutter
node_flutter -->|"API requests"| node_http
node_http -->|"routes requests"| node_identity
node_http -->|"routes requests"| node_social
node_http -->|"routes requests"| node_messaging
node_http -->|"routes requests"| node_commerce
node_http -->|"routes requests"| node_media
node_identity -->|"domain calls"| node_rpc_client
node_social -->|"domain calls"| node_rpc_client
node_messaging -->|"domain calls"| node_rpc_client
node_commerce -->|"domain calls"| node_rpc_client
node_rpc_client -->|"RPC calls"| node_rpc_server
node_rpc_server -->|"dispatches"| node_rpc_logic
node_rpc_logic -->|"reads/writes"| node_models
node_rpc_context -->|"initializes database"| node_models
node_http -->|"routes requests"| node_chat_routes
node_chat_routes -->|"manages connections"| node_websocket
node_http -->|"routes requests"| node_ollama_routes
node_ollama_routes -->|"dispatches raw chat"| node_ollama_raw
node_ollama_raw -->|"forwards request"| node_ollama

click node_flutter "https://github.com/xuxinzhi007/moe_social/blob/main/lib/main.dart"
click node_http "https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/handler/routes.go"
click node_identity "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/user"
click node_social "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/post"
click node_messaging "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/privatemsg"
click node_commerce "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/gift"
click node_media "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/image"
click node_api_context "https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/svc/servicecontext.go"
click node_rpc_client "https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/svc/servicecontext.go"
click node_rpc_server "https://github.com/xuxinzhi007/moe_social/blob/main/backend/rpc/internal/server/superserver.go"
click node_rpc_logic "https://github.com/xuxinzhi007/moe_social/tree/main/backend/rpc/internal/logic"
click node_rpc_context "https://github.com/xuxinzhi007/moe_social/blob/main/backend/rpc/internal/svc/servicecontext.go"
click node_models "https://github.com/xuxinzhi007/moe_social/blob/main/backend/model/user.go"
click node_websocket "https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/websocket/manager.go"
click node_chat_routes "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/chat"
click node_ollama_routes "https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/llm"
click node_ollama_raw "https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/handler/llm/rawchathandler.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_flutter,node_user toneBlue
class node_http,node_identity,node_social,node_messaging,node_commerce,node_media,node_api_context,node_rpc_client toneAmber
class node_rpc_server,node_rpc_logic,node_rpc_context,node_models toneMint
class node_websocket,node_chat_routes toneRose
class node_ollama_routes,node_ollama_raw,node_ollama toneIndigo
```

## Components

### Flutter client

- [Flutter app](https://github.com/xuxinzhi007/moe_social/blob/main/lib/main.dart): `lib/main.dart`

### HTTP API

- [REST routes](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/handler/routes.go): `backend/api/internal/handler/routes.go`
- [Accounts & profiles](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/user): `backend/api/internal/handler/user`
- [Posts & groups](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/post): `backend/api/internal/handler/post`
- [Messages & notices](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/privatemsg): `backend/api/internal/handler/privatemsg`
- [Virtual goods](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/gift): `backend/api/internal/handler/gift`
- [Image service](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/image): `backend/api/internal/handler/image`
- [API service context](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/svc/servicecontext.go): `backend/api/internal/svc/servicecontext.go`
- [Super RPC client](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/svc/servicecontext.go): `backend/api/internal/svc/servicecontext.go`

### RPC services

- [RPC server](https://github.com/xuxinzhi007/moe_social/blob/main/backend/rpc/internal/server/superserver.go): `backend/rpc/internal/server/superserver.go`
- [Domain operations](https://github.com/xuxinzhi007/moe_social/tree/main/backend/rpc/internal/logic): `backend/rpc/internal/logic`
- [RPC service context](https://github.com/xuxinzhi007/moe_social/blob/main/backend/rpc/internal/svc/servicecontext.go): `backend/rpc/internal/svc/servicecontext.go`
- [Domain records](https://github.com/xuxinzhi007/moe_social/blob/main/backend/model/user.go): `backend/model/user.go`

### Real-time

- [WebSocket manager](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/websocket/manager.go): `backend/api/internal/websocket/manager.go`
- [Chat endpoints](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/chat): `backend/api/internal/handler/chat`

### AI integration

- [LLM endpoints](https://github.com/xuxinzhi007/moe_social/tree/main/backend/api/internal/handler/llm): `backend/api/internal/handler/llm`
- [Raw chat proxy](https://github.com/xuxinzhi007/moe_social/blob/main/backend/api/internal/handler/llm/rawchathandler.go): `backend/api/internal/handler/llm/rawchathandler.go`

### Other components

- **App user**
- **Ollama service**

## Connections

- App user → Flutter app: uses
- Flutter app → REST routes: API requests
- REST routes → Accounts & profiles: routes requests
- REST routes → Posts & groups: routes requests
- REST routes → Messages & notices: routes requests
- REST routes → Virtual goods: routes requests
- REST routes → Image service: routes requests
- Accounts & profiles → Super RPC client: domain calls
- Posts & groups → Super RPC client: domain calls
- Messages & notices → Super RPC client: domain calls
- Virtual goods → Super RPC client: domain calls
- Super RPC client → RPC server: RPC calls
- RPC server → Domain operations: dispatches
- Domain operations → Domain records: reads/writes
- RPC service context → Domain records: initializes database
- REST routes → Chat endpoints: routes requests
- Chat endpoints → WebSocket manager: manages connections
- REST routes → LLM endpoints: routes requests
- LLM endpoints → Raw chat proxy: dispatches raw chat
- Raw chat proxy → Ollama service: forwards request
