|
| 1 | +# AI_CONTEXT.md |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +## Project Purpose |
| 6 | +Production-grade AI Resume Analyzer & Career Assistant. Demonstrates reliable AI orchestration, validation, monitoring, and deployment for MLOps/AI system design. |
| 7 | + |
| 8 | +## Architecture Summary |
| 9 | +- **Frontend**: React (Vite, TailwindCSS) |
| 10 | +- **Backend**: FastAPI (Python 3.11) |
| 11 | +- **AI Layer**: Gemini API (structured output, fallback to heuristics) |
| 12 | +- **Containerization**: Docker, docker-compose |
| 13 | +- **Deployment**: Backend (Render), Frontend (Firebase Hosting) |
| 14 | + |
| 15 | +## Component Boundaries |
| 16 | +- **Frontend**: UI, form validation, error display, health status, API calls |
| 17 | +- **Backend**: API endpoints, validation, AI orchestration, fallback, monitoring, error handling |
| 18 | +- **AI Layer**: Gemini API integration, schema enforcement, fallback logic |
| 19 | +- **Monitoring**: In-memory metrics, `/metrics` endpoint |
| 20 | + |
| 21 | +## Key Workflows |
| 22 | +1. User submits resume (text/file), target role, job description |
| 23 | +2. Backend validates input, extracts text if needed |
| 24 | +3. AI analysis via Gemini (timeout/retry); fallback to heuristics if needed |
| 25 | +4. Structured JSON response returned |
| 26 | +5. Metrics and logs recorded for every request |
| 27 | + |
| 28 | +## Deployment Model |
| 29 | +- **Backend**: Dockerized, deployed via Render (`render.yaml`), health checks on `/health` |
| 30 | +- **Frontend**: Static build, deployed to Firebase Hosting (`firebase.json`) |
| 31 | +- **Local**: `docker-compose.yml` for unified dev |
| 32 | +- **Secrets**: Managed via environment variables (`.env`) |
| 33 | + |
| 34 | +## API Contracts Summary |
| 35 | +- **POST `/analyze`**: multipart/form-data, fields: `resume_text` or `resume_file`, `target_role`, `job_description`. Returns JSON: `{ ats_score, missing_skills, strengths, recommendations }` |
| 36 | +- **GET `/health`**: `{ status, environment, gemini_configured }` |
| 37 | +- **GET `/metrics`**: `{ total_requests, total_errors, average_latency_ms, requests_by_path }` |
| 38 | + |
| 39 | +## Reliability Assumptions |
| 40 | +- Strict schema validation (Pydantic) for all input/output |
| 41 | +- Timeout/retry for AI calls |
| 42 | +- Fallback to local analysis if Gemini fails |
| 43 | +- Centralized error handling, structured logging |
| 44 | +- Health/metrics endpoints for observability |
| 45 | + |
| 46 | +## Security Constraints |
| 47 | +- Input validation/sanitization for all user data |
| 48 | +- Only PDF/TXT files accepted, size-limited |
| 49 | +- No persistent user data storage |
| 50 | +- Secrets never hardcoded; loaded from env |
| 51 | +- CORS restricts frontend origins |
| 52 | +- Error responses never leak sensitive info |
| 53 | +- Backend container runs as non-root |
| 54 | + |
| 55 | +## Operational Conventions |
| 56 | +- All config via environment variables |
| 57 | +- All errors/logs include request IDs |
| 58 | +- Monitoring via `/metrics` (in-memory, not persistent) |
| 59 | +- Health via `/health` |
| 60 | +- No database or persistent storage |
| 61 | +- All deployments must pass health/metrics checks |
| 62 | + |
| 63 | +## Important Engineering Rules |
| 64 | +- Never bypass schema validation |
| 65 | +- Always log errors with context |
| 66 | +- Fallback logic must be enabled for reliability |
| 67 | +- All new endpoints require strict request/response models |
| 68 | +- No sensitive data in logs or responses |
| 69 | +- All changes must be documented for future agents |
| 70 | + |
| 71 | +## Extension Guidance |
| 72 | +- Add endpoints by creating new routers/services (backend) |
| 73 | +- Extend AI logic in Gemini/heuristic services |
| 74 | +- Add validation/monitoring layers as needed |
| 75 | +- Update frontend components for new features |
| 76 | +- Always enforce schema validation and structured outputs |
| 77 | +- Document all changes in agent-native docs |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +**This file is the canonical, condensed context for AI agents.** |
0 commit comments