# ateeb09/resai architecture

> Architecture diagram of the GitHub repository ateeb09/resai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ateeb09/resai
- Repository: https://github.com/ateeb09/resai

## Overview

#### 1. Purpose and Runtime Shape
CareerLift AI is a two-tier placement-preparation platform: a React single-page client and a FastAPI API. It provides resume review, interview practice, aptitude tests, coaching chat, analytics, authentication, and subscription billing. Backend entrypoint: `backend/server.py`; frontend bootstrap/router: `frontend/src/index.js`, `frontend/src/App.js`.

#### 2. Frontend Application Shell
React (CRA with CRACO) owns route-level workflows and shared visual shell. `App.js` composes routing, providers, protected pages, navigation, and sitewide features; the auth context maintains client session state and the API client centralizes backend calls.
- `frontend/src/App.js`
- `frontend/src/lib/auth.jsx`
- `frontend/src/lib/api.js`

Route pages implement the principal user journeys: resume analysis, interview simulation, timed aptitude, dashboard, and pricing. The floating career coach and OTP modal are cross-cutting UI capabilities.
- `frontend/src/pages/Resume.jsx`
- `frontend/src/pages/Interview.jsx`
- `frontend/src/pages/Aptitude.jsx`
- `frontend/src/components/Chatbot.jsx`
- `frontend/src/components/AuthModal.jsx`

#### 3. API Composition and Shared Boundaries
FastAPI composes domain routers under `/api`, configures CORS, and mediates all persistence and external-service access. Dependency logic resolves MongoDB connectivity and optional/required authenticated sessions from cookies or Bearer tokens.
- `backend/server.py`
- `backend/deps.py`
- `backend/auth_routes.py`

The client talks only to this API boundary; credentials and provider keys remain backend environment concerns.

#### 4. Identity, Persistence, and Entitlements
Passwordless email OTP creates/fetches users and issues session tokens. MongoDB persists users, sessions, OTPs, feature histories, and payment transactions. Auth is selectively enforced: dashboard requires identity, while several generation flows can operate anonymously and save history when a session is available.
- `backend/auth_routes.py`
- `backend/deps.py`
- `backend/dashboard_routes.py`

The frontend prevents access to core preparation and pricing routes through a route guard, triggering login UI rather than directly exposing protected workflows.
- `frontend/src/components/ProtectedRoute.jsx`
- `frontend/src/lib/auth.jsx`

#### 5. AI Preparation Workflows
Resume upload flows through PDF extraction, Gemini-based structured review, persistence, and optional ReportLab report generation. Interview flow generates a configured five-question session, grades each submitted answer, then saves an aggregate session. Aptitude flow generates ten MCQs, accepts timed submissions, returns explanations, and records attempts.
- `backend/resume_routes.py`
- `backend/pdf_parser.py`
- `backend/interview_routes.py`
- `backend/aptitude_routes.py`
- `backend/gemini_service.py`

Gemini is the shared intelligence boundary for resume analysis, interview generation/grading, and conversational coaching; its outputs drive UI scorecards and feedback rather than being generated in the browser.
- `backend/gemini_service.py`
- `backend/chat_routes.py`

#### 6. Analytics and Conversational Layer
Dashboard aggregation reads module histories to produce a user-specific progress view. The sitewide chat endpoint maintains contextual coaching conversations, with frontend rendering handled independently from preparation pages.
- `backend/dashboard_routes.py`
- `frontend/src/pages/Dashboard.jsx`
- `backend/chat_routes.py`
- `frontend/src/components/Chatbot.jsx`

#### 7. External Infrastructure
Material services are MongoDB (application records), Gemini 3 Flash via `emergentintegrations` (LLM), Resend (OTP delivery, with terminal fallback), Stripe Checkout/webhooks (plan upgrades), PyMuPDF (input PDFs), and ReportLab (downloadable reports). Python 3.10+ runs FastAPI; Node 18+ runs the React build/runtime.
- `backend/email_service.py`
- `backend/payment_routes.py`
- `backend/requirements.txt`
- `frontend/package.json`

