File size: 11,841 Bytes
609ba3d
 
 
 
664c157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0803a31
664c157
 
 
 
 
 
 
 
 
 
 
0803a31
 
664c157
 
 
 
 
 
 
 
 
0803a31
664c157
 
 
0803a31
664c157
 
 
 
 
 
0803a31
664c157
0803a31
664c157
0803a31
664c157
0803a31
664c157
 
 
 
 
 
0803a31
 
664c157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609ba3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
---
tags:
- ml-intern
---
# πŸ€– AI-Powered HR Task Optimizer

<p align="center">
  <img src="https://img.shields.io/badge/Next.js-14-black?style=for-the-badge&logo=next.js" />
  <img src="https://img.shields.io/badge/Node.js-20-green?style=for-the-badge&logo=node.js" />
  <img src="https://img.shields.io/badge/Python-3.11-blue?style=for-the-badge&logo=python" />
  <img src="https://img.shields.io/badge/FastAPI-0.100+-009688?style=for-the-badge&logo=fastapi" />
  <img src="https://img.shields.io/badge/PostgreSQL-15-336791?style=for-the-badge&logo=postgresql" />
  <img src="https://img.shields.io/badge/Redis-7-DC382D?style=for-the-badge&logo=redis" />
  <img src="https://img.shields.io/badge/Tailwind-3.4-38B2AC?style=for-the-badge&logo=tailwind-css" />
</p>

<p align="center">
  <b>Production-grade AI recruitment platform</b> β€” automate resume screening, rank candidates with embeddings + LLM reranking, prioritize recruiter tasks with ML, and manage the entire hiring pipeline.
</p>

---

## πŸš€ What This Is

A **startup-grade SaaS ATS** (Applicant Tracking System) built for modern HR teams. It combines:

- **Semantic resume parsing** with LLM extraction
- **AI candidate ranking** using sentence embeddings + GPT-4o reranking
- **Intelligent task prioritization** with LightGBM risk prediction
- **Interview scheduling** with Google Calendar integration
- **AI email assistant** with human-in-the-loop approval
- **Real-time analytics** for hiring velocity and pipeline bottlenecks

**Live Demo:** [Coming Soon]
**Architecture Deep Dive:** [See ADRs](./docs/adr/)

---

