# ahmedgomaaeid/iadc-quiz architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedgomaaeid/iadc-quiz
- Repository: https://github.com/ahmedgomaaeid/iadc-quiz

## Overview

This is a Go backend for live, timed quizzes. Admins create quizzes, add questions, and end sessions; participants fetch quiz information, join, and submit answers. The game logic advances each participant through questions and sends updates over room-based WebSockets. Redis stores quiz, participant, progress, timing, and leaderboard data. The excerpts show these runtime paths, but do not establish how scores are retrieved or fully implemented: answer recording is a placeholder, and the README is empty.

Main entry points: [`backend/main.go`](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/main.go) (HTTP routes), [`backend/websocket/hub.go`](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/hub.go) (Connection hub), [`backend/game/logic.go`](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/game/logic.go) (Question progression), [`backend/store/redis_store.go`](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/store/redis_store.go) (Quiz store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP routes<br/>[main.go]"]
  node_admin_handlers["Admin actions<br/>[admin_handler.go]"]
  node_quiz_handlers["Quiz actions<br/>[quiz_handler.go]"]
  node_ws_handlers["WebSocket endpoints"]
end

subgraph group_realtime["Realtime and game"]
  node_game["Question progression<br/>[logic.go]"]
  node_hub["Connection hub<br/>[hub.go]"]
  node_client["WebSocket client<br/>[client.go]"]
  node_messages["Realtime messages<br/>[message.go]"]
end

subgraph group_data["Quiz data"]
  node_store["Quiz store<br/>[redis_store.go]"]
  node_models["Quiz models<br/>[quiz.go]"]
end

subgraph group_external["External services"]
  node_redis[("Redis")]
end

node_admin(("Quiz admin"))
node_participant(("Participant"))

node_admin -->|"uses admin routes"| node_server
node_participant -->|"uses quiz routes"| node_server
node_participant -->|"opens WebSocket"| node_server
node_server -->|"routes admin calls"| node_admin_handlers
node_server -->|"routes quiz calls"| node_quiz_handlers
node_server -->|"routes connections"| node_ws_handlers
node_server -->|"starts hub"| node_hub
node_server -->|"creates store"| node_store
node_server -->|"creates logic"| node_game
node_admin_handlers -->|"creates quiz, questions"| node_store
node_admin_handlers -->|"broadcasts end"| node_hub
node_admin_handlers -->|"accepts questions"| node_models
node_quiz_handlers -->|"reads and updates"| node_store
node_quiz_handlers -->|"broadcasts events"| node_hub
node_quiz_handlers -->|"advances participant"| node_game
node_ws_handlers -->|"creates connection"| node_client
node_ws_handlers -->|"registers client"| node_hub
node_ws_handlers -->|"starts progression"| node_game
node_game -->|"reads and times questions"| node_store
node_game -->|"sends participant updates"| node_hub
node_game -->|"builds question and end messages"| node_messages
node_client -->|"sends and unregisters"| node_hub
node_hub -->|"dispatches messages"| node_client
node_store -->|"reads and writes"| node_redis
node_store -->|"serializes records"| node_models

click node_server "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/main.go"
click node_admin_handlers "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/handlers/admin_handler.go"
click node_quiz_handlers "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/handlers/quiz_handler.go"
click node_ws_handlers "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/handlers/websocket_handler.go"
click node_game "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/game/logic.go"
click node_hub "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/hub.go"
click node_client "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/client.go"
click node_messages "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/message.go"
click node_store "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/store/redis_store.go"
click node_models "https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/models/quiz.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_server,node_admin_handlers,node_quiz_handlers,node_ws_handlers toneBlue
class node_game,node_hub,node_client,node_messages toneAmber
class node_store,node_models toneMint
class node_redis toneRose
class node_admin,node_participant toneIndigo
```

## Components

### HTTP API

- [HTTP routes](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/main.go): `backend/main.go`
- [Admin actions](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/handlers/admin_handler.go): `backend/handlers/admin_handler.go`
- [Quiz actions](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/handlers/quiz_handler.go): `backend/handlers/quiz_handler.go`
- [WebSocket endpoints](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/handlers/websocket_handler.go): `backend/handlers/websocket_handler.go`

### Realtime and game

- [Question progression](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/game/logic.go): `backend/game/logic.go`
- [Connection hub](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/hub.go): `backend/websocket/hub.go`
- [WebSocket client](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/client.go): `backend/websocket/client.go`
- [Realtime messages](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/websocket/message.go): `backend/websocket/message.go`

### Quiz data

- [Quiz store](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/store/redis_store.go): `backend/store/redis_store.go`
- [Quiz models](https://github.com/ahmedgomaaeid/iadc-quiz/blob/main/backend/models/quiz.go): `backend/models/quiz.go`

### External services

- **Redis**

### Other components

- **Quiz admin**
- **Participant**

## Connections

- Quiz admin → HTTP routes: uses admin routes (evidence: `backend/main.go`)
- Participant → HTTP routes: uses quiz routes (evidence: `backend/main.go`)
- Participant → HTTP routes: opens WebSocket (evidence: `backend/main.go`)
- HTTP routes → Admin actions: routes admin calls (evidence: `backend/main.go`)
- HTTP routes → Quiz actions: routes quiz calls (evidence: `backend/main.go`)
- HTTP routes → WebSocket endpoints: routes connections (evidence: `backend/main.go`)
- HTTP routes → Connection hub: starts hub (evidence: `backend/main.go`)
- HTTP routes → Quiz store: creates store (evidence: `backend/main.go`)
- HTTP routes → Question progression: creates logic (evidence: `backend/main.go`)
- Admin actions → Quiz store: creates quiz, questions (evidence: `backend/handlers/admin_handler.go`)
- Admin actions → Connection hub: broadcasts end (evidence: `backend/handlers/admin_handler.go`)
- Admin actions → Quiz models: accepts questions (evidence: `backend/handlers/admin_handler.go`)
- Quiz actions → Quiz store: reads and updates (evidence: `backend/handlers/quiz_handler.go`)
- Quiz actions → Connection hub: broadcasts events (evidence: `backend/handlers/quiz_handler.go`)
- Quiz actions → Question progression: advances participant (evidence: `backend/handlers/quiz_handler.go`)
- WebSocket endpoints → WebSocket client: creates connection (evidence: `backend/handlers/websocket_handler.go`)
- WebSocket endpoints → Connection hub: registers client (evidence: `backend/handlers/websocket_handler.go`)
- WebSocket endpoints → Question progression: starts progression (evidence: `backend/handlers/websocket_handler.go`)
- Question progression → Quiz store: reads and times questions (evidence: `backend/game/logic.go`)
- Question progression → Connection hub: sends participant updates (evidence: `backend/game/logic.go`)
- Question progression → Realtime messages: builds question and end messages (evidence: `backend/game/logic.go`)
- WebSocket client → Connection hub: sends and unregisters (evidence: `backend/websocket/client.go`)
- Connection hub → WebSocket client: dispatches messages (evidence: `backend/websocket/hub.go`)
- Quiz store → Redis: reads and writes (evidence: `backend/store/redis_store.go`)
- Quiz store → Quiz models: serializes records (evidence: `backend/store/redis_store.go`)