Main entry points: [`backend/server.py`](https://github.com/ateeb09/resai/blob/main/backend/server.py) (API composition), [`frontend/src/App.js`](https://github.com/ateeb09/resai/blob/main/frontend/src/App.js) (App shell & routes), [`frontend/src/lib/api.js`](https://github.com/ateeb09/resai/blob/main/frontend/src/lib/api.js) (API client), [`backend/gemini_service.py`](https://github.com/ateeb09/resai/blob/main/backend/gemini_service.py) (Gemini intelligence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React client"]
  node_app["App shell &amp; routes<br/>React application<br/>[App.js]"]
  node_auth_client["Auth context<br/>client session state<br/>[auth.jsx]"]
  node_api_client["API client<br/>HTTP client<br/>[api.js]"]
  node_route_guard["Protected route<br/>route guard<br/>[ProtectedRoute.jsx]"]
  node_prep_pages["Preparation pages<br/>[Resume.jsx]"]
  node_dashboard_ui["Dashboard<br/>progress UI<br/>[Dashboard.jsx]"]
  node_coach_ui["Career coach UI<br/>floating chat UI<br/>[Chatbot.jsx]"]
end

subgraph group_backend["FastAPI API"]
  node_api_server{{"API composition<br/>FastAPI server<br/>[server.py]"}}
  node_auth_api["OTP identity<br/>auth routes<br/>[auth_routes.py]"]
  node_session_deps["Session dependencies<br/>auth &amp; database dependencies<br/>[deps.py]"]
  node_resume_api["Resume workflow<br/>resume routes<br/>[resume_routes.py]"]
  node_pdf_parser["PDF extraction<br/>PDF parser<br/>[pdf_parser.py]"]
  node_interview_api["Interview workflow<br/>interview routes"]
  node_aptitude_api["Aptitude workflow<br/>aptitude routes<br/>[aptitude_routes.py]"]
  node_gemini{{"Gemini intelligence<br/>LLM integration<br/>[gemini_service.py]"}}
  node_chat_api["Coaching chat<br/>chat routes<br/>[chat_routes.py]"]
  node_dashboard_api["Progress analytics<br/>dashboard routes"]
  node_billing_api["Subscriptions<br/>payment routes<br/>[payment_routes.py]"]
end

subgraph group_external["External services"]
  node_mongodb[("MongoDB<br/>application database")]
  node_resend["Resend<br/>OTP email service"]
  node_stripe["Stripe<br/>billing platform"]
  node_gemini_provider{{"Gemini 3 Flash<br/>LLM provider"}}
end

node_app -->|"provides session"| node_auth_client
node_app -->|"guards routes"| node_route_guard
node_app -->|"routes to"| node_prep_pages
node_app -->|"routes to"| node_dashboard_ui
node_app -->|"renders sitewide"| node_coach_ui
node_auth_client -->|"uses"| node_api_client
node_route_guard -->|"checks identity"| node_auth_client
node_prep_pages -->|"submits workflows"| node_api_client
node_dashboard_ui -->|"loads progress"| node_api_client
node_coach_ui -->|"sends chat"| node_api_client
node_api_client -->|"HTTPS /api"| node_api_server
node_api_server -->|"mounts"| node_auth_api
node_api_server -->|"mounts"| node_resume_api
node_api_server -->|"mounts"| node_interview_api
node_api_server -->|"mounts"| node_aptitude_api
node_api_server -->|"mounts"| node_chat_api
node_api_server -->|"mounts"| node_dashboard_api
node_api_server -->|"mounts"| node_billing_api
node_auth_api -->|"issues sessions"| node_session_deps
node_session_deps -->|"connects and resolves"| node_mongodb
node_auth_api -->|"delivers OTP"| node_resend
node_resume_api -->|"extracts upload text"| node_pdf_parser
node_resume_api -->|"requests review"| node_gemini
node_interview_api -->|"generates and grades"| node_gemini
node_aptitude_api -->|"generates and explains"| node_gemini
node_chat_api -->|"coaching context"| node_gemini
node_gemini -->|"emergentintegrations"| node_gemini_provider
node_resume_api -->|"saves history"| node_mongodb
node_interview_api -->|"saves sessions"| node_mongodb
node_aptitude_api -->|"records attempts"| node_mongodb
node_chat_api -->|"stores context"| node_mongodb
node_dashboard_api -->|"aggregates histories"| node_mongodb
node_billing_api -->|"checkout and webhooks"| node_stripe
node_billing_api -->|"updates entitlements"| node_mongodb

click node_app "https://github.com/ateeb09/resai/blob/main/frontend/src/App.js"
click node_auth_client "https://github.com/ateeb09/resai/blob/main/frontend/src/lib/auth.jsx"
click node_api_client "https://github.com/ateeb09/resai/blob/main/frontend/src/lib/api.js"
click node_route_guard "https://github.com/ateeb09/resai/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_prep_pages "https://github.com/ateeb09/resai/blob/main/frontend/src/pages/Resume.jsx"
click node_dashboard_ui "https://github.com/ateeb09/resai/blob/main/frontend/src/pages/Dashboard.jsx"
click node_coach_ui "https://github.com/ateeb09/resai/blob/main/frontend/src/components/Chatbot.jsx"
click node_api_server "https://github.com/ateeb09/resai/blob/main/backend/server.py"
click node_auth_api "https://github.com/ateeb09/resai/blob/main/backend/auth_routes.py"
click node_session_deps "https://github.com/ateeb09/resai/blob/main/backend/deps.py"
click node_resume_api "https://github.com/ateeb09/resai/blob/main/backend/resume_routes.py"
click node_pdf_parser "https://github.com/ateeb09/resai/blob/main/backend/pdf_parser.py"
click node_interview_api "https://github.com/ateeb09/resai/blob/main/backend/interview_routes.py"
click node_aptitude_api "https://github.com/ateeb09/resai/blob/main/backend/aptitude_routes.py"
click node_gemini "https://github.com/ateeb09/resai/blob/main/backend/gemini_service.py"
click node_chat_api "https://github.com/ateeb09/resai/blob/main/backend/chat_routes.py"
click node_dashboard_api "https://github.com/ateeb09/resai/blob/main/backend/dashboard_routes.py"
click node_billing_api "https://github.com/ateeb09/resai/blob/main/backend/payment_routes.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_auth_client,node_api_client,node_route_guard,node_prep_pages,node_dashboard_ui,node_coach_ui toneBlue
class node_api_server,node_auth_api,node_session_deps,node_resume_api,node_pdf_parser,node_interview_api,node_aptitude_api,node_gemini,node_chat_api,node_dashboard_api,node_billing_api toneAmber
class node_mongodb,node_resend,node_stripe,node_gemini_provider toneMint
```

## Components

### React client

Browser SPA and user workflows.

- [App shell & routes](https://github.com/ateeb09/resai/blob/main/frontend/src/App.js): React application · Composes providers, navigation, protected pages, and shared UI. · `frontend/src/App.js`
- [Auth context](https://github.com/ateeb09/resai/blob/main/frontend/src/lib/auth.jsx): client session state · `frontend/src/lib/auth.jsx`
- [API client](https://github.com/ateeb09/resai/blob/main/frontend/src/lib/api.js): HTTP client · Centralizes all browser-to-API calls. · `frontend/src/lib/api.js`
- [Protected route](https://github.com/ateeb09/resai/blob/main/frontend/src/components/ProtectedRoute.jsx): route guard · Triggers login before core preparation and pricing workflows. · `frontend/src/components/ProtectedRoute.jsx`
- [Preparation pages](https://github.com/ateeb09/resai/blob/main/frontend/src/pages/Resume.jsx): resume, interview & aptitude UI · Runs the three primary assessment journeys. · `frontend/src/pages/Resume.jsx`
- [Dashboard](https://github.com/ateeb09/resai/blob/main/frontend/src/pages/Dashboard.jsx): progress UI · `frontend/src/pages/Dashboard.jsx`
- [Career coach UI](https://github.com/ateeb09/resai/blob/main/frontend/src/components/Chatbot.jsx): floating chat UI · Cross-cutting conversational coaching interface. · `frontend/src/components/Chatbot.jsx`

### FastAPI API

API, identity, preparation workflows, and analytics.

- [API composition](https://github.com/ateeb09/resai/blob/main/backend/server.py): FastAPI server · Mounts domain routers under /api and configures CORS. · `backend/server.py`
- [OTP identity](https://github.com/ateeb09/resai/blob/main/backend/auth_routes.py): auth routes · Creates or fetches users and issues session tokens. · `backend/auth_routes.py`
- [Session dependencies](https://github.com/ateeb09/resai/blob/main/backend/deps.py): auth & database dependencies · Resolves MongoDB and optional or required cookie/Bearer sessions. · `backend/deps.py`
- [Resume workflow](https://github.com/ateeb09/resai/blob/main/backend/resume_routes.py): resume routes · Extracts, reviews, saves, and can export resume reports. · `backend/resume_routes.py`
- [PDF extraction](https://github.com/ateeb09/resai/blob/main/backend/pdf_parser.py): PDF parser · `backend/pdf_parser.py`
- [Interview workflow](https://github.com/ateeb09/resai/blob/main/backend/interview_routes.py): interview routes · Generates five-question sessions, grades answers, and saves aggregates. · `backend/interview_routes.py`
- [Aptitude workflow](https://github.com/ateeb09/resai/blob/main/backend/aptitude_routes.py): aptitude routes · Generates ten MCQs, evaluates timed submissions, and records attempts. · `backend/aptitude_routes.py`
- [Gemini intelligence](https://github.com/ateeb09/resai/blob/main/backend/gemini_service.py): LLM integration · Shared generation and grading boundary. · `backend/gemini_service.py`
- [Coaching chat](https://github.com/ateeb09/resai/blob/main/backend/chat_routes.py): chat routes · Maintains contextual coaching conversations. · `backend/chat_routes.py`
- [Progress analytics](https://github.com/ateeb09/resai/blob/main/backend/dashboard_routes.py): dashboard routes · Aggregates user module histories. · `backend/dashboard_routes.py`
- [Subscriptions](https://github.com/ateeb09/resai/blob/main/backend/payment_routes.py): payment routes · Starts checkout and handles plan-upgrade webhooks. · `backend/payment_routes.py`

### External services

Managed data, AI, messaging, and billing services.

- **MongoDB**: application database · Stores users, sessions, OTPs, histories, and transactions.
- **Resend**: OTP email service · Email delivery has a terminal fallback.
- **Stripe**: billing platform · Checkout and webhook provider.
- **Gemini 3 Flash**: LLM provider

## Connections

- App shell & routes → Auth context: provides session
- App shell & routes → Protected route: guards routes
- App shell & routes → Preparation pages: routes to
- App shell & routes → Dashboard: routes to
- App shell & routes → Career coach UI: renders sitewide
- Auth context → API client: uses
- Protected route → Auth context: checks identity
- Preparation pages → API client: submits workflows
- Dashboard → API client: loads progress
- Career coach UI → API client: sends chat
- API client → API composition: HTTPS /api
- API composition → OTP identity: mounts
- API composition → Resume workflow: mounts
- API composition → Interview workflow: mounts
- API composition → Aptitude workflow: mounts
- API composition → Coaching chat: mounts
- API composition → Progress analytics: mounts
- API composition → Subscriptions: mounts
- OTP identity → Session dependencies: issues sessions
- Session dependencies → MongoDB: connects and resolves
- OTP identity → Resend: delivers OTP
- Resume workflow → PDF extraction: extracts upload text
- Resume workflow → Gemini intelligence: requests review
- Interview workflow → Gemini intelligence: generates and grades
- Aptitude workflow → Gemini intelligence: generates and explains
- Coaching chat → Gemini intelligence: coaching context
- Gemini intelligence → Gemini 3 Flash: emergentintegrations
- Resume workflow → MongoDB: saves history
- Interview workflow → MongoDB: saves sessions
- Aptitude workflow → MongoDB: records attempts
- Coaching chat → MongoDB: stores context
- Progress analytics → MongoDB: aggregates histories
- Subscriptions → Stripe: checkout and webhooks
- Subscriptions → MongoDB: updates entitlements
