How victsilva37/sugerencias-cr works
Project type and purpose
• This is a full-stack web application (“Sugerencias CR”) that analyzes a Clash Royale player’s recent battles and uses an LLM (via Groq API) to generate personalized strategy suggestions.
• Frontend is built in React + TypeScript; backend is Python + Flask; no persistent database (uses browser localStorage); integrates with two external services: Clash Royale API and Groq LLM API.
File structure
• Top level:
• README.md
• flask-project/ (backend)
• react-project/ (frontend)
• Backend (flask-project):
• app.py – Flask app entrypoint
• clash_api.py – module to fetch data from the Clash Royale API
• gpt.py – module to call the Groq LLM API and generate suggestions
• .gitignore, __pycache__
• Frontend (react-project):
• src/ – React components, pages, assets, interfaces, layouts
• public/index.html – HTML template
• package.json, tsconfig.json, vite.config.ts – build & tooling config
• localStorage used for state (no external DB/config files)
• No Docker, CI/CD, or deployment scripts present (can be added later).
Insights from the README
• Confirms tech stack: React/TypeScript frontend, Python/Flask backend.
• Mentions key features: player tag search, battle history, analysis panel, AI suggestions.
• Calls out two external integrations: official Clash Royale API and Groq LLM API.
• Notes current use of localStorage for “state” instead of a database.
a. Main components
• Client (Browser): Runs React SPA.
• Frontend Application: React components (Pages: Home, Panel; Components: Banner, InputTag, RegBatallas, Control).
• Backend Application: Flask server exposing REST endpoints.
• External Services:
– Clash Royale API (battle data)
– Groq LLM API (AI suggestions)
• Data Store: Browser localStorage (for caching user history or session).
b. Relationships & interactions
1. User interacts with React SPA in browser.
2. SPA issues HTTP requests to Flask backend (e.g., GET /player/:tag/battles).
3. Flask backend calls clash_api.py to fetch raw battle data from Clash Royale API.
4. Battle data returned to backend, optionally processed/filtered.
5. For strategy suggestions, backend calls gpt.py → Groq API with processed battle data as prompt.
6. Groq returns AI-generated suggestions; backend wraps and returns JSON to frontend.
7. Frontend displays history + AI suggestions; may cache results in localStorage.
c. Architectural patterns & principles
• Separation of Concerns: Frontend handles UI, state; backend handles data retrieval + AI logic.
• Modular code: clash_api.py and gpt.py isolate third-party API calls.
• Stateless backend: relies on external APIs, no internal DB. User state held in browser.
• Single Page Application pattern on frontend.
d. Key technologies & frameworks
• React (Vite) + TypeScript + CSS for frontend UI.
• Flask for routing and request handling.
• Requests (or equivalent) in Python for external API calls.
• localStorage for client-side state persistence.