# agilepartners-ai/myjobsearchagent architecture

> Architecture diagram of the GitHub repository agilepartners-ai/myjobsearchagent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agilepartners-ai/myjobsearchagent
- Repository: https://github.com/agilepartners-ai/myjobsearchagent

## Overview

##### Project Type & Purpose
- This is a full-stack, single-page application (SPA) for AI-powered job search, built with React + TypeScript and Vite.
- The “frontend” is a Vite-bundled React app hosted on Netlify.
- The “backend” consists of BaaS and serverless functions (Supabase edge functions) plus external APIs (job-search API, AI services), with Firebase/Supabase used for authentication and data storage.
- There’s also a small Python Flask/Django CORS server used locally for development.

##### Main Components
a. Client (Browser)
- React SPA (src/)
- Web Worker (tavusWorker.js / src/workers/tavusWorker.ts) for handling video/AI interview tasks
- Static assets (public/)
b. Hosting/CDN
- Netlify serving the built “dist” folder
c. BaaS & Serverless
- Supabase
- Authentication (supabaseAuthService.ts)
- Postgres Database (job applications, conversations, user profile)
- Edge Functions (resume-proxy in src/supabase/functions/resume-proxy)
- Firebase Authentication (configured via environment variables)
d. External APIs
- Job search API (JSEARCH_API_HOST / JSEARCH_API_KEY)
- Any AI/ML services (OpenAI or vendor for resume optimization)
e. Dev CORS Proxy
- Flask app (server/flask_app.py) and Django CORS settings for local testing

##### Component Interactions & Data Flow
- User interacts with the React UI → calls client-side “services” (e.g., jobSearchService.ts, conversationService.ts).
- Services either:
- Invoke Supabase JS client (for auth, profile, application tracking), or
- Call serverless endpoints (resume-proxy edge function), or
- Hit external APIs (JSearch, AI resume service).
- Responses flow back to the UI; state is managed in Redux slices (src/store) and React Query style boundaries.
- The Web Worker offloads compute-heavy interview tasks, communicates via postMessage to the main thread.
- CI/CD (GitHub Actions) scans secrets, lints, tests, then deploys to Netlify.

##### Architectural Patterns & Design Principles
- SPA with clear separation: Presentation (components/screens) ↔ Business Logic (services/hooks) ↔ Data Layer (Supabase / external APIs)
- Service-oriented: each “service” module encapsulates one API integration
- Modular folder structure: components, hooks, services, store, utils
- Serverless backend: BaaS + Edge Functions instead of monolithic server

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Top: Local Dev CORS Proxy
  subgraph "Local Dev CORS Proxy" 
    direction TB
    flask["Flask App"]:::devtools
    django["Django CORS Settings"]:::devtools
    corsMiddleware["CORS Middleware"]:::devtools
    nginxConfig["nginx CORS Config"]:::devtools
  end

  %% Frontend Layer
  subgraph "Client Browser" 
    direction TB
    react["React SPA"]:::frontend
    workerTS["Web Worker (tavusWorker.ts)"]:::frontend
    workerJS["Web Worker (tavusWorker.js)"]:::frontend
    assets["Static Assets"]:::frontend
  end

  %% Hosting Layer
  netlify["Netlify CDN"]:::frontend

  %% Backend & External
  subgraph "BaaS & Serverless" 
    direction TB
    supabaseClient["Supabase JS Client"]:::backend
    authService["Supabase Auth Service"]:::backend
    jobAppService["Job Application Service"]:::backend
    jobPrefService["Job Preferences Service"]:::backend
    edgeFunc["Resume-Proxy Edge Function"]:::backend
    firebaseAuth["Firebase Auth Config"]:::backend
    db[(Postgres Database)]:::backend
  end

  subgraph "External APIs" 
    direction TB
    jobAPI["Job Search API"]:::external
    aiService["AI/ML Service"]:::external
  end

  %% Bottom: Dev Tools / CI-CD
  subgraph "Dev Tools & CI/CD"
    direction TB
    githubActions["GitHub Actions"]:::devtools
    envValidator["Env Validator Utility"]:::devtools
  end

  %% Interactions
  react -->|"uses"| supabaseClient
  react -->|"spawns"| workerTS
  react -->|"spawns"| workerJS
  react -->|"loads"| assets
  react -->|"calls"| edgeFunc
  react -->|"fetches"| jobAPI
  react -->|"calls"| authService
  workerTS <-->|"postMessage"| react
  supabaseClient -->|"auth()"| authService
  supabaseClient -->|"from('applications')"| jobAppService
  supabaseClient -->|"from('preferences')"| jobPrefService
  authService --> db
  jobAppService --> db
  jobPrefService --> db
  edgeFunc -->|"proxy to"| aiService
  edgeFunc -->|"responds"| react
  jobAPI --> react
  firebaseAuth --> react
  envValidator --> firebaseAuth
  envValidator --> jobAPI
  githubActions --> netlify
  githubActions --> flask
  githubActions --> django
  flask --> react
  django --> react
  
  %% Click Events
  click react "https://github.com/agilepartners-ai/myjobsearchagent/tree/main/src/"
  click workerTS "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/workers/tavusWorker.ts"
  click workerJS "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/public/tavusWorker.js"
  click assets "https://github.com/agilepartners-ai/myjobsearchagent/tree/main/public/"
  click assets "https://github.com/agilepartners-ai/myjobsearchagent/tree/main/src/assets/"
  click supabaseClient "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/lib/supabase.ts"
  click authService "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/services/supabaseAuthService.ts"
  click jobAppService "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/services/supabaseJobApplicationService.ts"
  click jobPrefService "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/services/supabaseJobPreferencesService.ts"
  click edgeFunc "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/supabase/functions/resume-proxy/index.ts"
  click firebaseAuth "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/config/index.ts"
  click jobAPI "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/services/jobSearchService.ts"
  click aiService "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/services/resumeOptimizationService.ts"
  click aiService "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/services/aiEnhancementService.ts"
  click envValidator "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/src/utils/environmentValidator.ts"
  click githubActions "https://github.com/agilepartners-ai/myjobsearchagent/tree/main/.github/workflows/"
  click flask "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/server/flask_app.py"
  click django "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/server/django_cors_settings.py"
  click corsMiddleware "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/server/cors_middleware.py"
  click nginxConfig "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/server/nginx_cors_config.conf"
  click netlify "https://github.com/agilepartners-ai/myjobsearchagent/blob/main/netlify.toml"

  %% Styles
  classDef frontend fill:#D0E8FF,stroke:#36A2FF,color:#0366d6;
  classDef backend fill:#E8FFE8,stroke:#33C44B,color:#117A33;
  classDef external fill:#FFF4D0,stroke:#FFC107,color:#8D6E00;
  classDef devtools fill:#E0E0E0,stroke:#9E9E9E,color:#424242;
```
