# yosuke318/anontopic architecture

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

- Interactive diagram: https://gitdiagram.com/yosuke318/anontopic
- Repository: https://github.com/yosuke318/anontopic

## Overview

anontopic is an anonymous, topic-based random chat service with a Go modular-monolith API and a Next.js frontend. The principal user flow is session creation, topic and room-size selection, matching into a room, and WebSocket chat; messages pass moderation before delivery. Separate capabilities cover topic administration, reports and rights-infringement claims, staged sanctions, capacity limits, and data retention. The README and server wiring establish the main relationships; unsampled subsystem internals are represented at their existing source paths without inferring unshown calls.

Main entry points: [`cmd/server/main.go`](https://github.com/yosuke318/anontopic/blob/main/cmd/server/main.go) (HTTP server wiring), [`internal/chat/chat.go`](https://github.com/yosuke318/anontopic/blob/main/internal/chat/chat.go) (Realtime chat), [`internal/matching/http.go`](https://github.com/yosuke318/anontopic/blob/main/internal/matching/http.go) (Matching routes), [`web/app/page.tsx`](https://github.com/yosuke318/anontopic/blob/main/web/app/page.tsx) (Start and topics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webstart["Start and topics<br/>[page.tsx]"]
  node_topicpicker["Topic picker<br/>[topic-picker.tsx]"]
  node_waiting["Waiting room<br/>[waiting-panel.tsx]"]
  node_roomui["Chat room UI<br/>[chat-room.tsx]"]
end

subgraph group_identity["Identity and matching"]
  node_session["Anonymous sessions<br/>[session.go]"]
  node_sessionhttp["Session routes<br/>[http.go]"]
  node_topics["Topic catalog<br/>[topic.go]"]
  node_topicroutes["Topic routes<br/>[http.go]"]
  node_matching["Room matching<br/>[matching.go]"]
  node_matchroutes["Matching routes<br/>[http.go]"]
end

subgraph group_conversation["Conversation safety"]
  node_chat["Realtime chat<br/>[chat.go]"]
  node_moderation["Message moderation<br/>[moderation.go]"]
end

subgraph group_operations["Operations and review"]
  node_reports["Reports and claims<br/>[report.go]"]
  node_reportroutes["Review routes<br/>[http.go]"]
  node_bans["Staged sanctions<br/>[ban.go]"]
  node_capacity["Capacity limits<br/>[capacity.go]"]
  node_retention["Data retention<br/>[retention.go]"]
end

node_visitor(("Visitor"))
node_server["HTTP server wiring<br/>[main.go]"]
node_postgres[("PostgreSQL")]
node_redis[("Redis")]

node_visitor -->|"opens"| node_webstart
node_webstart -.->|"requests session"| node_sessionhttp
node_webstart -.->|"loads topics"| node_topicroutes
node_topicpicker -.->|"starts matching"| node_matchroutes
node_waiting -.->|"polls status"| node_matchroutes
node_matchroutes -->|"dispatches"| node_matching
node_matching -->|"returns room ID"| node_chat
node_roomui -.->|"opens WebSocket"| node_chat
node_server -->|"registers routes"| node_sessionhttp
node_server -->|"registers routes"| node_matchroutes
node_server -->|"registers routes"| node_topicroutes
node_server -->|"registers routes"| node_reportroutes
node_server -->|"builds service"| node_chat
node_chat -->|"checks messages"| node_moderation
node_chat -->|"checks sanctions"| node_bans
node_reportroutes -->|"handles submissions"| node_reports
node_reports -->|"escalates sanctions"| node_bans
node_server -->|"configures limits"| node_capacity
node_session -->|"stores sessions"| node_redis
node_matching -->|"uses wait queue"| node_redis
node_chat -->|"publishes messages"| node_redis
node_topicroutes -->|"routes requests"| node_topics
node_topics -.->|"reads catalog"| node_postgres
node_reports -.->|"stores reviews"| node_postgres
node_retention -->|"prunes data"| node_postgres

click node_webstart "https://github.com/yosuke318/anontopic/blob/main/web/app/page.tsx"
click node_topicpicker "https://github.com/yosuke318/anontopic/blob/main/web/components/topic-picker.tsx"
click node_waiting "https://github.com/yosuke318/anontopic/blob/main/web/components/waiting-panel.tsx"
click node_roomui "https://github.com/yosuke318/anontopic/blob/main/web/components/chat-room.tsx"
click node_session "https://github.com/yosuke318/anontopic/blob/main/internal/session/session.go"
click node_sessionhttp "https://github.com/yosuke318/anontopic/blob/main/internal/session/http.go"
click node_topics "https://github.com/yosuke318/anontopic/blob/main/internal/topic/topic.go"
click node_topicroutes "https://github.com/yosuke318/anontopic/blob/main/internal/topic/http.go"
click node_matching "https://github.com/yosuke318/anontopic/blob/main/internal/matching/matching.go"
click node_matchroutes "https://github.com/yosuke318/anontopic/blob/main/internal/matching/http.go"
click node_chat "https://github.com/yosuke318/anontopic/blob/main/internal/chat/chat.go"
click node_moderation "https://github.com/yosuke318/anontopic/blob/main/internal/moderation/moderation.go"
click node_reports "https://github.com/yosuke318/anontopic/blob/main/internal/report/report.go"
click node_reportroutes "https://github.com/yosuke318/anontopic/blob/main/internal/report/http.go"
click node_bans "https://github.com/yosuke318/anontopic/blob/main/internal/report/ban.go"
click node_capacity "https://github.com/yosuke318/anontopic/blob/main/internal/capacity/capacity.go"
click node_retention "https://github.com/yosuke318/anontopic/blob/main/internal/retention/retention.go"
click node_server "https://github.com/yosuke318/anontopic/blob/main/cmd/server/main.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_webstart,node_topicpicker,node_waiting,node_roomui toneBlue
class node_session,node_sessionhttp,node_topics,node_topicroutes,node_matching,node_matchroutes,node_postgres,node_redis toneAmber
class node_chat,node_moderation,node_server toneMint
class node_reports,node_reportroutes,node_bans,node_capacity,node_retention toneRose
class node_visitor toneIndigo
```

## Components

### Web experience

- [Start and topics](https://github.com/yosuke318/anontopic/blob/main/web/app/page.tsx): `web/app/page.tsx`
- [Topic picker](https://github.com/yosuke318/anontopic/blob/main/web/components/topic-picker.tsx): `web/components/topic-picker.tsx`
- [Waiting room](https://github.com/yosuke318/anontopic/blob/main/web/components/waiting-panel.tsx): `web/components/waiting-panel.tsx`
- [Chat room UI](https://github.com/yosuke318/anontopic/blob/main/web/components/chat-room.tsx): `web/components/chat-room.tsx`

### Identity and matching

- [Anonymous sessions](https://github.com/yosuke318/anontopic/blob/main/internal/session/session.go): `internal/session/session.go`
- [Session routes](https://github.com/yosuke318/anontopic/blob/main/internal/session/http.go): `internal/session/http.go`
- [Topic catalog](https://github.com/yosuke318/anontopic/blob/main/internal/topic/topic.go): `internal/topic/topic.go`
- [Topic routes](https://github.com/yosuke318/anontopic/blob/main/internal/topic/http.go): `internal/topic/http.go`
- [Room matching](https://github.com/yosuke318/anontopic/blob/main/internal/matching/matching.go): `internal/matching/matching.go`
- [Matching routes](https://github.com/yosuke318/anontopic/blob/main/internal/matching/http.go): `internal/matching/http.go`

### Conversation safety

- [Realtime chat](https://github.com/yosuke318/anontopic/blob/main/internal/chat/chat.go): `internal/chat/chat.go`
- [Message moderation](https://github.com/yosuke318/anontopic/blob/main/internal/moderation/moderation.go): `internal/moderation/moderation.go`

### Operations and review

- [Reports and claims](https://github.com/yosuke318/anontopic/blob/main/internal/report/report.go): `internal/report/report.go`
- [Review routes](https://github.com/yosuke318/anontopic/blob/main/internal/report/http.go): `internal/report/http.go`
- [Staged sanctions](https://github.com/yosuke318/anontopic/blob/main/internal/report/ban.go): `internal/report/ban.go`
- [Capacity limits](https://github.com/yosuke318/anontopic/blob/main/internal/capacity/capacity.go): `internal/capacity/capacity.go`
- [Data retention](https://github.com/yosuke318/anontopic/blob/main/internal/retention/retention.go): `internal/retention/retention.go`

### Other components

- **Visitor**
- [HTTP server wiring](https://github.com/yosuke318/anontopic/blob/main/cmd/server/main.go): `cmd/server/main.go`
- **PostgreSQL**
- **Redis**

## Connections

- Visitor → Start and topics: opens
- Start and topics → Session routes: requests session
- Start and topics → Topic routes: loads topics
- Topic picker → Matching routes: starts matching
- Waiting room → Matching routes: polls status
- Matching routes → Room matching: dispatches
- Room matching → Realtime chat: returns room ID
- Chat room UI → Realtime chat: opens WebSocket
- HTTP server wiring → Session routes: registers routes (evidence: `cmd/server/main.go`)
- HTTP server wiring → Matching routes: registers routes (evidence: `cmd/server/main.go`)
- HTTP server wiring → Topic routes: registers routes (evidence: `cmd/server/main.go`)
- HTTP server wiring → Review routes: registers routes (evidence: `cmd/server/main.go`)
- HTTP server wiring → Realtime chat: builds service (evidence: `cmd/server/main.go`)
- Realtime chat → Message moderation: checks messages
- Realtime chat → Staged sanctions: checks sanctions
- Review routes → Reports and claims: handles submissions
- Reports and claims → Staged sanctions: escalates sanctions
- HTTP server wiring → Capacity limits: configures limits (evidence: `cmd/server/main.go`)
- Anonymous sessions → Redis: stores sessions
- Room matching → Redis: uses wait queue
- Realtime chat → Redis: publishes messages
- Topic routes → Topic catalog: routes requests
- Topic catalog → PostgreSQL: reads catalog
- Reports and claims → PostgreSQL: stores reviews
- Data retention → PostgreSQL: prunes data
