How saolsen/gameplay.computer works
Frontend Components
• Web Interface: Built with HTMX and DaisyUI, facilitating user interactions for gameplay and agent creation.
• Web Clients: Specific components like web.tsx in gameplay_computer/agents and matches handle user interactions and display.
Backend Components
• API Layer: Powered by Hono, managing requests between frontend and backend services.
• Game Logic: Located in the gameplay/ directory, handling game rules and agent behaviors.
• Agent Services: Various agents (connect4_agent_*.ts, poker_agent_*.ts) implementing AI strategies.
Database
• Turso (SQLite): Manages persistent data such as user profiles, game histories, and agent configurations.
Infrastructure & Configuration
• Configuration Files: deno.json, drizzle.config.ts for environment setup and database configurations.
• Migrations: SQL scripts for database schema management.
b. Determine Relationships and Interactions
• Frontend ↔ API Layer: The web interface communicates with the API layer to send user actions and receive responses.
• API Layer ↔ Game Logic: Handles requests related to game operations, leveraging the game logic for rule enforcement and agent interactions.
• Game Logic ↔ Agent Services: The game logic invokes appropriate agent services based on the game and user interactions.
• API Layer ↔ Database: Reads and writes data pertaining to users, games, and agents.
• Configuration & Migration Tools: Ensure the backend environment and database are correctly set up and maintained.
c. Highlight Architectural Patterns and Design Principles
• Modular Architecture: Separation of concerns with distinct directories for agents, gameplay logic, and frontend components.
• MVC Pattern: Likely employed in the frontend (Model-View-Controller) with web.tsx as views, controllers handling user input, and models representing game states.
• Microservices Approach: Although not fully distributed, the separation of agents can be viewed as distinct services interacting through the API layer.
• Configuration as Code: Use of configuration files (deno.json, drizzle.config.ts) and migration scripts aligns with Infrastructure as Code principles.
d. Include Relevant Technologies, Frameworks, or Libraries
• Deno: Backend runtime for executing TypeScript and JavaScript.
• Hono: Web framework facilitating API development.
• Turso (SQLite): Database solution for data persistence.
• HTMX: Enhances frontend interactivity without heavy JavaScript frameworks.
• DaisyUI (Tailwind CSS): Provides pre-designed UI components for rapid frontend development.
Elements
• Clear Labels for Each Component: Frontend (Web Interface), Backend (API Layer, Game Logic, Agent Services), Database (Turso), Configuration Tools.
• Frontend: Blue rectangles.
• Backend Services: Green rectangles.
• Configuration: Yellow hexagons.
Frontend Layer
• Web Interface (HTMX + DaisyUI)
• User Dashboard
• Game Play Pages (web.tsx components)
• Agent Creation Interface
Backend Layer
• API Server (Hono)
• Routes for Gameplay
• Routes for Agent Management
• Game Logic (gameplay/)
• 4 Module
• Poker Module
• Agent Services (agents/)
• 4 Agents
• MCTS Agent
• Random Agent
• Poker Agents
• All-in Strategy
• Folding Strategy
Database
• Turso (SQLite)
• User Data
• Game Histories
• Agent Configurations
Infrastructure
• Configuration Files
• deno.json
• drizzle.config.ts
• Migration Tools
• SQL Scripts
• Migration Metadata
External Interfaces
• Deployment
• Hosting URL: https://gameplay.computer
• Developer Resources
• Agent Creation Guide: https://jsr.io/@gameplay/games