A modern, production-ready Fastify backend API built with TypeScript, Drizzle ORM, and comprehensive observability through Sentry.
| Category | Technology |
|---|---|
| Runtime | Node.js 24.x |
| Framework | Fastify 5 |
| Language | TypeScript 5.9 |
| Database | PostgreSQL with Drizzle ORM |
| Build | esbuild |
| Linting | Biome |
| Monitoring | Sentry (errors, logs, profiling, tracing) |
| Package Manager | pnpm |
| Containerization | Docker (multi-stage builds) |
src/
├── index.ts # Application entry point
├── instrument/ # Sentry instrumentation setup
├── plugins/ # Fastify plugins (autoloaded)
│ ├── sensible.ts # HTTP error utilities
│ └── no-icon.ts # Favicon 404 handler
├── routes/ # API routes (autoloaded)
│ └── root.ts # Root endpoints
└── db/
└── schema.ts # Drizzle database schema
- Node.js 24.x
- pnpm 10.x
- PostgreSQL database
# Install dependencies
pnpm install
# Set up environment variables
cp .env.example .env
# Edit .env with your DATABASE_URL| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
NODE_ENV |
Environment (local, production) |
# Start development server with hot reload
pnpm watch
# Build for production
pnpm buildThe server runs on http://localhost:3008 by default.
# Generate migrations from schema changes
pnpm drizzle-kit generate
# Apply pending migrations
pnpm drizzle-kit migrate
# Open Drizzle Studio for database inspection
pnpm drizzle-kit studio| Method | Path | Description |
|---|---|---|
| GET | / |
Returns 404 (placeholder) |
| GET | /async |
Async 404 example |
| GET | /debug-sentry |
Triggers test error for Sentry |
# Build the image
docker build -t airbelgie-backend .
# Run the container
docker run -p 3008:3008 -e DATABASE_URL=<your-url> airbelgie-backendThe project includes GitHub Actions workflows for:
- Docker Build & Push: Builds and pushes images to GitHub Container Registry on push to
main - Database Migrations: Automatically runs Drizzle migrations after build
- Deployment: SSH deploys to production server
docker pull ghcr.io/airbelgie/fastify-backend:main
docker run -d --name airbelgie_backend -p 3008:3008 ghcr.io/airbelgie/fastify-backend:mainSentry is configured for comprehensive observability (disabled in local environment):
- Error Tracking: Automatic capture with Fastify integration
- Structured Logging:
Sentry.logger.info()for structured logs - Performance Tracing: 100% trace sampling
- Profiling: Automatic profiling during active traces
- Metrics: Custom metrics via
Sentry.metrics
# Format and lint
pnpm biome check --write .
# Type check
pnpm tsc --noEmitBiome is configured with:
- 2-space indentation
- Automatic import organization
- Sorted object keys
- Recommended linting rules
| Script | Description |
|---|---|
pnpm build |
Build with esbuild |
pnpm watch |
Development mode with hot reload |
pnpm test |
Run tests (not yet configured) |
AGPL-3.0-or-later
Rahul Parkar