How mjlee0914/rag-enterprise-api-assignment works
This is a FastAPI enterprise RAG API with three product workflows: policy-document chat, hybrid and personalized product recommendations, and RAGAS evaluation/regression. The graph follows documented endpoints and sampled router/service calls; unsampled implementations are represented only where the README establishes their capabilities. Dashed edges mark external model or storage dependencies whose specific runtime calls were not shown.
Main entry points: vector_store.py Model and vector access · main.py FastAPI application · router.py Recommendation routes · dataset_builder.py Golden dataset and outputs
Components 29
Shared infrastructure
- FastAPI application
src/main.py - Configuration
src/shared/core/config.py - Model and vector access
src/shared/core/vector_store.py - API response schema
src/shared/core/schemas.py - Exception handling
src/shared/core/exception_handlers.py - Shared exceptions
src/shared/core/exceptions.py - Logging
src/shared/core/logger.py
Policy chatbot
- Chatbot routes
src/v1/chatbot/router.py - Chunking preview
src/v1/chatbot/chunker.py - Document indexing
src/v1/chatbot/indexer.py - Policy answers
src/v1/chatbot/generator.py - Policy retrieval
src/v1/chatbot/retriever.py - Chat request models
src/v1/chatbot/schemas.py
Product recommendations
- Recommendation routes
src/v1/recommend/router.py - Catalog sync
src/v1/recommend/catalog_loader.py - BM25 retrieval
src/v1/recommend/bm25_retriever.py - Hybrid RRF search
src/v1/recommend/hybrid_rrf.py - Activity query rewrite
src/v1/recommend/query_rewrite.py - Candidate reranking
src/v1/recommend/reranker.py - Recommendation models
src/v1/recommend/schemas.py
Evaluation and regression
- Evaluation routes
src/v1/evaluations/router.py - Golden dataset and outputs
src/v1/evaluations/dataset_builder.py - RAGAS metrics
src/v1/evaluations/metrics_runner.py - Failure diagnosis
src/v1/evaluations/failure_analyzer.py - Regression service
src/v1/evaluations/regression_service.py - Evaluation models
src/v1/evaluations/schemas.py
Other components
- API client
- PostgreSQL pgvector
- LLM and embeddings
Connections 43
- API client → FastAPI application: sends requests
README.md - FastAPI application → Chatbot routes: registers routes
src/main.py - FastAPI application → Recommendation routes: registers routes
src/main.py - FastAPI application → Evaluation routes: registers routes
src/main.py - FastAPI application → Configuration: loads settings
src/main.py - FastAPI application → Model and vector access: initializes collections
src/main.py - FastAPI application → Exception handling: registers handlers
src/main.py - Exception handling → Shared exceptions: handles
src/shared/core/exception_handlers.py - Exception handling → API response schema: formats failures
src/shared/core/exception_handlers.py - Exception handling → Logging: logs errors
src/shared/core/exception_handlers.py - Model and vector access → Configuration: reads settings
src/shared/core/vector_store.py - Model and vector access → PostgreSQL pgvector: connects to
README.md - Model and vector access → LLM and embeddings: creates clients
src/shared/core/vector_store.py - Chatbot routes → Chunking preview: previews chunks
src/v1/chatbot/router.py - Chatbot routes → Document indexing: indexes documents
src/v1/chatbot/router.py - Chatbot routes → Policy answers: answers questions
src/v1/chatbot/router.py - Chatbot routes → API response schema: wraps results
src/v1/chatbot/router.py - Document indexing → Chunking preview: chunks documents
src/v1/chatbot/indexer.py - Document indexing → Model and vector access: stores vectors
src/v1/chatbot/indexer.py - Policy answers → Policy retrieval: retrieves context
src/v1/chatbot/generator.py - Policy answers → Model and vector access: accesses vector store
src/v1/chatbot/generator.py - Policy retrieval → Model and vector access: searches vectors
src/v1/chatbot/retriever.py - Recommendation routes → Catalog sync: syncs catalog
src/v1/recommend/router.py - Recommendation routes → Hybrid RRF search: runs hybrid search
src/v1/recommend/router.py - Recommendation routes → Activity query rewrite: rewrites activity query
src/v1/recommend/router.py - Recommendation routes → Candidate reranking: reranks candidates
src/v1/recommend/router.py - Recommendation routes → API response schema: wraps results
src/v1/recommend/router.py - Catalog sync → Model and vector access: stores catalog
src/v1/recommend/catalog_loader.py - Hybrid RRF search → BM25 retrieval: gets keyword ranks
src/v1/recommend/hybrid_rrf.py - Hybrid RRF search → Model and vector access: gets vector ranks
src/v1/recommend/hybrid_rrf.py - Activity query rewrite → Model and vector access: invokes language model
src/v1/recommend/query_rewrite.py - Candidate reranking → Model and vector access: invokes language model
src/v1/recommend/reranker.py - Evaluation routes → Golden dataset and outputs: loads dataset and outputs
src/v1/evaluations/router.py - Evaluation routes → Regression service: runs regression
src/v1/evaluations/router.py - Evaluation routes → API response schema: wraps results
src/v1/evaluations/router.py - Golden dataset and outputs → Hybrid RRF search: searches candidates
src/v1/evaluations/dataset_builder.py - Golden dataset and outputs → Activity query rewrite: rewrites queries
src/v1/evaluations/dataset_builder.py - Golden dataset and outputs → Candidate reranking: reranks candidates
src/v1/evaluations/dataset_builder.py - Golden dataset and outputs → Model and vector access: runs baseline search
src/v1/evaluations/dataset_builder.py - Regression service → Golden dataset and outputs: collects outputs
src/v1/evaluations/regression_service.py - Regression service → RAGAS metrics: measures outputs
src/v1/evaluations/regression_service.py - Regression service → Failure diagnosis: diagnoses failures
src/v1/evaluations/regression_service.py - RAGAS metrics → Model and vector access: uses vector access
src/v1/evaluations/metrics_runner.py