How emeraldpathways/lilicfversusai works
Purpose and entry points
This is an academic demo that compares a collaborative-filtering (CF) recommender with an agentic/LLM-enhanced recommendation workflow using the H&M Personalized Fashion Recommendations CSV dataset. The runtime entry points are FastAPI in backend/app/main.py and a Next.js App Router dashboard rooted at frontend/app/page.tsx. The experiment is initiated through POST /experiment/run; the frontend calls backend APIs through frontend/lib/api.ts.
API and experiment orchestration
FastAPI routes divide the system into experiment lifecycle, users, recommendations, and metrics boundaries:
• backend/app/api/experiment.py starts runs and exposes setup state.
• backend/app/api/users.py serves inferred user intent and accepts feedback.
• backend/app/api/recommendations.py exposes per-user CF-versus-agentic comparisons.
• backend/app/api/metrics.py exposes aggregate evaluation outputs.
backend/app/main.py assembles the application, including frontend-origin integration configured through backend/app/config.py.
Data ingestion and local artifact boundary
The pipeline consumes uncommitted H&M source files from backend/app/data/raw/: transactions, articles, and customers. backend/app/services/data_service.py is the data-processing boundary, using pandas to load, transform, and prepare model-ready data. Derived experiment state/artifacts are retained locally under backend/app/data/processed/, making the system file-backed rather than database-backed.
Recommendation engines
The baseline recommendation path is implemented by backend/app/services/cf_service.py, which produces collaborative-filtering recommendations from prepared interaction data. The agentic path is implemented by backend/app/services/agentic_service.py; it interprets user intent and produces augmented recommendations or explanations. These engines are coordinated as part of the same run rather than exposed as independent infrastructure services.
Experiment state and evaluation
backend/app/services/experiment_service.py owns lifecycle orchestration: prepare data, execute both recommendation approaches, persist/refresh available experiment results, and provide state used by API handlers. backend/app/models/experiment_state.py represents experiment-level state, while request/response contracts reside in backend/app/models/schemas.py. backend/app/services/evaluation_service.py computes comparative metrics consumed by /metrics and the dashboard.
LLM and external-service boundary
The agentic service integrates with the OpenAI API, using OPENAI_API_KEY and optionally OPENAI_MODEL (default gpt-4.1-mini). This external dependency is specifically used for user-intent interpretation and recommendation explanations; CF and evaluation operate locally. The backend also accepts FRONTEND_ORIGIN to control browser access from the separately deployed Next.js frontend.
Frontend research workflow
The frontend is a multi-page dashboard rather than a generic consumer app. Its pages map to the experiment narrative:
• setup and processing: frontend/app/research-setup/page.tsx, frontend/app/data-processing/page.tsx
• intent inspection: frontend/app/user-intention/page.tsx
• side-by-side recommendation comparison: frontend/app/comparison/page.tsx
• aggregate evaluation: frontend/app/evaluation/page.tsx
Reusable visualization and exploration components, including frontend/components/ComparisonExplorer.tsx, frontend/components/UserIntentExplorer.tsx, and frontend/components/ModelComparisonTable.tsx, render API-derived experiment outputs.
Main entry points: experiment_service.py Experiment orchestrator · main.py FastAPI application · .gitkeep Processed artifacts · page.tsx Research workflow pages
Components 20
Research dashboard
Next.js App Router workflow for running and inspecting the experiment.
- Dashboard entry
frontend/app/page.tsx - Research workflow pages · Setup, processing, intent, comparison, and evaluation views.
frontend/app/research-setup/page.tsx - Exploration components · Renders intent and side-by-side recommendation exploration.
frontend/components/ComparisonExplorer.tsx - Model comparison table
frontend/components/ModelComparisonTable.tsx - Backend API client
frontend/lib/api.ts
Experiment backend
FastAPI orchestration, recommendation engines, and evaluation.
- FastAPI application · Assembles routes and frontend-origin access control.
backend/app/main.py - Runtime configuration · Controls frontend origin and OpenAI settings.
backend/app/config.py - Experiment lifecycle API · Starts runs and exposes setup state.
backend/app/api/experiment.py - Users API · Serves inferred intent and accepts feedback.
backend/app/api/users.py - Recommendations API · Returns per-user CF versus agentic comparisons.
backend/app/api/recommendations.py - Metrics API · Exposes aggregate comparative evaluation.
backend/app/api/metrics.py - Experiment orchestrator · Prepares data, runs both approaches, and refreshes results.
backend/app/services/experiment_service.py - Data preparation · Loads and transforms H&M data into model-ready interactions.
backend/app/services/data_service.py - CF recommender · Produces baseline recommendations from prepared interactions.
backend/app/services/cf_service.py - Agentic recommender · Interprets intent and augments recommendations with explanations.
backend/app/services/agentic_service.py - Comparative evaluation · Computes metrics for the two recommendation approaches.
backend/app/services/evaluation_service.py - Experiment state
backend/app/models/experiment_state.py
Local data artifacts
CSV inputs and file-backed derived experiment state.
- H&M source CSVs · Transactions, articles, and customers supplied outside version control.
backend/app/data/raw/.gitkeep - Processed artifacts · File-backed prepared data and experiment outputs.
backend/app/data/processed/.gitkeep
Other components
- OpenAI API · Used only for intent interpretation and recommendation explanations.
Connections 25
- Dashboard entry → Research workflow pages: navigates research flow
- Research workflow pages → Exploration components: uses
- Research workflow pages → Model comparison table: uses
- Dashboard entry → Backend API client: requests experiment data
- Backend API client → FastAPI application: HTTP API calls
- Runtime configuration → FastAPI application: configures origin access
- FastAPI application → Experiment lifecycle API: routes
- FastAPI application → Users API: routes
- FastAPI application → Recommendations API: routes
- FastAPI application → Metrics API: routes
- Experiment lifecycle API → Experiment orchestrator: starts and reads runs
- Users API → Experiment orchestrator: reads intent and feedback state
- Recommendations API → Experiment orchestrator: reads comparisons
- Metrics API → Comparative evaluation: reads metrics
- Experiment orchestrator → Data preparation: prepares data
- H&M source CSVs → Data preparation: loads CSVs
- Data preparation → Processed artifacts: writes prepared artifacts
- Experiment orchestrator → CF recommender: executes baseline
- Experiment orchestrator → Agentic recommender: executes agentic path
- Experiment orchestrator → Comparative evaluation: evaluates approaches
- Experiment orchestrator → Experiment state: maintains lifecycle state
- Experiment orchestrator → Processed artifacts: persists results
- Processed artifacts → CF recommender: supplies interactions
- Agentic recommender → OpenAI API: intent and explanations
- Comparative evaluation → Processed artifacts: stores metrics