Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌬️ Breeze GraphQL Starter (Enterprise SaaS Edition)

An enterprise-grade Bun + Hono + GraphQL Yoga + Drizzle ORM (PostgreSQL 17) + Redis starter designed for high-performance SaaS backends.


✨ Features

  • ⚑️ Bun Runtime – Instant startup and high throughput.
  • 🌐 Hono HTTP Framework – Webhook routers (/webhooks/stripe), CORS, security headers, and health probes (/health).
  • πŸ“œ GraphQL Yoga 5 – Fast, standards-compliant GraphQL engine with interactive Studio.
  • 🐘 Drizzle ORM + PostgreSQL 17 – End-to-end type safety with native UUIDs, timestamps, and relational queries.
  • πŸ”΄ Redis L2 Caching & PubSub – Multi-key DataLoader caching to eliminate N+1 database queries.
  • πŸ“¦ Feature Module Pattern – Clean co-location of types, resolvers, services, and loaders.
  • πŸ” JWT Authentication & Guards – Token verification via jose with requireAuth() and requireRole().
  • πŸ›‘οΈ GraphQLException v2 – Typed error handling mapped to standard HTTP status codes.
  • πŸ“Š Dual-Mode Structured Logger – Pretty colored terminal in development, single-line structured JSON in production.
  • 🐳 Docker Compose – 1-command startup for PostgreSQL 17 and Redis 7.

πŸ“‚ Architecture & Directory Structure

src/
β”œβ”€β”€ index.ts                       # Hono HTTP router + Yoga mount + Webhooks + Bun.serve
β”œβ”€β”€ env.ts                         # Zod-validated environment variables
β”‚
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ auth/jwt.ts                # Fast JWT signing & verification (jose)
β”‚   β”œβ”€β”€ error/exceptions.ts        # Typed GraphQLException with HTTP status mapping
β”‚   β”œβ”€β”€ redis/index.ts             # Singleton Redis connection client
β”‚   └── utils/logger.ts            # Dual-mode structured logger
β”‚
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ index.ts                   # Drizzle PostgreSQL client (postgres-js)
β”‚   β”œβ”€β”€ schema/                    # PostgreSQL table definitions & Drizzle-Zod schemas
β”‚   β”œβ”€β”€ migrations/                # Generated SQL migration files
β”‚   └── migrate.ts                 # Programmatic migration runner
β”‚
└── graphql/
    β”œβ”€β”€ context.ts                 # GraphQL Context (db, user, requireAuth, loaders)
    β”œβ”€β”€ schema.ts                  # Root schema merger
    β”‚
    └── modules/
        └── task/                  # πŸ“¦ Feature Module
            β”œβ”€β”€ task.types.ts      # GraphQL TypeDefs & Pagination inputs
            β”œβ”€β”€ task.services.ts   # Atomic 1-query business logic (.returning())
            β”œβ”€β”€ task.resolvers.ts  # Resolvers with unmasked error handling
            └── task.loader.ts     # Batched DataLoader with Redis L2 cache

πŸš€ Getting Started

1. Clone & Install Dependencies

bun install

2. Start PostgreSQL & Redis via Docker

bun run db:up

3. Run Database Migrations

bun run db:migrate

4. Start Development Server

bun run dev

🌿 Branches

  • main (Flagship): Full SaaS architecture with PostgreSQL 17, Redis, Docker Compose, and Hono.
  • sqlite: Minimalist zero-Docker version running on embedded SQLite.

πŸ› οΈ Available Scripts

Command Description
bun run dev Start development server with hot-reloading
bun run db:up Start PostgreSQL 17 and Redis Docker containers
bun run db:down Stop Docker containers safely
bun run db:logs View real-time database and redis logs
bun run db:generate Generate new Drizzle SQL migration files
bun run db:migrate Execute pending database migrations
bun run db:studio Open interactive Drizzle Studio in browser
bun run typecheck Run TypeScript compiler type check
bun run format Format codebase with Biome
bun run lint Check and fix lint issues with Biome

πŸ” Environment Variables (.env)

PORT=3000
NODE_ENV=development
DEBUG=1

# Database & Redis
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/breeze_db
REDIS_URL=redis://localhost:6379

# Authentication
JWT_SECRET=super-secret-key-change-in-production-min-32-chars-long

πŸ›‘οΈ Error Handling

Breeze uses GraphQLException mapped to standard HTTP status codes:

// In your services or resolvers:
throw GraphQLException.notFound("Task not found");
throw GraphQLException.unauthenticated("Authentication required");
throw GraphQLException.forbidden("Admin access only");
throw GraphQLException.badInput("Invalid task name");

πŸ“„ License

MIT Β© Mohamed

About

πŸƒ Minimal, fast, and modern GraphQL starter kit β€” Bun + Drizzle ORM

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages