How amwt24/ahorrec works
Project Type & Purpose
• Full-stack, microservices-style platform for real-time supermarket price comparison + AI-powered cooking assistant.
• Frontend: React/TypeScript SPA.
• Backend: FastAPI REST service.
• Data/IA pipeline: Scrapy spiders, filtering, vectorization scripts.
• Persistence: relational or document DB + vector store.
• External AI: LLM (Gemini, etc.) for recipe generation.
High-Level File Structure Analysis
• Top level
• backend/ – FastAPI app
• frontend/ – React SPA
• scrapersAhorrEC/ – Scrapy ETL service
• docker-compose.yml – orchestrates containers
• CI configs (GitHub Actions, Jenkinsfile)
• backend/
• routes.py – HTTP controllers
• services/ – business logic modules (shopping, recipes, ranking, embeddings, etc.)
• chef_service.py – LLM integration
• database.py – DB connectivity
• scripts/ – offline utilities (vectorize_products.py)
• frontend/
• src/app/components – UI widgets and views
• config.ts, hooks/, styles/ – configuration, state hooks, styling
• scrapersAhorrEC/
• spiders/ – one per supermarket
• pipelines.py, middlewares.py – data processing
• scripts/ – filter_food.py, upload_recetas.py
Key Components
a. Client Layer
– Browser/mobile running React SPA
b. API Layer
– FastAPI service (routes → service modules → DB / vector store / LLM)
c. Data Pipeline
– Scrapy container: spiders → raw JSON
– Filter/ETL scripts → Database + Vector DB
– Vectorization script → Vector DB
d. Persistence
– Primary DB (Postgres/Mongo) for products, users, history
– Vector store (e.g., Pinecone) for embedding-based ranking
e. External AI Service
– Gemini/OpenAI APIs for recipe generation
f. DevOps & Infra
– Docker/Docker Compose
– CI/CD pipelines (GitHub Actions, Jenkins)
– (Optional) Cloud load balancer, container registry
Data Flows & Interactions
• User → Frontend (UI) → HTTP(S) → FastAPI routes
• FastAPI → Services → Database (CRUD)
• FastAPI → Embedding Service → Vector store (k-NN queries)
• FastAPI → Chef Service → LLM API → response → UI
• Scheduled ETL: Scrapy spiders → raw JSON → filter_food → upload_recetas → DB & Vector DB
• Scripts/vectorize_products run offline or on CI trigger → update vector store
Architectural Patterns & Principles
• Microservices / separation of concerns
• Layered architecture in backend (Controller → Service → Data)
• Asynchronous ETL vs. synchronous API
• SPA decoupled from backend API
• Containerization for environment consistency