How graple254/yoooo works
Purpose and Entry Points
Chichi is a Django-based real-time multiplayer board-game platform with random matchmaking and LiveKit-backed video/audio. HTTP entry points are configured in chichi/urls.py and served through WSGI/ASGI adapters in chichi/wsgi.py and chichi/asgi.py. The Django management entry point is manage.py.
Application Composition
Two Django apps separate identity from gameplay:
• authentication/ owns user-facing authentication, terms/policy acceptance, and admin email records through authentication/models.py, authentication/views.py, and authentication/urls.py.
• core/ owns game/session state, matchmaking-facing views, site state, activity tracking, and real-time connections via core/views.py, core/models/match_session.py, and core/models/game_models.py.
The project-level configuration, installed services, and URL composition live in chichi/settings.py and chichi/urls.py.
Match and Game State
Persistent domain state is modeled in Django ORM migrations and model modules:
• Match/session lifecycle: core/models/match_session.py
• Game types and results: core/models/game_models.py
• Site availability, beta state, and operational error records: core/models/site_state.py
This establishes a boundary between server-authoritative account/session/result data and browser-side game interaction. Administrative management of games, sessions, activity, and site state is organized in core/admin/game_admin.py, core/admin/session_admin.py, and core/admin/site_state.py.
Real-Time Interaction Layer
ASGI/WebSocket-oriented behavior is concentrated in core/routing.py, core/consumers.py, and core/presence_consumer.py. Presence tracking is separated into core/presence.py, indicating distinct real-time flows for match/game communication versus online-user state.
The expected control flow is: browser loads a Django-rendered page, establishes real-time connections to core consumers, participates in matching/session updates, and synchronizes game interaction with its opponent. Video/audio is delegated to the external LiveKit service rather than implemented by the Django server.
Browser Client and Game Implementations
Templates provide the rendered application shell and connection pages in core/templates/files/base.html, core/templates/files/index.html, and core/templates/files/connect.html. Browser JavaScript contains the interactive game rules/UI and match client behavior:
• Match coordination client: core/static/files/match_client.js
• Individual games: core/static/files/games/chess.js, core/static/files/games/checkers.js, core/static/files/games/connect4.js
• Presence UI: core/static/files/presence_widget.js
This makes the browser a material gameplay runtime, while Django persists and coordinates sessions.
Operational Services and Deployment
Production is designed around Django ASGI served by Daphne, with Nginx as the front proxy: daphne/daphne.service, nginx/nginx.conf, and scripts/daphne.sh. Deployment automation is represented by deploy.sh, scripts/start_app.sh, and .github/workflows/deploy.yaml.
The runtime requires Python 3.10+, Django dependencies from requirements.txt, and a reachable LiveKit server or LiveKit Cloud credentials. UserData.sh and setup scripts indicate instance-level provisioning is part of the deployment model.
Supporting Operational Flows
Middleware and context enrichment are centralized in core/middleware.py and core/context_processors.py. Activity/location tracking and periodic traffic snapshots are represented by core/models/activity_location_tracking.py and core/management/commands/snapshot_traffic.py. Email delivery is encapsulated in core/email.py, with email templates under core/templates/emails/.
Main entry points: core/views.py Gameplay HTTP views · routing.py WebSocket router · urls.py HTTP URL router · authentication/views.py Authentication app
Components 22
Django application
HTTP, identity, and authoritative game state.
- Management entry
manage.py - Project settings · Composes installed services and project configuration.
chichi/settings.py - HTTP URL router · Composes project and app HTTP routes.
chichi/urls.py - Authentication app · Owns login flows, policy acceptance, and email records.
authentication/views.py - Identity records
authentication/models.py - Gameplay HTTP views · Serves matchmaking-facing pages and site interactions.
core/views.py - Match and game state · Server-authoritative sessions, game results, and game types.
core/models/match_session.py - Site operations state · Tracks availability, beta status, and operational errors.
core/models/site_state.py - Request enrichment · Central middleware and template context enrichment.
core/middleware.py - Traffic snapshots · Captures periodic activity and location traffic state.
core/management/commands/snapshot_traffic.py - Email delivery
core/email.py
Real-time and browser
WebSocket coordination and client-side gameplay.
- Rendered application shell
core/templates/files/base.html - WebSocket router
core/routing.py - Match consumers · Coordinates matching, session updates, and game interaction.
core/consumers.py - Presence service · Maintains online-user state separately from matches.
core/presence.py - Game browser client · Runs match coordination and client-side game rules/UI.
core/static/files/match_client.js - Presence widget
core/static/files/presence_widget.js
Deployment and external services
Production serving, automation, and media.
- LiveKit · Provides video and audio outside Django.
- ASGI application · Hosts HTTP and WebSocket application traffic.
chichi/asgi.py - Daphne service
daphne/daphne.service - Nginx proxy
nginx/nginx.conf - Deployment automation · Starts and deploys the production application.
.github/workflows/deploy.yaml
Connections 24
- Management entry → Project settings: loads
- Project settings → HTTP URL router: configures
- HTTP URL router → Authentication app: routes to
- HTTP URL router → Gameplay HTTP views: routes to
- Request enrichment → Gameplay HTTP views: enriches requests
- Authentication app → Identity records: reads and writes
- Authentication app → Email delivery: sends via
- Gameplay HTTP views → Rendered application shell: renders
- Gameplay HTTP views → Match and game state: reads and writes
- Gameplay HTTP views → Site operations state: checks
- Rendered application shell → Game browser client: loads
- Rendered application shell → Presence widget: loads
- Game browser client → WebSocket router: opens WebSockets
- Presence widget → WebSocket router: opens presence socket
- WebSocket router → Match consumers: dispatches match traffic
- WebSocket router → Presence service: dispatches presence traffic
- Match consumers → Match and game state: coordinates state
- Presence service → Traffic snapshots: supplies activity data
- Game browser client → LiveKit: uses video and audio
- Nginx proxy → Daphne service: proxies traffic
- Daphne service → ASGI application: serves
- ASGI application → HTTP URL router: serves HTTP
- ASGI application → WebSocket router: serves WebSockets
- Deployment automation → Daphne service: deploys and starts