How bhuvan128/career-ai-backend works
Purpose and Runtime
Career AI is a Python/FastAPI backend for AI-driven student career guidance: personalized roadmaps, mentor chat, mock interviews, evaluations, progress analytics, and gamification. The ASGI entry point is app/main.py; it is run with uvicorn app.main:app. Deployment is containerizable via Dockerfile and documented for Render. A React frontend is an external consumer.
HTTP API Boundary
Route modules expose feature-oriented API endpoints and translate request/response schemas into service calls. Core endpoint groups include:
• Chat and AI mentoring: app/api/routes/chat.py
• Roadmap generation and diagnosis: app/api/routes/roadmap.py, app/api/routes/diagnosis.py
• Interview workflows: app/api/routes/interview.py
• Analytics, gamification, internships, and auth: app/api/routes/analytics.py, app/api/routes/gamification.py, app/api/routes/auth.py
Health endpoints are isolated in app/api/routes/health.py.
Application Services and Engines
Business behavior is concentrated in services rather than route handlers. AI-facing flows use dedicated engines/services for roadmap creation, conversational mentoring, mock interviews, assessment, and portfolio projects:
• app/services/roadmap_engine.py, app/services/diagnosis.py
• app/services/chat_service.py, app/services/interview_engine.py
• app/services/evaluation.py, app/services/project_engine.py
Engagement and reporting are separate stages: app/services/analytics_engine.py derives user insights, while app/services/streak_engine.py tracks daily activity. app/services/video_service.py is a separate integration boundary for video-related functionality.
LLM Provider Boundary
The repository uses an abstraction layer so feature services do not directly depend on a single model vendor. app/services/llm/base.py defines the provider contract; app/services/llm/factory.py selects the configured implementation. Provider adapters include app/services/llm/openai_provider.py, app/services/llm/claude_provider.py, app/services/llm/gemini_provider.py, and app/services/llm/groq_provider.py.
Control flow for AI features is: HTTP route → feature service/engine → LLM factory/provider → external LLM API → structured response returned through the route. Provider choice and API credentials are environment-driven configuration.
Persistence, Identity, and Data Contracts
Supabase PostgreSQL is the persistence and authentication platform. Database setup/access is centralized in app/core/database.py; authentication/authorization dependencies and security logic sit in app/core/dependencies.py and app/core/security.py. Domain persistence models cover users, roadmaps, chat, analytics, gamification, and projects:
• app/models/user.py, app/models/roadmap.py, app/models/chat.py
• app/models/analytics.py, app/models/gamification.py, app/models/project.py
Pydantic-style API contracts are separated from persistence models in app/schemas/, notably app/schemas/user.py, app/schemas/roadmap.py, and app/schemas/chat.py.
Cross-Cutting Control
Runtime settings, including Supabase and LLM provider configuration, are owned by app/config.py. Request logging and centralized exception-to-response handling are middleware concerns in app/middleware/logging.py and app/middleware/error_handler.py; shared exception definitions reside in app/core/exceptions.py. This keeps transport concerns outside feature engines.
Main End-to-End Flows
1. Authenticated users submit goals, diagnoses, chat messages, or interview responses through route modules.
2. Routes validate schemas and resolve shared auth/database dependencies.
3. Feature engines combine user context and request data, invoke the selected LLM when generation/evaluation is required, and persist relevant roadmap, chat, analytics, or gamification state in Supabase.
4. Analytics and streak services consume recorded activity to produce progress insights and engagement state for later API reads.
Main entry points: chat.py Feature routes · roadmap_engine.py Guidance engines · database.py Database access · main.py FastAPI ASGI app
Components 18
HTTP API
FastAPI transport boundary.
- FastAPI ASGI app
app/main.py - Feature routes · Chat, roadmap, diagnosis, interview, analytics, gamification, and auth endpoints.
app/api/routes/chat.py - Health routes
app/api/routes/health.py - API schemas
app/schemas/roadmap.py
Application Services
Feature engines and supporting workflows.
- Guidance engines · Roadmap, diagnosis, chat, interview, evaluation, and project workflows.
app/services/roadmap_engine.py - Analytics and streaks · Derives progress insights and daily activity state.
app/services/analytics_engine.py - Video service
app/services/video_service.py
LLM Abstraction
Configurable provider selection layer.
- LLM provider contract
app/services/llm/base.py - LLM factory
app/services/llm/factory.py - LLM adapters · OpenAI, Claude, Gemini, and Groq implementations.
app/services/llm/openai_provider.py
Platform
Runtime, identity, persistence, and cross-cutting concerns.
- Runtime settings · Environment-driven Supabase and LLM configuration.
app/config.py - Auth dependencies
app/core/dependencies.py - Logging and error middleware
app/middleware/error_handler.py - Database access
app/core/database.py - Domain models · Users, roadmaps, chat, analytics, gamification, and projects.
app/models/user.py
Other components
- React frontend
- External LLM APIs
- Supabase PostgreSQL and Auth
Connections 21
- React frontend → FastAPI ASGI app: HTTP requests
- FastAPI ASGI app → Logging and error middleware: applies
- FastAPI ASGI app → Feature routes: mounts
- FastAPI ASGI app → Health routes: mounts
- Feature routes → API schemas: validates
- Feature routes → Auth dependencies: resolves identity
- Feature routes → Guidance engines: dispatches
- Feature routes → Analytics and streaks: reads insights
- Guidance engines → LLM factory: requests model
- LLM factory → LLM provider contract: uses contract
- LLM factory → LLM adapters: selects
- LLM adapters → External LLM APIs: API calls
- Runtime settings → LLM factory: selects provider
- Guidance engines → Database access: persists state
- Analytics and streaks → Database access: reads activity
- Database access → Domain models: maps
- Database access → Supabase PostgreSQL and Auth: accesses
- Auth dependencies → Supabase PostgreSQL and Auth: authenticates
- Runtime settings → Database access: Supabase config
- Guidance engines → Analytics and streaks: records activity
- Guidance engines → Video service: video workflows