Note: This project is a work in progress. The connection between the frontend and backend is not yet fully implemented.
A modern, full-stack TypeScript monorepo built with Turborepo, featuring a React frontend, Hono API server, ORPC for type-safe RPC, and Drizzle ORM.
- TypeScript: Statically typed JavaScript at scale
- Turborepo: High-performance build system for JavaScript/TypeScript monorepos
- pnpm: Fast, disk space efficient package manager
- Node.js 22+: JavaScript runtime built on Chrome's V8 JavaScript engine
- React 19: Library for building user interfaces
- TanStack Router: Type-safe routing solution
- TanStack Query: Powerful asynchronous state management
- TanStack Form: Type-safe form state management
- Tailwind CSS: Utility-first CSS framework
- Radix UI: Unstyled, accessible UI components
- Hono: Ultrafast web framework for the Edges
- ORPC: Type-safe RPC framework for TypeScript
- Better Auth: Authentication library
- OpenAPI: API documentation with Scalar
- Drizzle ORM: TypeScript ORM for SQL databases
- PostgreSQL: Advanced open-source relational database
- Biome: Fast linter and formatter replacing ESLint and Prettier
- dotenv: Environment variable management
- tsx: TypeScript execution environment
contract-based-monorepo/
├── apps/ # Application code
│ ├── api/ # Hono API server with ORPC
│ └── web/ # React frontend with TanStack Router
│
├── packages/ # Shared packages
│ ├── contract/ # API contracts and schemas
│ ├── db/ # Database schema and access layer
│ └── ui/ # Shared UI components
│
└── .env # Environment variables (create from example)
- Git
- Docker and Docker Compose
- Visual Studio Code
- VS Code Remote - Containers extension
This project includes a DevContainer configuration that automatically sets up the development environment with all the necessary dependencies, including Node.js 22, TypeScript, npm, eslint, and PostgreSQL.
- Clone the repository:
git clone https://github.com/gthomas08/contract-based-monorepo.git
cd contract-based-monorepo
- Open the project in VS Code:
code .
-
When prompted, click "Reopen in Container" or run the "Remote-Containers: Reopen in Container" command from the command palette.
-
The DevContainer will automatically:
- Build the Docker container with Node.js 22 and TypeScript
- Set up a PostgreSQL database container
- Install all dependencies with
pnpm install
- Forward ports: 3000 (web), 3001 (api), 4983 (drizzle-studio), and 5432 (postgres)
-
Set up environment variables:
cp .env.example .env
# Edit .env with your database connection string and other settings
- Push database schema:
pnpm -F @contract-based-monorepo/db push
API Documentation: After starting the API server, visit http://localhost:3001/api/docs for interactive API docs.
Run all applications in development mode:
pnpm dev
Or run specific applications:
# API server only
pnpm -F @contract-based-monorepo/api dev
# Web frontend only
pnpm -F @contract-based-monorepo/web dev
Build all applications:
pnpm build
Run type checking across all packages:
pnpm type:check
The project uses Biome for linting and formatting instead of ESLint and Prettier:
# Lint
pnpm lint
# Format
pnpm format
# Check (lint + format)
pnpm check
The project includes a comprehensive DevContainer setup for VS Code:
.devcontainer/devcontainer.json
: Main configuration file for the DevContainer.devcontainer/docker-compose.yml
: Docker Compose configuration for the app and PostgreSQL services.devcontainer/Dockerfile
: Docker configuration for the Node.js 22 and TypeScript environment
The DevContainer automatically forwards the following ports:
3000
: Web frontend3001
: API server4983
: Drizzle Studio5432
: PostgreSQL database
The DevContainer automatically installs these VS Code extensions:
- Docker (
ms-azuretools.vscode-docker
) - ESLint (
dbaeumer.vscode-eslint
)