A fast, modern full-stack monorepo starter to help you build and scale apps quickly. Built with Bun, TurboRepo, Elysia, React, Vite, Drizzle ORM, and TypeScript.
- β‘οΈ Superfast stack: Bun for runtime and package management, Elysia for the backend, and Vite + React for the frontend. Enjoy instant dev and build speeds.
- π¦ Elysia + Bun API: Modern, high-performance backend with Elysia on Bun.
- βοΈ React + Vite Frontend: Fast, modern SPA using React 19 and Tailwind CSS.
- ποΈ Type-safe Database: PostgreSQL with Drizzle ORM for reliable, scalable data.
- π Reusable API Client: Typed SDK for smooth integration between frontend and backend.
- ποΈ TurboRepo Monorepo: Fast builds and easy workspace management.
- π οΈ TypeScript, ESLint & Prettier: All the tools you need for clean, maintainable code.
- π³ Docker-Ready: Simple local development and deployment with Docker.
- Project Overview
- Monorepo Structure
- Tech Stack
- Getting Started
- Scripts
- Development
- Environment Variables
- Database
- Docker
- Scaling the Application
- Contributing
- License
This boilerplate provides a scalable foundation for full-stack applications. It features:
- Backend: Elysia (Bun runtime) API server
- Frontend: React (Vite, Tailwind CSS)
- Database: PostgreSQL with Drizzle ORM
- API Client: TypeScript SDK for frontend/backend communication
- Monorepo: Managed with TurboRepo and Bun workspaces
Why Relysia?
- Instant installs and builds with Bun
- Modern, type-safe, and batteries-included
- Built for speed, DX, and scalability
.
βββ apps/
β βββ api/ # Backend API (Elysia + Bun)
β βββ web/ # Frontend (React + Vite)
βββ packages/
β βββ api-client/ # TypeScript API client
β βββ db/ # Drizzle ORM config
βββ .env.example # Root environment variables template
βββ docker-compose.yml
βββ turbo.json # TurboRepo config
βββ package.json # Monorepo scripts & workspaces
βββ README.md
- Bun: Fast JS/TS runtime & package manager
- TurboRepo: Monorepo build system
- Elysia: Backend web framework (Bun)
- React: Frontend UI library
- Vite: Frontend build tool
- Drizzle ORM: Type-safe SQL ORM
- TypeScript: Static typing
- ESLint & Prettier: Linting & formatting
- Tailwind CSS: Utility-first CSS
Clone and install dependencies:
git clone <your-repo-url>
cd relysia
bun install
Set up environment variables for the entire project:
- Root environment (for Docker Compose and shared config):
cp .env.example .env
- API environment (for the backend):
cp apps/api/.env.example apps/api/.env
- Web environment (for the frontend):
cp apps/web/.env.example apps/web/.env
Important: Edit each .env
file and replace placeholder values with your actual configuration.
Run these from the repo root:
Script | Description |
---|---|
bun run dev |
Start all apps in dev mode |
bun run build |
Build all apps/packages |
bun run lint |
Lint all code |
bun run format |
Format codebase |
Or use app-specific scripts (see each package.json
).
cd apps/api
bun run dev
- Runs Elysia server at http://localhost:3000
- API route example:
GET /api/message
cd apps/web
bun run dev
- Runs Vite dev server at http://localhost:5173
Reusable TypeScript client for API calls:
cd packages/api-client
bun run build
The project uses multiple .env
files for different purposes:
DATABASE_URL
: PostgreSQL connection stringPOSTGRES_USER
,POSTGRES_PASSWORD
,POSTGRES_DB
: Database credentialsAUTH_SECRET
: JWT secret keyAUTH_BASE_URL
: Authentication base URLFRONTEND_URL
: Frontend URL for CORS
- All authentication and database variables
- OAuth provider credentials (Google, GitHub)
- API configuration
VITE_API_URL
: Backend API URL- Development server configuration
Security Notes:
- Never commit
.env
files to version control - Use strong, unique secrets in production
- Generate secure keys:
openssl rand -base64 32
- Uses PostgreSQL with Drizzle ORM.
- Configure database in
.env
andpackages/db/drizzle.config.ts
. - Run migrations using Drizzle CLI:
bunx drizzle-kit generate:pg
- Use
docker-compose.yml
to spin up local Postgres and services:
docker-compose up -d
This project is built to grow with you. Here's how you can scale it up for production:
-
API (Elysia/Bun):
- Run several API server instances behind a load balancer (Nginx, HAProxy, or your cloud provider's load balancer).
- The API is stateless, so you can add or remove instances as needed. Use Docker Compose for local scaling, or Kubernetes for production.
- For example, with Docker Compose:
docker-compose up --scale api=3
- In production, use a managed Kubernetes service (like AWS EKS, GCP GKE, or DigitalOcean Kubernetes) to automate scaling and health checks.
-
Frontend (React/Vite):
- Build your frontend for production (
bun run build
inapps/web
). - Deploy the static files to a CDN or static hosting (Vercel, Netlify, AWS S3 + CloudFront, or Cloudflare Pages).
- Use cache headers and invalidation strategies to keep content fresh.
- Build your frontend for production (
- Connection Pooling:
- Use PgBouncer or Pgpool-II to manage database connections, especially if you have many API instances.
- Read Replicas:
- For heavy read traffic, set up PostgreSQL read replicas. Route SELECT queries to replicas and writes to the primary.
- Backups and Monitoring:
- Set up automated backups and use monitoring tools (like pgAdmin, Datadog, or cloud-native solutions) to track performance and spot issues early.
- API Caching:
- Use Redis or Memcached to cache frequent queries or session data. This reduces database load and speeds up responses.
- Frontend Caching:
- Leverage browser caching and service workers for static assets and API responses. Configure your CDN for optimal cache control.
- Docker:
- Use the provided Dockerfiles to build production images for both API and frontend.
- Kubernetes:
- For serious scaling, deploy your containers to Kubernetes. Use Horizontal Pod Autoscaling to automatically adjust the number of API pods based on CPU or request load.
- Set up health checks, rolling updates, and secrets management for a robust deployment.
- API:
- If you want to go serverless, deploy the API to AWS Lambda, Google Cloud Functions, or Vercel Functions. This is great for unpredictable or spiky traffic.
- Frontend:
- Host your static frontend on a serverless platform like Vercel, Netlify, or Cloudflare Pages for instant global delivery.
π‘ Tip:
- Always monitor your app's performance and error rates. Use tools like Sentry, Datadog, or your cloud provider's monitoring suite.
- Regularly review your scaling setup as your user base grows.
- Fork and clone the repo
- Create a new branch (
git checkout -b feature/your-feature
) - Make and commit your changes
- Run lint and tests
- Push and open a PR
MIT
Happy hacking! π