# aossie-org/debateai architecture

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

- Interactive diagram: https://gitdiagram.com/aossie-org/debateai
- Repository: https://github.com/aossie-org/debateai

## Overview

DebateAI is a real-time debate platform for human-versus-human and AI-opponent debates, with teams, tournaments, community, coaching, and user progression features. Users enter through the web app, participate in structured debates or team activities, and can review saved transcripts and results. The backend exposes authenticated HTTP routes and WebSocket endpoints, with MongoDB for persistence and optional Gemini-backed AI features. Several feature modules are represented from the repository tree and README; their internal wiring was not sampled, so uncertain connections are omitted.

Main entry points: [`backend/cmd/server/main.go`](https://github.com/aossie-org/debateai/blob/main/backend/cmd/server/main.go) (HTTP and WS server), [`frontend/src/services/teamService.ts`](https://github.com/aossie-org/debateai/blob/main/frontend/src/services/teamService.ts) (Team API client), [`backend/db/db.go`](https://github.com/aossie-org/debateai/blob/main/backend/db/db.go) (MongoDB), [`frontend/src/App.tsx`](https://github.com/aossie-org/debateai/blob/main/frontend/src/App.tsx) (DebateAI web app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["DebateAI web app<br/>[App.tsx]"]
  node_teamui["Team experience<br/>[TeamBuilder.tsx]"]
  node_tournamentui["Tournament experience<br/>[TournamentHub.tsx]"]
  node_config["Frontend config<br/>[config.ts]"]
end

subgraph group_debate["Debate sessions"]
  node_debateui["Debate rooms<br/>[DebateRoom.tsx]"]
  node_debateatoms["Debate state<br/>[debateAtoms.ts]"]
  node_debatews["Debate WebSocket hook<br/>[useDebateWS.ts]"]
  node_aiui["AI debate<br/>[BotSelection.tsx]"]
  node_transcriptcontroller["Transcript API"]
  node_transcriptservice["Transcript service"]
  node_botcontroller["AI debate API"]
  node_gemini["Gemini integration<br/>[gemini.go]"]
end

subgraph group_social["Community and teams"]
  node_teamservice["Team API client<br/>[teamService.ts]"]
  node_communityui["Community feed<br/>[CommunityFeed.tsx]"]
  node_teamcontroller["Team operations<br/>[team_controller.go]"]
  node_tournamentcontroller["Tournament operations"]
end

subgraph group_platform["Backend platform"]
  node_server["HTTP and WS server<br/>[main.go]"]
  node_auth["Authentication middleware<br/>[auth.go]"]
  node_teamws["Team debate sockets"]
end

subgraph group_state["Persistence and AI"]
  node_mongo[("MongoDB<br/>[db.go]")]
  node_redis[("Redis client<br/>[redis_client.go]")]
  node_teamturn["Team turn management"]
  node_rating["Rating service<br/>[rating_service.go]"]
end

node_debaters(("Debaters"))

node_debaters -->|"use"| node_webapp
node_webapp -.->|"enter debates"| node_debateui
node_debateui -->|"connects through"| node_debatews
node_debatews -->|"updates state"| node_debateatoms
node_debaters -->|"challenge AI"| node_aiui
node_aiui -.->|"requests AI debates"| node_botcontroller
node_botcontroller -.->|"uses AI service"| node_gemini
node_debaters -.->|"form teams"| node_teamui
node_teamui -.->|"requests team data"| node_teamservice
node_teamservice -.->|"calls team API"| node_teamcontroller
node_teamservice -->|"reads base URL"| node_config
node_debaters -.->|"join tournaments"| node_tournamentui
node_tournamentui -.->|"requests tournament actions"| node_tournamentcontroller
node_debaters -.->|"participate"| node_communityui
node_server -->|"connects"| node_mongo
node_server -->|"applies to protected routes"| node_auth
node_server -->|"registers transcript routes"| node_transcriptcontroller
node_transcriptcontroller -.->|"delegates transcript work"| node_transcriptservice
node_server -->|"registers team socket"| node_teamws
node_teamturn -->|"loads team members"| node_mongo
node_server -.->|"initializes Redis"| node_redis
node_rating -.->|"persists rating data"| node_mongo

click node_webapp "https://github.com/aossie-org/debateai/blob/main/frontend/src/App.tsx"
click node_teamui "https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/TeamBuilder.tsx"
click node_tournamentui "https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/TournamentHub.tsx"
click node_debateui "https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/DebateRoom.tsx"
click node_debateatoms "https://github.com/aossie-org/debateai/blob/main/frontend/src/atoms/debateAtoms.ts"
click node_debatews "https://github.com/aossie-org/debateai/blob/main/frontend/src/hooks/useDebateWS.ts"
click node_aiui "https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/BotSelection.tsx"
click node_teamservice "https://github.com/aossie-org/debateai/blob/main/frontend/src/services/teamService.ts"
click node_communityui "https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/CommunityFeed.tsx"
click node_teamcontroller "https://github.com/aossie-org/debateai/blob/main/backend/controllers/team_controller.go"
click node_tournamentcontroller "https://github.com/aossie-org/debateai/blob/main/backend/controllers/tournament_controller.go"
click node_transcriptcontroller "https://github.com/aossie-org/debateai/blob/main/backend/controllers/transcript_controller.go"
click node_transcriptservice "https://github.com/aossie-org/debateai/blob/main/backend/services/transcriptservice.go"
click node_botcontroller "https://github.com/aossie-org/debateai/blob/main/backend/controllers/debatevsbot_controller.go"
click node_gemini "https://github.com/aossie-org/debateai/blob/main/backend/services/gemini.go"
click node_server "https://github.com/aossie-org/debateai/blob/main/backend/cmd/server/main.go"
click node_auth "https://github.com/aossie-org/debateai/blob/main/backend/middlewares/auth.go"
click node_teamws "https://github.com/aossie-org/debateai/blob/main/backend/websocket/team_debate_handler.go"
click node_mongo "https://github.com/aossie-org/debateai/blob/main/backend/db/db.go"
click node_redis "https://github.com/aossie-org/debateai/blob/main/backend/internal/debate/redis_client.go"
click node_teamturn "https://github.com/aossie-org/debateai/blob/main/backend/services/team_turn_service.go"
click node_rating "https://github.com/aossie-org/debateai/blob/main/backend/services/rating_service.go"
click node_config "https://github.com/aossie-org/debateai/blob/main/frontend/src/config/config.ts"

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_webapp,node_teamui,node_tournamentui,node_config toneBlue
class node_debateui,node_debateatoms,node_debatews,node_aiui,node_transcriptcontroller,node_transcriptservice,node_botcontroller,node_gemini toneAmber
class node_teamservice,node_communityui,node_teamcontroller,node_tournamentcontroller toneMint
class node_server,node_auth,node_teamws toneRose
class node_mongo,node_redis,node_teamturn,node_rating,node_debaters toneIndigo
```

## Components

### Web experience

- [DebateAI web app](https://github.com/aossie-org/debateai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Team experience](https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/TeamBuilder.tsx): `frontend/src/Pages/TeamBuilder.tsx`
- [Tournament experience](https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/TournamentHub.tsx): `frontend/src/Pages/TournamentHub.tsx`
- [Frontend config](https://github.com/aossie-org/debateai/blob/main/frontend/src/config/config.ts): `frontend/src/config/config.ts`

### Debate sessions

- [Debate rooms](https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/DebateRoom.tsx): `frontend/src/Pages/DebateRoom.tsx`
- [Debate state](https://github.com/aossie-org/debateai/blob/main/frontend/src/atoms/debateAtoms.ts): `frontend/src/atoms/debateAtoms.ts`
- [Debate WebSocket hook](https://github.com/aossie-org/debateai/blob/main/frontend/src/hooks/useDebateWS.ts): `frontend/src/hooks/useDebateWS.ts`
- [AI debate](https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/BotSelection.tsx): `frontend/src/Pages/BotSelection.tsx`
- [Transcript API](https://github.com/aossie-org/debateai/blob/main/backend/controllers/transcript_controller.go): `backend/controllers/transcript_controller.go`
- [Transcript service](https://github.com/aossie-org/debateai/blob/main/backend/services/transcriptservice.go): `backend/services/transcriptservice.go`
- [AI debate API](https://github.com/aossie-org/debateai/blob/main/backend/controllers/debatevsbot_controller.go): `backend/controllers/debatevsbot_controller.go`
- [Gemini integration](https://github.com/aossie-org/debateai/blob/main/backend/services/gemini.go): `backend/services/gemini.go`

### Community and teams

- [Team API client](https://github.com/aossie-org/debateai/blob/main/frontend/src/services/teamService.ts): `frontend/src/services/teamService.ts`
- [Community feed](https://github.com/aossie-org/debateai/blob/main/frontend/src/Pages/CommunityFeed.tsx): `frontend/src/Pages/CommunityFeed.tsx`
- [Team operations](https://github.com/aossie-org/debateai/blob/main/backend/controllers/team_controller.go): `backend/controllers/team_controller.go`
- [Tournament operations](https://github.com/aossie-org/debateai/blob/main/backend/controllers/tournament_controller.go): `backend/controllers/tournament_controller.go`

### Backend platform

- [HTTP and WS server](https://github.com/aossie-org/debateai/blob/main/backend/cmd/server/main.go): `backend/cmd/server/main.go`
- [Authentication middleware](https://github.com/aossie-org/debateai/blob/main/backend/middlewares/auth.go): `backend/middlewares/auth.go`
- [Team debate sockets](https://github.com/aossie-org/debateai/blob/main/backend/websocket/team_debate_handler.go): `backend/websocket/team_debate_handler.go`

### Persistence and AI

- [MongoDB](https://github.com/aossie-org/debateai/blob/main/backend/db/db.go): `backend/db/db.go`
- [Redis client](https://github.com/aossie-org/debateai/blob/main/backend/internal/debate/redis_client.go): `backend/internal/debate/redis_client.go`
- [Team turn management](https://github.com/aossie-org/debateai/blob/main/backend/services/team_turn_service.go): `backend/services/team_turn_service.go`
- [Rating service](https://github.com/aossie-org/debateai/blob/main/backend/services/rating_service.go): `backend/services/rating_service.go`

### Other components

- **Debaters**

## Connections

- Debaters → DebateAI web app: use (evidence: `README.md`)
- DebateAI web app → Debate rooms: enter debates
- Debate rooms → Debate WebSocket hook: connects through (evidence: `README.md`)
- Debate WebSocket hook → Debate state: updates state (evidence: `frontend/src/hooks/useDebateWS.ts`)
- Debaters → AI debate: challenge AI (evidence: `README.md`)
- AI debate → AI debate API: requests AI debates
- AI debate API → Gemini integration: uses AI service
- Debaters → Team experience: form teams
- Team experience → Team API client: requests team data
- Team API client → Team operations: calls team API
- Team API client → Frontend config: reads base URL (evidence: `frontend/src/services/teamService.ts`)
- Debaters → Tournament experience: join tournaments
- Tournament experience → Tournament operations: requests tournament actions
- Debaters → Community feed: participate
- HTTP and WS server → MongoDB: connects (evidence: `backend/cmd/server/main.go`)
- HTTP and WS server → Authentication middleware: applies to protected routes (evidence: `backend/cmd/server/main.go`)
- HTTP and WS server → Transcript API: registers transcript routes
- Transcript API → Transcript service: delegates transcript work
- HTTP and WS server → Team debate sockets: registers team socket (evidence: `backend/cmd/server/main.go`)
- Team turn management → MongoDB: loads team members (evidence: `backend/services/team_turn_service.go`)
- HTTP and WS server → Redis client: initializes Redis
- Rating service → MongoDB: persists rating data
