Paulo BiaoPaulo BiaoSystems & Cloud Analyst
Projects
Deployed project· Currently offline

BiaoTech API

Cloud-Deployed REST API & CI/CD

A TypeScript/Express REST API built to take a backend through the complete engineering path — from authentication and database integration to automated testing, CI/CD and deployment on AWS EC2.

  • TypeScript
  • Node.js
  • Express
  • PostgreSQL
  • AWS EC2
  • GitHub Actions
  • PM2

The EC2 environment is offline, so no live endpoints are linked. Everything here is derived from the source repository.

Source & delivery
GitHub
push · main
Actions
workflow
Validation
types · lint · tests
SSH deploy
needs: test
AWS EC2single instance · manually provisioned
Web
  • React SPA
    built on deploy
  • Nginx
    serves the SPA
API
  • Express · TS
    REST API
  • PM2
    process manager
PostgreSQL
hosting not in repo
Docker Compose · local devAPI proxy / TLS config not preserved in repo
01 · Engineering goal

A small scope, carried through the whole lifecycle

An end-to-end backend and cloud-deployment exercise. The business scope is intentionally small — authentication, user management and administrative operations — so the engineering effort goes into everything around it.

  1. 01
    API design
    Express 5 · REST · OpenAPI 3
  2. 02
    Database
    PostgreSQL · SQL migrations
  3. 03
    Auth & security
    JWT · RBAC · Helmet
  4. 04
    Testing
    Jest · Supertest
  5. 05
    CI/CD
    GitHub Actions
  6. 06
    Cloud deploy
    AWS EC2 · PM2
02 · API & security

11 routes, three access levels, layered controls

Documented with swagger-jsdoc annotations and served as Swagger UI. Every user route requires a JWT; every write also requires the admin role.

Route surfacePublicJWTJWT + Admin
System
  • GET/Public
  • GET/api/healthPublic
    Database-aware health check
  • GET/api/docsDocs
    Swagger UI · OpenAPI 3.0
Authentication
  • POST/api/auth/loginPublic
  • POST/api/auth/refreshPublic
  • GET/api/auth/meJWT
Users
  • GET/api/usersJWT
    ?page · limit · search
  • GET/api/users/:idJWT
  • POST/api/usersJWT + Admin
  • PUT/api/users/:idJWT + Admin
  • DELETE/api/users/:idJWT + Admin
Authentication
  • JWT access tokens · 1h default
  • Refresh tokens · 7d default
  • Separate signing secrets
  • bcrypt password hashing
Authorization
  • RBAC with admin and user roles
  • authorizeRoles("admin") on every user write
  • JWT required on all user reads
API hardening
  • Helmet security headers
  • Rate limit · 100 req / 15 min
  • CORS allowlist from config
  • Zod request validation
Operations
  • Health check runs SELECT 1 · HTTP 500 when the database is unreachable
  • X-Request-Id on every response
  • Pino structured request logs
  • Centralized 404 and error handling
  • Admin seed refuses to run without ADMIN_PASSWORD
Trade-off · token storage

The React client keeps both tokens in localStorage — simple, and documented in the repository, but readable by any script on the page. The identified improvement is an httpOnly refresh cookie with the access token held in memory.

/api/health · response shape
{ "success": true, "status": "ok",
  "service": "biaotech-api",
  "environment": <NODE_ENV>,
  "database": "connected",
  "uptime": <process.uptime()>,
  "timestamp": <ISO-8601> }
Response shape from healthController.ts — not a captured live response.
03 · Testing & delivery

Deployment gated behind a real test suite

One GitHub Actions workflow runs on every push to main. The deploy job declares needs: test — nothing reaches EC2 unless types, lint and the integration suite pass against a real PostgreSQL.

job: testubuntu-latest · Node.js 20
  1. Push to main
    Workflow trigger
  2. Type check
    tsc --noEmit
  3. Lint
    ESLint
  4. Tests
    Jest + Supertest against a PostgreSQL 16 service container
needs: test
job: deploySSH into the EC2 host
  1. SSH
    appleboy/ssh-action
  2. AWS EC2
    Reset to main · npm build
  3. PM2
    Restart the backend process
  4. Nginx
    SPA build copied · config test · reload
11integration
tests
Auth
2
Health
1
Users
8
Selected cases
  • Logs in and returns a JWT
  • Denies access without a token
  • Validates the user name
  • Denies delete for the user role
  • Allows delete for the admin role
  • Reports API health

Run history is public in the repository's Actions tab; no live pipeline status is shown here.

04 · Engineering decisions

Boundaries of the original approach

The right column is direction, not retrofit — none of it was implemented in BiaoTech API.

Single EC2 instance

One host, no horizontal scaling.

Reproducible infrastructure that can be recreated from code
Cloud Lab design
Manual provisioning

The original deployment was not defined as Infrastructure as Code.

Terraform-defined AWS architecture
Cloud Lab design
SSH deployment

CI held a long-lived SSH key in repository secrets.

OIDC-based, least-privilege delivery design
Cloud Lab design
PM2 host process

Production ran as a PM2-managed Node process, not containers.

Container-oriented workloads
Cloud Lab design
Docker for local dev only

Compose ran the API, PostgreSQL and Adminer locally — never the production runtime.

The container image as the deployable unit
Cloud Lab design
localStorage tokens

Simple to build, but readable by any script on the page.

httpOnly, SameSite=Strict refresh cookie; access token in memory
Identified · not implemented

Evidence boundaries: the previously deployed AWS environment is currently offline, and the repository does not preserve the API reverse-proxy/TLS configuration or where production PostgreSQL was hosted.

05 · Evolution

From deployment to reproducible infrastructure

The limits of a manually provisioned, SSH-deployed server motivated the next infrastructure exercise.

Deployed project
BiaoTech API
  • AWS EC2
  • GitHub Actions
  • SSH deploy
  • PM2
  • Manual provisioning
Design validated · not deployed
BiaoTech Cloud Lab
  • Terraform
  • Containers
  • GitHub OIDC
  • Least privilege
  • Zero-spend guardrails

AWS architecture defined in Terraform — not deployed.