How lorenzofavaro/prompt-clash-game works
Main Components
• Chat Service – Manages user interactions and image generation. It uses Chainlit for chat handling, includes its own API endpoints and data layer (e.g., mysql_data_layer, OCI storage client) and communicates with external AI services (OpenAI DALL-E).
• Round Manager Service – This service is responsible for handling game rounds, themes, timings, and state management. It houses modules for MySQL connection, round state repository, and a streaming component for real-time notifications.
• Admin Service and Admin Interface – The Admin Service provides backend functionality for administrative operations (e.g., evaluating and selecting winning images). Its corresponding Admin Interface is built using Streamlit, with components to render control buttons, images, login forms, and settings.
• User Interface – A React-based frontend that includes a full client application with multiple pages, API integrations, and state management. It is architectured to interact with the chat service through RESTful calls.
• Database Service – A MySQL database that persists game data. The README also mentions that a PostgreSQL alternative is possible.
• External Storage Providers – The implementation currently uses Oracle Cloud Infrastructure (OCI), with notes for alternative providers (AWS S3, GCS, Azure Blob).
Relationships and Interactions
• The User Interface communicates with the Chat Service (for image generation and chat interactions) as well as with other services as needed.
• Chat Service interfaces with the Database for persistence and uses specific data-layer modules (like the custom MySQL data layer) and storage clients.
• Round Manager Service orchestrates game rounds and communicates with both the Chat and Admin Services for real-time updates and administrative controls.
• Admin Service coordinates with the Admin Interface to present game data, timings, and controls to game administrators.
• All microservices are containerized (each service includes its Dockerfile and related configuration), and docker-compose is used to manage inter-service orchestration.
Architectural Patterns and Technologies
• The project is structured based on a microservices architecture:
• Each service (chat, round manager, admin) is isolated with its own codebase, Docker configuration, and runtime.
• The React-based User Interface and Streamlit-based Admin Interface emphasize a clear separation of client responsibilities.
• Use of containerization (Dockerfiles per service) implies a cloud-native design that can leverage orchestrators.
• API gateways or routers exist within each microservice (for instance, chat_router in chat_service, round_router in admin_service, etc.) to encapsulate endpoints.
• The design promotes separation of concerns through service-specific directories and dedicated configuration files.
• Additional libraries and frameworks include Chainlit (for chat service), Streamlit (for admin interface), and React (for user interface).
Elements
• Components: Label nodes for "Chat Service", "Round Manager Service", "Admin Service", "User Interface (React)", "Admin Interface (Streamlit)", and "Database (MySQL)/Storage".
• Data flow from the User Interface to the Chat Service.
• Communication from the Round Manager Service to both Chat and Admin Services.
• Interactions between each service and the Database.
• External calls to the OpenAI API from the Chat Service.
• Dependencies of the admin/dashboard side that interacts with administrative APIs.