How yashksaini-coder/hack-agent-server works
Project type and purpose
• This is a monolithic, full‑stack web application whose backend is a REST API server built with FastAPI.
• It also serves server‑rendered pages (via Jinja2 templates) and static assets under “public.”
• It integrates with an external AI library (Agno) and likely caches or brokers data through Redis.
File structure
• Top level:
• app.py – entrypoint that instantiates FastAPI, mounts routers, templates, static files.
• Dockerfile + docker‑compose.yaml – containerization (app + Redis).
• requirements.txt – Python dependencies.
• .env.example – configuration variables (e.g., Redis URL, Render deploy settings).
• controllers/ – business logic for each feature (agent, chat, stock analysis, news, top stocks).
• routes/ – HTTP routing layer that delegates to controllers.
• templates/ – Jinja2 templates for server‑rendered HTML pages.
• public/ – static assets (images, CSS, JS).
• scripts/ – support scripts (health check ping).
Key insights from README
• FastAPI framework serves both REST endpoints and Jinja2 templates.
• Agno library is invoked within controllers to obtain AI predictions.
• Deployed via Docker Compose (app + Redis).
• Hosted on Render (single‑port service).
Main components & their relationships
a. Client (Browser or API consumer)
b. FastAPI App (Docker container)
• Route Layer (routes/*.py)
• Controller Layer (controllers/*.py)
• Template Engine (templates/) & Static Server (public/)
c. Redis (cache / message broker)
d. External AI Service (Agno)
e. External Stock Data Providers (third‑party APIs)
f. GitHub Actions (ping workflow) – optional, for uptime checks
• Flow example:
1. Client → HTTP GET/POST → Route (/stock, /chat, /agent, etc.)
2. Route → invokes appropriate Controller
3. Controller → checks Redis cache → if miss, fetch stock data from external API
4. Controller → calls Agno AI library for predictions
5. Controller → writes/reads Redis as needed
6. Controller → returns JSON or renders HTML via Jinja2 templates
7. FastAPI → HTTP response → Client
Architectural patterns & design principles
• Layered MVC‑like separation: Routes (Controller interface) → Controllers (Business logic) → External Services
• Single‑process monolith wrapped in containers
• Use of caching layer (Redis) to improve performance
• External AI integration decoupled via library calls (Agno)
• Container orchestration via Docker Compose