How moubarak1ezzyani/retention-ai-api works
Retention AI is a FastAPI HR decision-support backend: HR users authenticate, submit employee features for churn scoring, and can request a risk-based retention plan. The README also documents prediction-history and health endpoints; utilities are included as a product branch. Source excerpts confirm prediction persistence, while the retention handler's history write is commented out. Unsampled utilities are represented at their exact file path, with relationships limited to indexed references.
Main entry points: main.py FastAPI app · auth.py Authentication · predict.py Churn prediction · retention.py Plan endpoint
Components 16
API workflows
- FastAPI app
app/main.py - Request schemas
app/db/schemas.py - Health and history
app/api/routers/utils.py
Identity and access
- Authentication
app/api/routers/auth.py - JWT security
app/core/security.py - Access dependencies
app/api/dependencies.py
Retention decisions
- Churn prediction
app/api/routers/predict.py - Plan endpoint
app/api/routers/retention.py - ML inference
app/services/ml_service.py - Plan generation
app/services/llm_service.py
Persistence
- Database queries
app/db/crud.py - Database models
app/db/models.py - DB session setup
app/db/database.py
Other components
- HR client
- PostgreSQL
- Hugging Face API
Connections 25
- HR client → FastAPI app: sends requests
README.md - FastAPI app → Authentication: registers router
app/main.py - FastAPI app → Churn prediction: registers router
app/main.py - FastAPI app → Plan endpoint: registers router
app/main.py - FastAPI app → Health and history: registers router
app/main.py - Authentication → Database queries: reads and creates users
app/api/routers/auth.py - Authentication → JWT security: hashes and verifies
app/api/routers/auth.py - Authentication → Access dependencies: opens DB session
app/api/routers/auth.py - Access dependencies → DB session setup: creates session
app/api/dependencies.py - Access dependencies → Database models: loads user
app/api/dependencies.py - Churn prediction → ML inference: scores features
app/api/routers/predict.py - Churn prediction → Database queries: records prediction
app/api/routers/predict.py - Churn prediction → Access dependencies: requires user and DB
app/api/routers/predict.py - Plan endpoint → ML inference: scores features
app/api/routers/retention.py - Plan endpoint → Plan generation: requests plan
app/api/routers/retention.py - Plan endpoint → Access dependencies: requires user and DB
app/api/routers/retention.py - Plan generation → Hugging Face API: generates plan
app/services/llm_service.py - Health and history → Database queries: uses history queries
app/api/routers/utils.py - Database queries → Database models: queries records
app/db/crud.py - Database models → DB session setup: uses ORM base
app/db/models.py - DB session setup → PostgreSQL: connects
app/db/database.py - FastAPI app → DB session setup: creates tables
app/main.py - Churn prediction → Request schemas: accepts and returns
app/api/routers/predict.py - Plan endpoint → Request schemas: accepts and returns
app/api/routers/retention.py - Authentication → Request schemas: accepts and returns
app/api/routers/auth.py