How bhupencod3/perfectpick works
Project Type and Purpose
• This is a full-stack, AI-driven e-commerce recommendation application.
• It consists of a Flask-based web UI, a Python recommendation service (the “PerfectPick” package), a NoSQL database (AstraDB/Cassandra), and a containerized deployment with Kubernetes, Prometheus, and Grafana for monitoring.
File Structure
• Top-level code:
• app.py, main.py: Flask entry points
• perfectpick/: Core recommendation library modules (data_ingestion, data_converter, retrieval, generation, recommender, service, session_memory, config)
• notebooks/: Exploratory analysis
• static/, templates/: Frontend assets (CSS, HTML)
• Deployment:
• Dockerfile, deployment/*: Scripts & K8s manifests (deployments, services, ingress, HPA, ConfigMaps, Secrets)
• deployment/prometheus/*, deployment/grafana/*: Monitoring stack definitions
• Utilities and tests under utils/ and tests/.
README Insights
• AI/ML components: LangChain, HuggingFace, Groq
• Database: AstraDB (Cassandra)
• Monitoring: Prometheus + Grafana
• Orchestration: Docker + Minikube/Kubernetes
Main Components and Their Relationships
a. Frontend (Flask + HTML/CSS)
• Templates (templates/index.html) and static assets (static/style.css)
• Exposes HTTP endpoints (app.py/main.py)
b. Backend Service (“PerfectPick”)
• Data Ingestion & Conversion: cleans and prepares mobile data (data_ingestion.py, data_converter.py)
• Retrieval & Generation: fetches candidate products and generates recommendations using LLMs (retrieval.py, generation.py)
• Recommender Core: ranking and personalization logic (recommender.py)
• Session & Service Layer: manages user sessions and API logic (session_memory.py, service.py)
c. Database (AstraDB/Cassandra)
• Stores user sessions, product metadata, recommendation logs
• Accessed via PerfectPick’s config and data layers
d. External AI Services
• LangChain orchestration, Groq compute, HuggingFace APIs
e. Monitoring & Logging
• Prometheus scrapes metrics endpoints exposed by Flask and PerfectPick
f. Containerization & Orchestration
• Docker container built from Dockerfile
• Kubernetes objects: Namespaces, Deployment, Service, Ingress, ConfigMap, Secret, HPA
• Helm-style scripts under deployment/deploy-all.sh and entrypoint.sh
Architectural Patterns & Design Principles
• Monolithic microservice for backend with clear module boundaries (data, retrieval, recommendation, service).
• Separation of concerns: frontend UI vs. backend logic vs. data storage vs. monitoring.
• MLOps pipeline: data ingestion → model invocation → results stored & served.
• Twelve-factor: externalize config (dotenv, K8s ConfigMaps/Secrets), logs to stdout, dependencies via requirements.txt.
• Async or sync calls to external AI APIs.
• Monitoring endpoints (e.g., /metrics) and the scrape configuration in Prometheus.
• Grafana dashboards reading from Prometheus.