A production-oriented backend system for asynchronous AI-powered document processing built with Node.js, Express, TypeScript, PostgreSQL (pgvector), Redis, BullMQ, Docker, GitHub Actions, and AWS EC2.
This project demonstrates how modern backend systems process large documents asynchronously using queues, workers, vector databases, and AI services.
Instead of processing uploaded documents inside an HTTP request, the API stores metadata, queues a background job, and returns immediately. Dedicated workers then extract text, generate AI embeddings using Google Gemini, and store vector representations inside PostgreSQL with pgvector.
The architecture follows production backend engineering principles including asynchronous processing, containerization, CI/CD, and cloud deployment.
- JWT Authentication
- Document Upload API
- PDF Text Extraction
- AI Embedding Generation (Google Gemini)
- Vector Storage using pgvector
- Background Processing using BullMQ
- Redis Queue
- PostgreSQL Database
- Dockerized Services
- GitHub Actions CI/CD
- GitHub Container Registry (GHCR)
- AWS EC2 Deployment
- Integration Testing
Client
│
▼
Express REST API
│
Store Metadata (Postgres)
│
▼
BullMQ Queue
│
▼
Redis Job Queue
│
▼
Background Worker
│
┌──────────────┼──────────────┐
▼ ▼ ▼
Extract PDF Chunk Text Generate Embeddings
│
▼
Google Gemini API
│
▼
PostgreSQL + pgvector
- Backend
- Node.js
- Express.js
- TypeScript
- PostgreSQL
- pgvector
- Queue
- BullMQ
- Redis
- Google Gemini Embedding API
- CI/CD
- Docker
- Docker Compose
- GitHub Actions
- GitHub Container Registry
- AWS EC2
- Integration Tests
| Method | Endpoint | Authentication | Description |
|---|---|---|---|
| GET | /health |
No | Check API health status |
| Method | Endpoint | Authentication | Description |
|---|---|---|---|
| POST | /api/auth/register |
No | Register a new user |
| POST | /api/auth/login |
No | Authenticate user and return access & refresh tokens |
| POST | /api/auth/refresh |
No | Generate a new access token using a refresh token |
| POST | /api/auth/logout |
Yes | Logout the current user and invalidate refresh token |
| Method | Endpoint | Authentication | Description |
|---|---|---|---|
| POST | /api/documents/upload |
Yes | Upload a PDF for asynchronous AI processing |
| GET | /api/documents |
Yes | Retrieve all uploaded documents |
| GET | /api/documents/:id |
Yes | Retrieve a specific document by ID |
Protected endpoints require a JWT access token.
Authorization: Bearer <access_token>| Status Code | Description |
|---|---|
| 200 | Request completed successfully |
| 201 | Resource created successfully |
| 202 | Accepted for background processing |
| 400 | Bad request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Resource not found |
| 409 | Conflict (resource already exists) |
| 500 | Internal server error |
src
├── modules
│ ├── auth
│ └── document
│
├── infrastructure
│ ├── database
│ ├── queue
│ ├── workers
│ └── logger
│
├── shared
│
└── server.ts
Client Uploads PDF
│
▼
Express API
│
Save Document Metadata
│
PostgreSQL
│
Add Job
│
BullMQ
│
Redis Queue
│
Worker
│
Extract PDF
│
Chunk Text
│
Generate Embeddings
│
Store Vectors
│
PostgreSQL (pgvector)
Git Push
│
▼
GitHub Actions
│
Run Tests
│
Build Docker Images
│
Push Images
▼
GitHub Container Registry
The application is containerized using Docker Compose and deployed on AWS EC2.
- API
- Worker
- PostgreSQL
- Redis
- Docker
- Docker Compose
- GitHub Container Registry
- AWS EC2
Clone the repository
git clone https://github.com/<username>/document-processing-platform.git
Install dependencies
pnpm install
Run docker services
docker compose up -d
Run migrations
pnpm migrate
Start development server
pnpm dev
Running Tests
pnpm test
- Semantic Search
- RAG Chat
- OpenTelemetry
- Prometheus & Grafana
- Kubernetes Deployment
- S3 Object Storage
- Multi-file Processing
- Horizontal Worker Scaling
- Rate Limiting
- API Gateway
- REST API Design
- Authentication
- Repository Pattern
- Background Job Processing
- Queue-based Architecture
- Worker Pattern
- Vector Databases
- AI Integration
- Docker
- CI/CD
- Cloud Deployment
- Production Logging
- Integration Testing
Kushal Chavan
Backend Engineer
GitHub: [https://github.com/Kushalchavan]