Skip to content

jarodtaylor/fastify-project-starter

Repository files navigation

Fastify Project Starter

πŸš€ CLI tool to generate production-ready Fastify-based fullstack projects with multiple frontend framework options

A flexible project generator that creates modern, scalable fullstack applications with Fastify APIs and your choice of frontend framework. Built with TypeScript, modern tooling, and industry best practices.

✨ Quick Start

# Create a React Router project (default)
npx create-fastify-project my-app
cd my-app
pnpm dev

That's it! Your fullstack application is running:

🎯 Available Templates

Template Description Status
react-router React Router 7 + SSR + File-based routing βœ… Stable
nextjs Next.js + App Router + Server Components 🚧 Coming Soon
solidjs SolidJS + SolidStart + Islands Architecture 🚧 Coming Soon
svelte Svelte + SvelteKit + Server-side rendering 🚧 Coming Soon
# Currently only React Router is available
npx create-fastify-project my-app
npx create-fastify-project my-app --template react-router

# Coming soon:
# npx create-fastify-project my-app --template nextjs
# npx create-fastify-project my-app --template solidjs

πŸ› οΈ CLI Options

All templates support these customization options:

# Database options
npx create-fastify-project my-app --db postgres
npx create-fastify-project my-app --db mysql
npx create-fastify-project my-app --db sqlite  # default

# Development options
npx create-fastify-project my-app --lint eslint
npx create-fastify-project my-app --no-install
npx create-fastify-project my-app --no-git

# Combine options
npx create-fastify-project my-app --template react-router --db postgres --lint eslint

πŸ“ What You Get

Every generated project includes:

πŸš€ High-Performance API (Fastify)

  • TypeScript-first with full type safety
  • 65k+ requests/sec capability (2x faster than Express)
  • Built-in CORS, error handling, and validation
  • Hot reload development experience

βš›οΈ Modern Frontend (Template-Specific)

  • React Router: SSR, file-based routing, optimistic UI
  • Next.js: App Router, Server Components, streaming
  • SolidJS: Fine-grained reactivity, minimal runtime
  • Svelte: Compiled components, optimal performance

πŸ—„οΈ Database Ready (Prisma ORM)

  • SQLite for development, PostgreSQL/MySQL for production
  • Type-safe queries with auto-generated types
  • Visual database browser with Prisma Studio
  • Migration system for schema evolution

πŸ“¦ Monorepo Architecture (Turborepo)

  • Shared packages for code reuse across apps
  • Optimized build caching and parallelization
  • Independent scaling and deployment strategies

πŸ“Š Project Structure

my-app/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                 # Fastify API server
β”‚   └── web/                 # React Router 7 frontend
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ database/            # Shared Prisma database
β”‚   β”œβ”€β”€ shared-utils/        # Shared utilities
β”‚   β”œβ”€β”€ typescript-config/   # Shared TypeScript configs
β”‚   └── ui/                  # Shared UI components
β”œβ”€β”€ .env.example             # Environment variables template
β”œβ”€β”€ package.json             # Root workspace config
└── turbo.json              # Monorepo build system

πŸš€ Getting Started

1. Generate Project

npx create-fastify-project my-app
cd my-app

2. Environment Setup

If using PostgreSQL or MySQL:

# Copy environment template
cp .env.example .env

# Add your database URL
echo 'DATABASE_URL="postgresql://user:pass@host:5432/dbname"' >> .env

3. Start Development

# Install dependencies (if you used --no-install)
pnpm install

# Set up database
pnpm db:push

# Start all development servers
pnpm dev

πŸ“Š Available Scripts

# Development
pnpm dev              # Start all development servers
pnpm build            # Build all packages for production
pnpm typecheck        # Run TypeScript checks

# Database
pnpm db:generate      # Generate Prisma client
pnpm db:push          # Push schema to database
pnpm db:studio        # Open database browser
pnpm db:migrate       # Create and run migrations

# Code Quality
pnpm format           # Format code with Biome/ESLint
pnpm lint             # Lint code

πŸ—„οΈ Database Setup

SQLite (Default)

  • βœ… Zero setup required - works out of the box
  • βœ… Perfect for development and small applications
  • πŸ“ Database file: data/dev.db

PostgreSQL (Recommended for Production)

  • πŸš€ Production-ready with ACID compliance
  • πŸ”’ Advanced features - JSON columns, full-text search
  • 🌐 Hosted options: Railway, Supabase, Neon, Vercel Postgres

MySQL

  • πŸš€ Production-ready with wide ecosystem support
  • ⚑ High performance for read-heavy workloads
  • 🌐 Hosted options: PlanetScale, AWS RDS, DigitalOcean

πŸš€ Deployment

Vercel (Recommended)

npm i -g vercel
vercel
# Add DATABASE_URL in Vercel dashboard

Railway

npm i -g @railway/cli
railway login && railway init && railway up

Docker

docker build -t my-app .
docker run -p 3000:3000 my-app

🎯 Perfect For

  • 🏒 Business Applications - CRM, admin panels, dashboards
  • πŸ’° SaaS Products - User authentication, billing, multi-tenancy ready
  • πŸ›’ E-commerce - Product catalogs, shopping carts, order management
  • πŸ“± Social Apps - User profiles, feeds, real-time features
  • πŸ“Š Analytics Dashboards - Data visualization, reporting tools

πŸ”§ Troubleshooting

PostgreSQL Setup Issues

If you see database connection errors:

# 1. Ensure your database is running
# 2. Check your DATABASE_URL in .env
# 3. Try manual setup:
cd packages/database
cp .env.example .env
# Edit .env with your DATABASE_URL
pnpm prisma generate
pnpm prisma db push

Dependencies Installation

If dependencies fail to install:

# Clear package manager cache
pnpm store prune
rm -rf node_modules
pnpm install

πŸ“š Learn More

Framework Documentation

Project Resources

πŸ“„ License

MIT License - see LICENSE for details.


Ready to build something amazing? πŸš€

npx create-fastify-project my-app
cd my-app
pnpm dev

About

A CLI generator for fullstack monorepo applications with Fastify API, Prisma ORM, and React Router 7 frontends.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published