Skip to content

Wrapjet Secure Scale API — A production-grade backend built with Node.js, Express.js, Neon Postgres, Drizzle ORM, and Zod. Fully Dockerized with CI/CD automation and Arcjet integration for robust, scalable, and secure deployments.

Notifications You must be signed in to change notification settings

aswazone/wrapjet-prod-scale-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Project Banner

Build a Scalable Production Ready API

  1. Introduction
  2. ⚙️ Tech Stack
  3. 🔋 Features
  4. 🤸 Quick Start

Master DevOps by taking an API from code to production with Docker, Kubernetes, Git & GitHub, Warp, and CI/CD Actions! Build a scalable backend using Node.js, Express.js, Neon Postgres, and Drizzle ORM, while testing ensures reliability at every step. Learn to containerize services, orchestrate deployments, automate pipelines, and monitor applications—perfect for developers who want hands-on experience shipping robust, production-ready systems.

  • Arcjet is a developer-first security layer that enables you to protect your applications with minimal code. It offers features like bot protection, rate limiting, email validation, and defense against common attacks. Arcjet's SDK integrates seamlessly into your application, providing real-time security decisions without the need for additional infrastructure.

  • Docker is a leading containerization platform that allows you to package applications along with all their dependencies into portable, lightweight containers. This ensures consistent behavior across different environments, simplifies deployment, and makes scaling applications more efficient.

  • Kubernetes is an open-source orchestration system designed to automate the deployment, scaling, and management of containerized applications. It handles tasks like load balancing, self-healing, and rolling updates, making it essential for running applications reliably at scale.

  • Warp is a modern terminal built in Rust, optimized for developer productivity. It offers features like AI-assisted commands, easy collaboration, command history search, and a faster, more intuitive interface compared to traditional terminals.

  • Node.js is a fast, event-driven JavaScript runtime built on Chrome’s V8 engine. It enables developers to build scalable, high-performance server-side applications and APIs using JavaScript on both the client and server side.

  • Express.js is a minimal and flexible Node.js web application framework. It provides robust features for building APIs and server-side applications, including routing, middleware support, and simplified request/response handling.

  • Neon Postgres is a fully managed, serverless Postgres database designed for modern cloud applications. It offers autoscaling, branching for development workflows, and simplifies database management without compromising performance.

  • Drizzle ORM is a TypeScript-first, lightweight ORM for SQL databases. It provides type safety, schema migrations, and an intuitive API for building reliable and maintainable database queries.

  • Zod is a TypeScript-first schema validation library that ensures runtime type safety. It helps developers validate data structures, enforce strict type checks, and catch errors early in the development process.

👉 Absolute Imports: Clean import paths using # prefix aliases for more organized and readable code.

👉 Business Listings: Create, update, delete, and browse business listings efficiently.

👉 Database Integration: Integrate PostgreSQL with Drizzle ORM, including migrations for schema management.

👉 Deal Management: Create deals on listings, accept or reject offers, and track deal status.

👉 Docker Support: Full containerization with development and production environments for consistent deployment.

👉 ESLint + Prettier: Enforce code linting and formatting rules for cleaner, consistent code.

👉 Health Monitoring: Endpoint to check system health and monitor overall application status.

👉 Hot Reload: Development server automatically restarts on file changes for faster iteration.

👉 Jest Testing: Framework for unit and integration testing with SuperTest for HTTP endpoints.

👉 Request Validation: Validate all API inputs using Zod schemas to ensure data integrity.

👉 Role-Based Access Control: Implement admin and user roles with permission middleware for secure operations.

👉 Structured Logging: Winston-based logging throughout the application for better monitoring and debugging.

👉 User Authentication & Authorization: JWT-based authentication supporting signup, signin, and signout workflows.

👉 User Management: CRUD operations for user accounts, enabling easy administration and management.

And many more, including code architecture and reusability.

Follow these steps to set up the project locally on your machine.

Prerequisites

Make sure you have the following installed on your machine:

Cloning the Repository

git clone https://github.com/aswazone/wrapjet-prod-scale-api.git

cd wrapjet-prod-scale-api

🐳 Docker Setup (Recommended)

This project supports two deployment modes: Development (with Neon Local) and Production (with Neon Cloud).

📦 Development Environment (Local with Neon Local)

Use Neon Local to run a local PostgreSQL instance that simulates Neon's serverless database for development.

1. Set Up Environment Variables

The .env.development file is already configured for local development:

# Server configuration
PORT=3000
NODE_ENV=development
LOG_LEVEL=debug

# Database configuration - Neon Local (Docker Compose)
DATABASE_URL=postgres://postgres:postgres@neon-local:5432/wrapjet_dev

