Avatar
← Back to Portfolio

HTTP Backends (Java & Node)

Parallel backends in Spring Boot and Express that expose the same REST surface: CRUD, validation, JWT auth, pagination, rate limiting, background jobs, OpenAPI, k6 load tests—Dockerized with Postgres/Redis and basic observability.

JavaSpring BootNode.jsExpressPostgreSQLSupabaseRedisDockerNGINXk6JWT
View Repository →

The Goal

Build the same HTTP API twice—once in Spring Boot (Java) and once in Express (Node)—to compare ergonomics, performance, testing strategies, and deployment. Both backends share Postgres and Redis and are exercised with identical curl, k6, and integration tests.

Solution Overview

  • Common REST surface: /health, /todos, /bookmarks
  • Full validation, pagination, filtering, and sorting parity
  • JWT auth + refresh tokens; rate limiting via Redis
  • OpenAPI spec, k6 load tests, and Dockerized local stack

Architecture & Stack

Node.js Service

  • Express + Zod validation
  • pg client for Postgres
  • Redis cache + rate limiting
  • Jest integration tests

Java Service

  • Spring Boot (Web, Data JPA)
  • Hibernate → Postgres
  • JWT filter + Controller/Service/Repo
  • Maven + Spring Test

[Architecture Diagram Placeholder]

Java & Node services → NGINX → Postgres + Redis

Key Endpoints (Shared Contract)

  • GET /health – service + DB + cache status
  • GET /todos?limit=&offset= – pagination
  • POST /todos, PATCH /todos/:id, DELETE /todos/:id
  • /bookmarks – filtering, sorting, search
  • /auth/login, /auth/refresh
# Create
curl -X POST localhost:4000/todos \
  -H 'content-type: application/json' \
  -d '{"title":"learn http","done":false}'

Tests, Perf & Observability

  • Integration tests for success & error paths; OpenAPI contract checks
  • k6 load tests; compare p95 latency Java vs Node
  • Request ID logging, basic metrics (/metrics)

Deployment

Docker Compose for local dev (Postgres + Redis + both services). CI builds and runs tests; images can be pushed to a registry and deployed behind NGINX as an API gateway.