This project demonstrates how to build a scalable, asynchronous file processing pipeline using BullMQ, S3, Sequelize, and PostgreSQL.
- Upload CSV/Excel/DBF files via an API
- Store files in S3
- Track file processing status in PostgreSQL
- Background validation and mapping jobs using BullMQ
- Final data storage in a table
- Node.js + Express
- PostgreSQL + Sequelize
- BullMQ + Redis
- AWS S3
- Multer for file upload
Lightweight pipeline that accepts CSV uploads, stores files in S3, enqueues background jobs with BullMQ, and persists parsed rows into a dump table via Sequelize/Postgres.
Key features
- CSV upload endpoint with S3 storage and processing tracking
- Background job workers using BullMQ + Redis
- CSV parsing with configurable date handling and header validation
- UI for monitoring queues (
/bullui) protected with basic auth
Prerequisites
- Node 18+ and npm
- PostgreSQL
- Redis
- (Optional) AWS S3 credentials to enable S3 uploads
Quickstart
- Install dependencies:
npm install- Copy and edit environment variables:
cp .env.example .env
# then edit .env to set DB, Redis and AWS credentials- Start the app:
# production-style
npm start
# development with auto-reload
npm run devAPI
- Upload endpoint: POST
/upload/upload— multipart form with fieldfileand optionalupload_type.
Example (CSV):
curl -F "file=@/path/to/data.csv" -F "upload_type=bse_scheme" http://localhost:3000/upload/uploadQueue UI (Bull UI)
- Installed and mounted at:
http://localhost:3000/bullui - Protected with HTTP Basic Auth using
BULLUI_USERandBULLUI_PASS(defaults in.env.example).
Database migrations
This repo uses Sequelize migrations. To create the tables run:
npm install
npm run db:migrateTo undo last migration:
npm run db:migrate:undoTesting
Run automated tests (Jest + Supertest):
npm testNotes about test mode
- When
NODE_ENV=testthe app avoids starting workers and the HTTP server and the service layer uses lightweight test-mode shortcuts so tests run reliably without AWS/Redis/Postgres.
Useful scripts
npm start— run the appnpm run dev— run withnodemonnpm test— run test suitenpm run db:migrate— run Sequelize migrationsnpm run db:migrate:undo— undo last migration
Development
- Source is under
src/. - Add queue processors in
src/queuesProcessors/and jobs insrc/jobs/.
Security
- Keep real credentials out of the repository. Use
.envand store secrets in your CI provider or vault. - The Bull UI is protected by
express-basic-auth— change the default credentials in.envbefore deploying.
Contributing
- Open a PR with clear description and tests for new behaviour.
License
- ISC