This is a Node.js-based backend service for handling asynchronous image processing tasks such as uploading, retrieving and performing transformations on images. The system is built with scalability in mind using Amazon S3 and PostgreSQL for storage, and RabbitMQ for task queuing.
- Upload images to S3
- Extract and return image metadata
- Asynchronously apply different image transformations via RabbitMQ
- Save transformed image results back to S3
- Current Supported transformations rotate, flip, resize, crop, change file format, grayscale, and sepia.
- Node.js / Express – API framework
- Amazon S3 – Cloud storage for uploaded and transformed images
- PostgreSQL – Relational database for image records
- RabbitMQ – Asynchronous job queue for image transformation
Ensure you have the following installed:
- Node.js (>= 16.x)
- PostgreSQL
- RabbitMQ
-
Clone the repository:
git clone https://github.com/jamesh21/image-processing-service
-
Install dependencies:
npm install
-
Configure environment variables:
- Create a
.env
file in the project directory and add the following:
PORT=3000 DB_USER=your-local-postgres-db-username DB_HOST=your-local-postgres-db-host DB_NAME=your-local-postgres-db-name DB_PASSWORD=your-local-postgres-pw DB_PORT=your-local-postgres-port JWT_SECRET=your-jwt-secret JWT_LIFETIME=your-jwt-lifetime AWS_ACCESS_KEY_ID=your-aws-key-id AWS_SECRET_ACCESS_KEY=your-aws-secret AWS_REGION=your-aws-region S3_BUCKET_NAME=your-s3-bucket
- Create a
-
Start Postgres and RabbitMQ server locally
-
Run DB Script
- Run db.sql to generate postgres tables
npm start
node consumer.js
POST /api/v1/auth/register
– Register new userPOST /api/v1/auth/login
– Login user
POST /api/images/
- Uploads image
GET /api/images/:imageId
- Retrieves image associated with image IdGET /api/images?page=1&limit=5
- Retrieves image uploaded by logged in user, can accept pagination
- `POST /api/images/:imageId/transform - Performs transformations on image Id
- Sample transformation option to pass in:
{
"transformations": {
"resize": {
"width": 400,
"height": 400
},
"format": "png",
"flip": true,
"grayscale": true,
"sepia": true
}
}
- Add caching for transformed images (e.g., Redis)
- Build a frontend dashboard
MIT
- James Ho – Developer
For any inquiries or contributions, feel free to reach out:
- GitHub: jamesh21
This project idea is from roadmap.sh