How jan-dyndor/llm_spam works
LLM Spam Classifier is an authenticated FastAPI service that classifies message text with Gemini, validates structured results, caches them, and stores prediction history. Its other documented product workflow evaluates the model against a golden dataset and persists metrics and per-example outputs. The graph also includes the documented logging and metrics observability stack. Router excerpts are partial, so links for unsampled endpoint behavior are based on README descriptions; peripheral wiring is omitted.
Main entry points: v1.py v1 API router · spam_classification.py Spam classification · main.py App lifecycle and telemetry · database.py Async database access
Components 21
API and identity
- v1 API router
src/app/routers/v1.py - JWT and passwords
src/app/authentication/auth.py - Request and response schemas
src/app/schemas/pydantic_schemas.py
Classification
- Spam classification
src/app/services/spam_classification.py - Classification prompt
src/app/prompts/prompt_v1.py - Gemini client
src/app/llm_clients/gemini.py - Retry policy
src/app/retry_utils/retry.py - Redis cache
Persistence
- Async database access
src/app/db/database.py - Persistent models
src/app/db/db_models.py
Model evaluation
- Evaluation workflow
src/app/evaluation/evaluate_model.py - Golden dataset
src/app/evaluation/golden_data_set/golden_data.py
Observability
- App lifecycle and telemetry
src/app/main.py - Prometheus
- Prometheus scrape config
prometheus/prometheus.yml - Alloy log collection
alloy/config.alloy - Loki log store
loki/loki-config.yml - Grafana dashboards
grafana/dashboards/app_dashboard.json
Other components
- API client
- Google Gemini
- PostgreSQL
Connections 25
- API client → v1 API router: sends requests
- v1 API router → Request and response schemas: validates data
- v1 API router → JWT and passwords: verifies credentials
- v1 API router → Async database access: queries and saves
- v1 API router → Spam classification: classifies text
- v1 API router → Redis cache: reads and writes cache
- Spam classification → Classification prompt: uses prompt
- Spam classification → Gemini client: requests inference
- Spam classification → Request and response schemas: validates output
- Spam classification → Retry policy: uses retry policy
- Gemini client → Google Gemini: sends inference request
- App lifecycle and telemetry → Gemini client: initializes client
- App lifecycle and telemetry → Async database access: creates schema and sessions
- App lifecycle and telemetry → Redis cache: connects and clears
- Async database access → PostgreSQL: reads and writes
- Async database access → Persistent models: maps records
- v1 API router → Evaluation workflow: runs evaluation
- Evaluation workflow → Golden dataset: reads examples
- Evaluation workflow → Spam classification: classifies examples
- v1 API router → Persistent models: persists evaluation results
- App lifecycle and telemetry → Prometheus: exposes metrics
- Prometheus scrape config → Prometheus: configures scraping
- Alloy log collection → Loki log store: ships logs
- Grafana dashboards → Prometheus: visualizes metrics
- Grafana dashboards → Loki log store: visualizes logs