This document outlines the DevOps practices, build processes, and deployment strategies for the Form Engine Backend project.
- Runtime: Bun
- Framework: ElysiaJS
- Language: TypeScript
- Database: PostgreSQL
- ORM: Prisma
- Auth: Better Auth
- Logging: Pino
- Testing: Bun Test
- Linting: Biome
- API Client: Bruno
- Node.js: v18+ (Recommended for some tools)
- Bun: Latest version (
curl -fsSL https://bun.sh/install | bash) - Docker: For running the database locally.
Clone the repository and install dependencies using Bun:
git clone <repository-url>
cd form-engine-backend
bun installStart the PostgreSQL database using Docker Compose:
docker-compose up -dGenerate the Prisma client:
bunx prisma generateThe server will start on port 8000.
bun run devEnsure code quality before pushing changes.
Used Biome for both linting and formatting.
# Check for linting/formatting errors
bun run check
# Fix auto-fixable issues
bunx biome check --writeTypeScript validation:
bun run typecheckRun unit tests via Bun Test:
# Run tests
# Run tests (Coverage enabled by default in bunfig.toml)
bun testThe project uses Bruno for API documentation and testing.
- Collections are located in the
./brunodirectory. - Open the
./brunofolder in the Bruno app to view and run API requests.
The project is built using Bun's bundler, targeting the Bun runtime.
bun run buildOutput:
- Directory:
./dist - Artifact:
dist/index.js - Target: Bun (minified)
To containerize the application for deployment (e.g., for Kubernetes or Cloud Run), use the following configuration.
Create a file named Dockerfile in the root:
FROM oven/bun:1 AS base
WORKDIR /app
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lock /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
RUN mkdir -p /temp/prod
COPY package.json bun.lock /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build
# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /app/dist/index.js index.js
COPY --from=prerelease /app/package.json package.json
# run the app
USER bun
EXPOSE 8000/tcp
ENTRYPOINT [ "bun", "run", "index.js" ]node_modules
dist
.git
.env
We use GitHub Actions to validate code on every Pull Request.
The workflow is defined in .github/workflows/backend-ci.yml.
Key Steps:
- Checkout code: Pulls the code from the repository.
- Setup Bun: Installs the Bun runtime.
- Cache dependencies: Caches
node_modulesand database-related artifacts to speed up builds. - Install dependencies:
bun install. - Generate Prisma client: Generates the type-safe database client.
- Code quality check: Runs
bun run check(Biome). - Type checking: Runs
bun run typecheck. - Run database migrations: Applies Prisma migrations to the test database.
- Security audit: Runs
bun audit. - Build application: Runs
bun run build. - Build verification: Ensures the built artifact can start.
- Upload artifacts: Saves the
distdirectory.
The following diagram illustrates the automated DevOps pipeline from code commit to deployment.
graph TD
A[Code Commit] -->|Push to Main| B(CI Pipeline)
B --> C{Checks Pass?}
C -->|No| D[Notify Developer]
C -->|Yes| E[Build Application]
E --> F[Create Docker Image]
F --> G[Push to Registry]
G --> H[Deploy to Target Env]
This section details the source, deployment target, and validation checks for each major component.
| Attribute | Description |
|---|---|
| Source Code Repo | form-engine-backend (Git) |
| Deployment Location | Docker Container in Kubernetes / Cloud Run / VPS |
| Tools & Platforms | Docker (Containerization), GitHub Actions (CI/CD), Bun (Runtime) |
| Pre-Deployment Checks | 1. Linting: bun run check2. Type Checking: bun run typecheck3. Unit Tests: bun test4. Security Audit: bun audit5. Build Verification: bun run build |
| Attribute | Description |
|---|---|
| Source Definition | prisma/schema.prisma in form-engine-backend Repo |
| Deployment Location | Managed PostgreSQL Service (e.g., AWS RDS, Supabase) or StatefulSet |
| Tools & Platforms | Prisma (ORM & Migrations), PostgreSQL 17 (Database Docker Image) |
| Pre-Deployment Checks | 1. Schema Validation: bunx prisma validate2. Migration Status: bunx prisma migrate status3. Migration Apply: bunx prisma migrate deploy (during deployment) |
The following tools and libraries are standardized for this project's DevOps lifecycle:
- Source Control: GitHub