# kunal-khairnar-05/fakehire architecture

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

- Interactive diagram: https://gitdiagram.com/kunal-khairnar-05/fakehire
- Repository: https://github.com/kunal-khairnar-05/fakehire

## Overview

FakeHire is a job-posting scam detector. A user submits a posting in the browser; the API authenticates and rate-limits the request, checks a versioned verdict cache, and on a miss asks the ML service to score it. The API saves the result to history and returns the verdict and flags. Separate workflows support account access, web evidence, user scam reports, moderator review, company search, and trending. The README documents PostgreSQL, Redis, and Tavily integrations; some API route and service implementations were not sampled, so uncertain connections are omitted or marked dashed.

Main entry points: [`api/app/main.py`](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/main.py) (FastAPI application), [`api/app/services/check_service.py`](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/check_service.py) (Check workflow), [`ml/service/app.py`](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/service/app.py) (ML prediction service), [`api/app/services/report_service.py`](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/report_service.py) (Report review)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser app"]
  node_app["Application shell<br/>[App.tsx]"]
  node_checkform["Posting check form<br/>[CheckForm.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_session["Tab session state<br/>[useSessionState.ts]"]
end

subgraph group_api["API and identity"]
  node_api_runtime["FastAPI application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_auth_service["Authentication service<br/>[auth_service.py]"]
  node_check_service["Check workflow<br/>[check_service.py]"]
  node_ml_client["ML HTTP client<br/>[ml_client.py]"]
end

subgraph group_detector["Detection engine"]
  node_ml_service["ML prediction service<br/>[app.py]"]
  node_posting["Posting representation<br/>[posting.py]"]
  node_rules["Red-flag rules<br/>[rules.py]"]
  node_scoring["Hybrid scoring<br/>[scoring.py]"]
  node_model["TF-IDF classifier<br/>[model.py]"]
  node_training["Model training<br/>[training.py]"]
end

subgraph group_community["Reports and discovery"]
  node_report_service["Report review<br/>[report_service.py]"]
  node_trending["Trending board<br/>[trending.py]"]
  node_web_service["Web evidence checks<br/>[web_check.py]"]
  node_company_service["Company discovery<br/>[company_service.py]"]
end

subgraph group_state["Shared state"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis")]
end

node_user(("Job seeker"))
node_tavily["Tavily search"]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_checkform
node_checkform -->|"requests"| node_api_client
node_app -->|"persists page"| node_session
node_api_client -->|"calls API"| node_api_runtime
node_api_runtime -->|"registers routes"| node_auth_routes
node_auth_routes -->|"delegates"| node_auth_service
node_api_runtime -.->|"provides dependencies"| node_check_service
node_check_service -->|"requests version and scores"| node_ml_client
node_ml_client -->|"posts prediction"| node_ml_service
node_ml_service -->|"builds input"| node_posting
node_ml_service -->|"evaluates flags"| node_rules
node_ml_service -->|"predicts score"| node_model
node_scoring -->|"uses results"| node_rules
node_training -->|"trains pipeline"| node_model
node_training -->|"converts data"| node_posting
node_check_service -->|"saves history"| node_postgres
node_check_service -.->|"checks verdict cache"| node_redis
node_api_runtime -.->|"provides dependencies"| node_report_service
node_report_service -->|"records verified report"| node_trending
node_report_service -->|"stores reports"| node_postgres
node_company_service -->|"reads trends"| node_trending
node_api_runtime -.->|"provides dependencies"| node_web_service
node_web_service -.->|"searches web"| node_tavily
node_report_service -.->|"supports company records"| node_company_service

click node_app "https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/App.tsx"
click node_checkform "https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/components/CheckForm.tsx"
click node_api_client "https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/api.ts"
click node_session "https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/useSessionState.ts"
click node_api_runtime "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/main.py"
click node_auth_routes "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/routes/auth.py"
click node_auth_service "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/auth_service.py"
click node_check_service "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/check_service.py"
click node_ml_client "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/clients/ml_client.py"
click node_report_service "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/report_service.py"
click node_trending "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/trending.py"
click node_web_service "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/web_check.py"
click node_company_service "https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/company_service.py"
click node_ml_service "https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/service/app.py"
click node_posting "https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/posting.py"
click node_rules "https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/rules.py"
click node_scoring "https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/scoring.py"
click node_model "https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/model.py"
click node_training "https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/training.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_checkform,node_api_client,node_session toneBlue
class node_api_runtime,node_auth_routes,node_auth_service,node_check_service,node_ml_client toneAmber
class node_ml_service,node_posting,node_rules,node_scoring,node_model,node_training toneMint
class node_report_service,node_trending,node_web_service,node_company_service toneRose
class node_postgres,node_redis,node_user,node_tavily toneIndigo
```

## Components

### Browser app

- [Application shell](https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Posting check form](https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/components/CheckForm.tsx): `frontend/src/components/CheckForm.tsx`
- [API client](https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Tab session state](https://github.com/kunal-khairnar-05/fakehire/blob/main/frontend/src/useSessionState.ts): `frontend/src/useSessionState.ts`

### API and identity

- [FastAPI application](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/main.py): `api/app/main.py`
- [Authentication routes](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/routes/auth.py): `api/app/routes/auth.py`
- [Authentication service](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/auth_service.py): `api/app/services/auth_service.py`
- [Check workflow](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/check_service.py): `api/app/services/check_service.py`
- [ML HTTP client](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/clients/ml_client.py): `api/app/clients/ml_client.py`

### Detection engine

- [ML prediction service](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/service/app.py): `ml/service/app.py`
- [Posting representation](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/posting.py): `ml/fakehire_ml/posting.py`
- [Red-flag rules](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/rules.py): `ml/fakehire_ml/rules.py`
- [Hybrid scoring](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/scoring.py): `ml/fakehire_ml/scoring.py`
- [TF-IDF classifier](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/model.py): `ml/fakehire_ml/model.py`
- [Model training](https://github.com/kunal-khairnar-05/fakehire/blob/main/ml/fakehire_ml/training.py): `ml/fakehire_ml/training.py`

### Reports and discovery

- [Report review](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/report_service.py): `api/app/services/report_service.py`
- [Trending board](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/trending.py): `api/app/services/trending.py`
- [Web evidence checks](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/web_check.py): `api/app/services/web_check.py`
- [Company discovery](https://github.com/kunal-khairnar-05/fakehire/blob/main/api/app/services/company_service.py): `api/app/services/company_service.py`

### Shared state

- **PostgreSQL**
- **Redis**

### Other components

- **Job seeker**
- **Tavily search**

## Connections

- Job seeker → Application shell: uses
- Application shell → Posting check form: renders (evidence: `frontend/src/App.tsx`)
- Posting check form → API client: requests (evidence: `frontend/src/components/CheckForm.tsx`)
- Application shell → Tab session state: persists page (evidence: `frontend/src/App.tsx`)
- API client → FastAPI application: calls API (evidence: `frontend/src/api.ts`)
- FastAPI application → Authentication routes: registers routes (evidence: `api/app/main.py`)
- Authentication routes → Authentication service: delegates (evidence: `api/app/routes/auth.py`)
- FastAPI application → Check workflow: provides dependencies
- Check workflow → ML HTTP client: requests version and scores (evidence: `api/app/services/check_service.py`)
- ML HTTP client → ML prediction service: posts prediction (evidence: `api/app/clients/ml_client.py`)
- ML prediction service → Posting representation: builds input (evidence: `ml/service/app.py`)
- ML prediction service → Red-flag rules: evaluates flags (evidence: `ml/service/app.py`)
- ML prediction service → TF-IDF classifier: predicts score (evidence: `ml/service/app.py`)
- Hybrid scoring → Red-flag rules: uses results (evidence: `ml/fakehire_ml/scoring.py`)
- Model training → TF-IDF classifier: trains pipeline (evidence: `ml/fakehire_ml/training.py`)
- Model training → Posting representation: converts data (evidence: `ml/fakehire_ml/training.py`)
- Check workflow → PostgreSQL: saves history (evidence: `api/app/services/check_service.py`)
- Check workflow → Redis: checks verdict cache
- FastAPI application → Report review: provides dependencies
- Report review → Trending board: records verified report (evidence: `api/app/services/report_service.py`)
- Report review → PostgreSQL: stores reports (evidence: `api/app/services/report_service.py`)
- Company discovery → Trending board: reads trends (evidence: `api/app/services/company_service.py`)
- FastAPI application → Web evidence checks: provides dependencies
- Web evidence checks → Tavily search: searches web
- Report review → Company discovery: supports company records
