How andi-nev/brawl-ai works
Main Components
• Frontend:
• Built with Next.js (using TypeScript and React) and styled with TailwindCSS.
• Contains UI components (as seen in the “frontend/app/components” folder) including API handler, display components for brawlers and maps, and overall page routing/layout.
• Backend:
• A Python service likely using FastAPI (hinted by the README badge) for its web server (see backend/src/web_server.py).
• Contains various modules for AI processing (ai.py, inference.py, pipeline.py), data handling (datasource.py, db.py, feeding.py), and external integrations (scraper.py, old_ai.py for legacy functionality).
• Database:
• While not explicitly shown as a folder (and being optional for local testing), the README indicates PostgreSQL is used.
• Backend module “db.py” manages database interactions, particularly for training and feeding processes.
• External Services:
• Brawl Stars API (for live game data) and BrawlAPI for high-quality images, as mentioned in the README.
• These should be noted as external integrations that feed data into the backend.
Relationships and Interactions
• User requests flow from the frontend (Next.js UI) to the backend (FastAPI web server) via RESTful API calls.
• The backend performs AI-based decision making (handled in modules like ai.py, inference.py) and interacts with the PostgreSQL database to retrieve or store data.
• A data ingestion pipeline is present in the backend (using scraper.py and feeding.py), ensuring the system is regularly updated with fresh game data.
• The external services (Brawl Stars API, BrawlAPI) supply additional game assets and metrics that the system may use in its decision-making processes.
Architectural Patterns and Design Principles
• Separation of concerns is clear: the frontend and backend are independently managed, with a clear API boundary between them.
• Modular design in the backend, where different Python modules handle AI, data handling, and scraping; this suggests a deferred process pipeline typical in data-driven applications.
• The design also incorporates flexibility for model training and updating, inviting potential for scalability (e.g., swap or improve the AI model without interrupting the UI).
Technologies and Their Roles
• Frontend: Next.js, React, TypeScript, TailwindCSS – Serve as the mobile-friendly, responsive UI layer.
• Backend: Python, FastAPI (inferred), PyTorch – Provide AI capabilities and data processing.
• Database: PostgreSQL – Used (optionally) to store training data and game-related statistics.
• Others: ESLint and configuration files on the frontend; Git and project dependency files ensure standardized development and deployment pipelines.
• Under the backend, create sub-components for “AI Engine” (including ai.py, inference.py, pipeline.py), “Data Handling” (datasource.py, db.py, feeding.py, scraper.py), and “Legacy Module” (old_ai.py).