Monorepo template for full-stack development with TypeScript, React, Bun, and Elysia.
| Name | Description | Docs |
|---|---|---|
| Runtime & Build Tools | ||
| Bun | High-performance JavaScript/TypeScript runtime | Link |
| Turbo | Build system for monorepos | Link |
| Frontend | ||
| React | Library for user interfaces | Link |
| TanStack Router | Type-safe routing | Link |
| TanStack Query | Server state management | Link |
| Vite | Build tool and dev server | Link |
| Tailwind CSS | Utility-first CSS framework | Link |
| Backend | ||
| Elysia | Fast TypeScript web framework | Link |
| Better Auth | Authentication system | Link |
| Database | ||
| Drizzle ORM | TypeScript ORM for PostgreSQL | Link |
| PostgreSQL | Relational database | Link |
| Redis | Cache and in-memory storage | Link |
| DevOps & Deploy | ||
| Vercel | Frontend deployment | Link |
| Fly.io | Backend deployment | Link |
| GitHub Actions | CI/CD | Link |
| Code Quality | ||
| Biome | Linter and formatter | Link |
| TypeScript | JavaScript superset with types | Link |
monorepo-template/
βββ apps/
β βββ api/ # Backend API (Elysia + Bun)
β βββ web/ # Frontend (React + Vite)
βββ packages/
β βββ auth/ # Authentication (Better Auth)
β βββ cache/ # Cache (Redis)
β βββ database/ # Database (Drizzle + PostgreSQL)
β βββ design-system/ # Shared UI components
β βββ linter/ # Linting configuration
β βββ tsconfig/ # TypeScript configurations
β βββ validation/ # Validation schemas (Zod)
βββ scripts/ # Utility scripts
This project is a template. To create a new repository from this template:
- Click the "Use this template" button on GitHub
- Follow the instructions to create your repository
- Clone the created repository
- Configure environment variables (see sections below)
For local development, you can automatically create .env files from .env.example files by running:
bun run build:envsThis command will copy all .env.example files to .env in the respective apps/packages. After that, you can configure the values in each .env file. Check the documentation for each app/package:
- π API - Environment Variables
- π Web - Environment Variables
- π Auth Package
- π Database Package
- π Cache Package
The project uses GitHub Actions for automatic CI/CD. Deployment is triggered when a release is published on GitHub.
- Trigger: Publishing a release on GitHub
- Change Detection: The workflow detects changes in
apps/weborapps/api - Automatic Deploy:
- Web: Deploy to Vercel
- API: Deploy to Fly.io
- Health Check: Automatic API health verification
- Rollback: Automatic rollback on failure
For CI/CD to work, you need to add the following secrets on GitHub:
- Go to the repository on GitHub
- Click Settings
- In the sidebar, click Secrets and variables β Actions
- Click New repository secret
Vercel access token for frontend deployment.
How to get:
- Go to Vercel Dashboard
- Go to Settings β Tokens
- Click Create Token
- Give the token a name (e.g., "GitHub Actions")
- Copy the generated token
- Documentation: Vercel - Authentication
Add to GitHub:
- Name:
VERCEL_TOKEN - Value: Paste the copied token
- Click Add secret
Fly.io access token for backend deployment.
How to get:
- Go to Fly.io Dashboard
- Run in terminal:
fly auth token - Copy the displayed token
- Documentation: Fly.io - Access Tokens
Add to GitHub:
- Name:
FLY_API_TOKEN - Value: Paste the copied token
- Click Add secret
After creating the app on Fly.io, add environment variables:
Via Dashboard:
- Go to Fly.io Dashboard
- Select your app (
monorepo-template-api) - Go to Secrets
- Add each environment variable
- Documentation: Fly.io - Secrets
Reference Links:
- π Fly.io - Environment Variables
- π Fly.io - PostgreSQL
- π Fly.io - Redis
Via Dashboard:
- Go to Vercel Dashboard
- Select your project (
monorepo-template-web) - Go to Settings β Environment Variables
- Add the variable:
- Key:
VITE_API_URL - Value: Your API URL (e.g.,
https://monorepo-template-api.fly.dev) - Environment: Production, Preview, Development (select as needed)
- Key:
- Click Save
- Documentation: Vercel - Environment Variables
Reference Links:
To trigger deployment:
- Go to the Releases tab on GitHub
- Click Create a new release
- Choose the tag (or create a new one)
- Fill in the title and description
- Click Publish release
- CI/CD will be triggered automatically
Documentation: GitHub - Creating Releases
- π Auth - Authentication with Better Auth
- π Database - Database with Drizzle ORM
- π Cache - Cache with Redis
- Bun installed (version 1.3.3 or higher)
- Docker and Docker Compose (for local database)
Important: It's recommended to use the minimum of TypeScript aliases (paths in tsconfig.json) in packages, as it can cause conflicts with apps during type checking. Prefer using relative imports or direct package imports when possible.
# Install dependencies
bun install
# Development (all apps)
bun dev
# Build (all apps)
bun build
# Linting
bun lint
# Formatting
bun formatbun dev- Starts all apps in development modebun build- Builds all appsbun preview- Preview of buildsbun lint- Runs the linterbun format- Formats the codebun check- Checks code and formattingbun check:write- Automatically fixes found issues
When running bun run dev on Windows, you may see a message about files "outside the project directory" not being watched. This is a Windows limitation related to the limited number of file watchers. It's just a safety measure from Bun and doesn't affect functionality. For more details, see the API README.