2. Start Development Environment

Run the application with Neon Local using Docker Compose:

docker-compose -f docker-compose.dev.yml up --build

This will:

  • Start Neon Local (PostgreSQL) on localhost:5432
  • Start the application on localhost:3000
  • Enable hot-reload for development

3. Run Database Migrations

Once the containers are running, execute migrations:

docker-compose -f docker-compose.dev.yml exec app npm run db:migrate

4. (Optional) Access Drizzle Studio

To manage your database visually with Drizzle Studio:

docker-compose -f docker-compose.dev.yml --profile tools up drizzle-studio

Access Drizzle Studio at: http://localhost:4983

5. Stop Development Environment

docker-compose -f docker-compose.dev.yml down

To remove volumes (database data):

docker-compose -f docker-compose.dev.yml down -v

🚀 Production Environment (Neon Cloud)

For production, the application connects to Neon Cloud (serverless PostgreSQL).

1. Set Up Environment Variables

Update .env.production with your Neon Cloud database URL:

# Server configuration
PORT=3000
NODE_ENV=production
LOG_LEVEL=info

# Database configuration - Neon Cloud (Production)
DATABASE_URL=postgres://user:password@ep-example-123456.us-east-2.aws.neon.tech/wrapjet_prod?sslmode=require

⚠️ Security Note: In production, inject DATABASE_URL via environment variables from your secrets manager (AWS Secrets Manager, Kubernetes Secrets, etc.). Never commit production credentials to version control.

2. Start Production Environment

Export your production database URL and start the application:

Linux/macOS:

export DATABASE_URL="your-neon-cloud-database-url"
docker-compose -f docker-compose.prod.yml up --build -d

Windows (PowerShell):

$env:DATABASE_URL="your-neon-cloud-database-url"
docker-compose -f docker-compose.prod.yml up --build -d

3. Run Database Migrations

docker-compose -f docker-compose.prod.yml exec app npm run db:migrate

4. Monitor Logs

docker-compose -f docker-compose.prod.yml logs -f app

5. Stop Production Environment

docker-compose -f docker-compose.prod.yml down

💻 Local Setup (Without Docker)

If you prefer to run the application without Docker:

Installation

Install the project dependencies using npm:

npm install

Set Up Environment Variables

Create a new file named .env in the root of your project and add the following content:

# Server Configuration
PORT=3000
NODE_ENV=development
LOG_LEVEL=info

# Database Configuration
DATABASE_URL=

# Arcjet
ARCJET_KEY=

Replace the placeholder values with your real credentials. You can get these by signing up at: Arcjet, Neon.

Running the Project

npm run dev

Open http://localhost:3000 in your browser to view the project.


📚 Additional Docker Commands

View Running Containers

docker ps

Access Application Shell

# Development
docker-compose -f docker-compose.dev.yml exec app sh

# Production
docker-compose -f docker-compose.prod.yml exec app sh

View Application Logs

# Development
docker-compose -f docker-compose.dev.yml logs -f app

# Production
docker-compose -f docker-compose.prod.yml logs -f app

Rebuild Containers

# Development
docker-compose -f docker-compose.dev.yml up --build

# Production
docker-compose -f docker-compose.prod.yml up --build

🗃️ Database Management

Generate Migrations

npm run db:generate

Run Migrations

# Development
docker-compose -f docker-compose.dev.yml exec app npm run db:migrate

# Production
docker-compose -f docker-compose.prod.yml exec app npm run db:migrate

Open Drizzle Studio

npm run db:studio

🔐 Environment Variables Reference

Variable Description Development Production
NODE_ENV Environment mode development production
PORT Application port 3000 3000
LOG_LEVEL Logging verbosity debug info
DATABASE_URL PostgreSQL connection string Neon Local Neon Cloud
ARCJET_KEY Arcjet API key Your dev key Your prod key

🌐 Neon Database Setup

Development: Neon Local

  • Automatically started via docker-compose.dev.yml
  • Runs PostgreSQL locally in a Docker container
  • Simulates Neon's serverless database features
  • Data persists in Docker volumes
  • Learn more: Neon Local Documentation

Production: Neon Cloud

  • Fully managed serverless PostgreSQL
  • Sign up at: Neon
  • Create a project and database
  • Copy your connection string to .env.production
  • Supports autoscaling, branching, and point-in-time recovery

Aswazone

Follow Aswazone on GitHub for more projects simillar to this.

About

Wrapjet Secure Scale API — A production-grade backend built with Node.js, Express.js, Neon Postgres, Drizzle ORM, and Zod. Fully Dockerized with CI/CD automation and Arcjet integration for robust, scalable, and secure deployments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published