How maybe25/project-quiz-arena works
This repository is a serverless multiplayer quiz backend. The visible implementation is Python-based AWS Lambda functions, even though the README says “web sockets in GO,” so the architecture diagram should follow the Terraform and Lambda layout rather than the README language.
The primary client-facing boundary is an API Gateway WebSocket API. Incoming socket lifecycle and messages are split across three edge Lambdas: ws-connect, ws-disconnect, and ws-message. These form the ingress layer for player sessions, connection tracking, and command handling.
The core game logic is decomposed into domain Lambdas rather than one monolith:
• room-manager handles room/session membership and room state.
• quiz-engine owns quiz progression and question selection.
• round-ender closes a round and likely triggers the next game phase.
• broadcaster sends game events back to connected clients.
• stats-recorder persists outcome/analytics data.
State is persisted in DynamoDB, with separate table definitions for game, room, and stats. The shared Dynamo layer under shared/dynamo suggests a clear model boundary between ephemeral websocket traffic and durable game state.
Outbound real-time messaging uses the API Gateway Management API through shared/wsapi/post.py. That means the broadcaster is not just publishing events internally; it is responsible for pushing updates back to specific websocket connections.
The repo also has asynchronous workflow infrastructure: SQS, Step Functions, and EventBridge are all provisioned in Terraform. That indicates the game flow is not purely request/response; round transitions and background actions are coordinated through event-driven handoffs and queue-based processing.
Question content is separated from code. The questions/general.json file and s3_questions.tf imply the question bank is packaged into S3 and consumed by the quiz engine from there, rather than being embedded in the Lambda code.
The shared/events/types.py module suggests an internal event contract shared across Lambdas. That is important for an architecture diagram because it marks the boundary between typed domain events and transport-specific websocket messages.
Infrastructure is managed entirely with Terraform under infrastructure/terraform. It provisions the API Gateway, Lambdas, DynamoDB, SQS, Step Functions, EventBridge, S3, and IAM. In other words, the operational architecture is “infrastructure as code” with AWS as the runtime platform.
CI/CD is also explicit: .github/workflows/ci.yml and deploy.yml indicate automated build/test and deployment pipelines. The scripts/build.sh / build.bat and bootstrap.bat files are packaging helpers for assembling Lambda artifacts locally or in CI.
For a diagram, the most important flow is: client connects over WebSocket -> connection is stored -> messages hit ws-message -> domain Lambdas mutate DynamoDB and/or enqueue events -> broadcaster pushes updates back over the websocket management API -> stats and round state are persisted asynchronously.
Main entry points: ws-message/handler.py Message · apigateway.tf WebSocket API · quiz-engine/handler.py Quiz engine · round-ender/handler.py Round ender
Components 21
Client boundary
WebSocket players and the API Gateway edge
- Player client · WebSocket-connected quiz participant
- WebSocket API · API Gateway WebSocket front door
infrastructure/terraform/apigateway.tf
Ingress lambdas
Connection lifecycle and message entrypoints
- Connect · Handles new socket connections
lambdas/ws-connect/handler.py - Disconnect · Handles socket disconnects
lambdas/ws-disconnect/handler.py - Message · Routes incoming websocket commands
lambdas/ws-message/handler.py
Game domain
Core quiz and room processing lambdas
- Room manager · Room membership and session state
lambdas/room-manager/handler.py - Quiz engine · Question selection and round progression
lambdas/quiz-engine/handler.py - Round ender · Closes rounds and advances flow
lambdas/round-ender/handler.py - Broadcaster · Pushes game events to sockets
lambdas/broadcaster/handler.py - Stats recorder · Persists outcomes and analytics
lambdas/stats-recorder/handler.py
State and content
Durable data stores and question content
- Game table · Primary game state store
infrastructure/terraform/dynamodb.tf - Room table · Room and connection state store
infrastructure/terraform/dynamodb.tf - Stats table · Persistent results and analytics store
infrastructure/terraform/dynamodb.tf - Question bank · Packaged quiz questions
infrastructure/terraform/s3_questions.tf
AWS plumbing
Eventing, orchestration, and websocket push infrastructure
- EventBridge · Event routing for async game flow
infrastructure/terraform/eventbridge.tf - SQS queues · Queued handoffs between stages
infrastructure/terraform/sqs.tf - Step Functions · Stateful workflow coordination
infrastructure/terraform/stepfunctions.tf
Shared code
Reusable contracts and persistence helpers
- WS management · API Gateway Management API sender
shared/wsapi/post.py - Dynamo helpers · Shared DynamoDB access model
shared/dynamo/game.py - Event types · Typed internal event definitions
shared/events/types.py
Delivery
Build and deployment automation
- CI/CD · Build and deployment automation
.github/workflows/deploy.yml
Connections 29
- Player client → WebSocket API: connects · Players open websocket sessions
- WebSocket API → Connect: $connect · Connection lifecycle routes
- WebSocket API → Disconnect: $disconnect · Connection lifecycle routes
- WebSocket API → Message: messages · Incoming websocket commands
- Connect → Room table: registers · Stores connection and room membership
- Disconnect → Room table: cleans up · Removes disconnected session state
- Message → Event types: emits · Normalizes commands into domain events
- Message → Room manager: routes · Session and room commands
- Message → Quiz engine: routes · Quiz progression commands
- Message → Round ender: routes · Round control commands
- Room manager → Dynamo helpers: uses · Shared persistence model
- Room manager → Room table: reads/writes · Maintains room state
- Room manager → Game table: reads/writes · Updates game session state
- Quiz engine → Question bank: loads · Fetches question content
- Quiz engine → Game table: reads/writes · Advances quiz state
- Quiz engine → EventBridge: publishes · Hands off phase changes
- Round ender → SQS queues: enqueues · Schedules async follow-up work
- Round ender → Step Functions: starts · Coordinates round transitions
- Round ender → Game table: updates · Closes round state
- Broadcaster → WS management: pushes · Sends updates to connected clients
- WS management → WebSocket API: delivers · Uses API Gateway Management API
- Broadcaster → Event types: consumes · Maps domain events to messages
- Stats recorder → Stats table: persists · Stores results and analytics
- Stats recorder → EventBridge: subscribes · Consumes async outcome events
- EventBridge → SQS queues: fanout · Routes events to queues
- SQS queues → Round ender: triggers · Deferred processing and phase changes
- Step Functions → Quiz engine: orchestrates · Drives multi-step quiz flow
- CI/CD → WebSocket API: deploys · Infrastructure and service deployment
- CI/CD → Message: packages · Builds Lambda artifacts