## πŸ—οΈ Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       CLIENT LAYER                          β”‚
β”‚  Next.js 14 (App Router) ──► Vercel Edge / Serverless      β”‚
β”‚  - SSR Dashboards (SEO + performance)                       β”‚
β”‚  - React Server Components for data-heavy tables            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚ HTTPS / JWT
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  API GATEWAY (Node.js)                      β”‚
β”‚  Express.js + Helmet + Rate Limiter + Request Validator   β”‚
β”‚  - Auth middleware (JWT + OAuth passthrough)               β”‚
β”‚  - Router: /api/v1/* β†’ Main API                            β”‚
β”‚           /ai/v1/*   β†’ AI Service Proxy (internal mTLS)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CORE API   β”‚    β”‚   AI SERVICE   β”‚
β”‚  Node.js    β”‚    β”‚   FastAPI      β”‚
β”‚  Express    β”‚    β”‚   (GPU/CPU)    β”‚
β”‚  PostgreSQL β”‚    β”‚  Sentence-     β”‚
β”‚  Redis      β”‚    β”‚  Transformers  β”‚
β”‚  Bull MQ    β”‚    β”‚  OpenAI SDK    β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚
   β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”         β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”
   β”‚  AWS   β”‚         β”‚  AWS   β”‚
   β”‚   S3   β”‚         β”‚  SQS / β”‚
   β”‚(Resumesβ”‚         β”‚ Redis  β”‚
   β”‚  PDFs) β”‚         β”‚ (Queue)β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

**Pattern: BFF (Backend-for-Frontend) + AI Microservice**

- **Node.js Core API** handles I/O concurrency (auth, CRUD, notifications, calendar APIs)
- **FastAPI AI Service** isolates the ML lifecycle (torch, transformers, CUDA dependencies)
- **Next.js App Router** uses Server Components for dashboard data and Server Actions for mutations

---

## ✨ Features

| Feature | Description | AI/ML Component |
|---------|-------------|-----------------|
| πŸ€– **AI Task Prioritization** | Dynamically ranks recruiter tasks by urgency, deadline, candidate quality, and workload | LightGBM risk model + heuristic blend |
| πŸ“„ **Resume Screening** | Upload PDFs, extract structured data (skills, experience, education) | unstructured.io + GPT-4o extraction |
| 🎯 **Smart Candidate Ranking** | Semantic similarity scoring + LLM reranking for precision | Sentence Transformers + GPT-4o |
| πŸ“… **Interview Scheduler** | Auto-manage slots, calendar sync, reminders, multi-stage workflow | Google Calendar API + BullMQ cron |
| πŸ“Š **Recruitment Dashboard** | Pipeline analytics, hiring progress, task monitoring | PostgreSQL aggregations + Recharts |
| βœ‰οΈ **AI Email Assistant** | Generate follow-ups, invites, rejections with human approval | GPT-4o with few-shot prompting |
| πŸ“ˆ **Productivity Analytics** | Time-to-hire, conversion rates, recruiter efficiency, bottlenecks | Survival analysis + funnel metrics |
| πŸ”” **Notification System** | Smart alerts, deadline reminders, candidate inactivity | SSE + Redis Pub/Sub |

---

## πŸ› οΈ Tech Stack

### Frontend
- **Next.js 14** (App Router, Server Components, Server Actions)
- **Tailwind CSS** + **shadcn/ui** primitives
- **TanStack Query** for client-side data fetching
- **Zustand** for lightweight global state
- **React Hook Form** + **Zod** for validation
- **Recharts / Tremor** for analytics

### Backend
- **Node.js + Express** (Core API)
- **Python + FastAPI** (AI Microservice)
- **PostgreSQL 15** (primary database + pgvector for semantic search)
- **Redis 7** (caching, sessions, BullMQ job queues)
- **BullMQ** (background job processing)

### AI/ML
- **Sentence Transformers** (`all-MiniLM-L6-v2` for embeddings)
- **OpenAI GPT-4o** (resume extraction, email generation, reranking)
- **LightGBM** (task prioritization model)
- **scikit-learn** (scoring ensembles)
- **unstructured.io** + **pdfplumber** (PDF parsing)

### Auth & Deployment
- **JWT** + **OAuth 2.0** (Google, GitHub)
- **Vercel** (frontend)
- **Railway / Render** (backend + AI service)
- **AWS S3** (resume storage)
- **SendGrid / AWS SES** (transactional email)

---

## πŸ“ Monorepo Structure

```
hr-task-optimizer/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/                    # Next.js 14 App Router
β”‚   β”‚   β”œβ”€β”€ app/                # Route groups, Server Components
β”‚   β”‚   β”œβ”€β”€ components/         # UI primitives + domain composites
β”‚   β”‚   └── lib/                # API wrappers, utilities
β”‚   β”œβ”€β”€ api/                    # Node.js Core API
β”‚   β”‚   β”œβ”€β”€ src/modules/        # Domain modules (auth, jobs, candidates, tasks)
β”‚   β”‚   β”œβ”€β”€ src/workers/        # BullMQ job processors
β”‚   β”‚   └── Dockerfile
β”‚   └── ai-service/             # Python FastAPI
β”‚       β”œβ”€β”€ app/routers/        # Embeddings, screening, generation, ranking
β”‚       β”œβ”€β”€ services/           # Model singletons, LLM clients
β”‚       └── Dockerfile.gpu
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ shared-types/           # Zod schemas β†’ TS + Pydantic
β”‚   β”œβ”€β”€ ui/                     # shadcn/ui base config
β”‚   └── eslint-config/
β”œβ”€β”€ infra/
β”‚   β”œβ”€β”€ docker-compose.yml      # Local dev stack
β”‚   β”œβ”€β”€ k8s/                    # Kubernetes manifests
β”‚   └── terraform/              # AWS/GCP provisioning
β”œβ”€β”€ docs/
β”‚   └── adr/                    # Architecture Decision Records
└── turbo.json
```

---

## πŸš€ Quick Start

### Prerequisites
- Docker + Docker Compose
- Node.js 20+ + pnpm
- Python 3.11+

### 1. Clone & Install

```bash
git clone https://github.com/plplpl183/ai-powered-hr-task-optimizer.git
cd ai-powered-hr-task-optimizer
pnpm install
```

### 2. Environment Setup

```bash
# Copy env files
cp apps/web/.env.example apps/web/.env.local
cp apps/api/.env.example apps/api/.env
cp apps/ai-service/.env.example apps/ai-service/.env

# Fill in your credentials (OpenAI, Google OAuth, AWS S3, etc.)
```

### 3. Start Local Stack

```bash
# Start PostgreSQL, Redis, MinIO (S3 mock)
docker-compose -f infra/docker-compose.yml up -d

# Run database migrations
pnpm db:migrate

# Start all apps in dev mode
pnpm dev
```

Services will be available at:
- **Web:** http://localhost:3000
- **Core API:** http://localhost:4000
- **AI Service:** http://localhost:8000
- **PostgreSQL:** localhost:5432
- **Redis:** localhost:6379
- **MinIO (S3):** http://localhost:9000

---

## πŸ§ͺ Testing

```bash
# Unit tests
pnpm test

# Integration tests (requires local stack)
pnpm test:integration

# AI service tests
pnpm test:ai
```

---

## πŸ“Š Performance & Scale

| Metric | Target | Implementation |
|--------|--------|----------------|
| Resume parsing | <5s per PDF | Async BullMQ worker + model singleton |
| Candidate ranking | <200ms for top-20 | pgvector cosine similarity + LLM reranker |
| Task prioritization | <100ms | LightGBM inference + Redis caching |
| Dashboard load | <1s TTFB | Next.js Server Components + ISR |
| Concurrent users | 1000+ | Horizontal scaling via K8s / Railway |

---

## πŸ” Security

- **HTTP-only cookies** with `SameSite=Lax` for refresh tokens
- **Rate limiting** by IP + user (Redis-backed)
- **File upload validation** via magic numbers + size limits
- **Parameterized queries** (Drizzle ORM) β€” SQL injection impossible
- **CORS** restricted to known origins
- **Helmet.js** security headers
- **Human-in-the-loop approval** for all AI-generated emails

---

## πŸ“– Documentation

- [Architecture Decision Records](./docs/adr/)
  - [001: Why PostgreSQL over MongoDB](./docs/adr/001-why-postgres.md)
  - [002: Why FastAPI for AI Service](./docs/adr/002-why-fastapi-for-ai.md)
  - [003: Task Prioritization Heuristic vs ML](./docs/adr/003-task-prioritization.md)
- [API Documentation](https://api.hr-task-optimizer.dev/docs) (OpenAPI/Swagger)
- [Contributing Guidelines](./CONTRIBUTING.md)

---

## 🀝 Contributing

We use [Conventional Commits](https://www.conventionalcommits.org/):

```bash
feat: add AI email generation endpoint
fix: resolve race condition in task prioritization
docs: update API documentation
refactor: extract resume parser into service class
test: add integration tests for interview scheduler
```

See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.

---

## πŸ“„ License

MIT License β€” see [LICENSE](./LICENSE) for details.

---

## πŸ™ Acknowledgments

- [sentence-transformers](https://www.sbert.net/) for embedding models
- [unstructured.io](https://unstructured.io/) for PDF parsing
- [shadcn/ui](https://ui.shadcn.com/) for UI primitives
- [BullMQ](https://docs.bullmq.io/) for job queues

---

<p align="center">
  Built with ❀️ by <a href="https://github.com/plplpl183">@plplpl183</a>
</p>

<!-- ml-intern-provenance -->
## Generated by ML Intern

This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.

- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "plplpl183/ai-powered-hr-task-optimizer"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
```

For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.