A clean, production-ready starter template for building modern web applications with Hono and Bun. This template provides a well-structured monorepo setup with TypeScript, database integration, Docker support, and development best practices.
- β‘ Hono Framework: Fast, lightweight, and modern web framework for Bun
- π· TypeScript: Full TypeScript support with strict configuration
- π¦ Bun Runtime: Lightning-fast JavaScript runtime and package managerk
- ποΈ Monorepo Structure: Organized with
apps,packages, andinfradirectories - π Worker Support: Background job processing (BullMQ or custom workers)
- π― Clean Architecture: Separation of concerns with modular design
- ποΈ PostgreSQL: Production-ready relational database
- π· Drizzle ORM: Type-safe database operations and migrations
- π± Database Seeding: Pre-configured seeding with drizzle-seed
- β‘ Redis Integration: High-performance caching and session management (IORedis)
- π¬ BullMQ: Robust queue system for background jobs and task processing
- π JWT Authentication: Secure token-based authentication (with Hono middlewares)
- π Password Hashing: Bcrypt integration for secure password storage
- π Encryption: Crypto-JS for data encryption and decryption
- π CORS Support: Configurable cross-origin resource sharing
- π Request Validation: Type-safe validation (e.g., Zod, VineJS, or similar)
- π Logging: Structured logging with Pino and pino-pretty
- π§ Email Support: Nodemailer integration for sending emails
- βοΈ Template Ready: Pre-configured email service layer
- π³ Docker Support: Complete containerization with Docker and Docker Compose
- π§ Hot Reload: Fast development with Bun's watch mode
- π¨ Code Quality: ESLint, Prettier, and Husky for consistent code formatting
- β° Date Handling: DayJS for modern date/time operations
- π Concurrency: Run multiple services simultaneously with concurrently
- π Environment Variables: Dotenv for configuration management
- βοΈ Multi-Environment: Support for development, staging, and production
- π Timezone Support: Configurable timezone settings
- Bun (latest version)
- PostgreSQL (v14 or higher)
- Redis (v6 or higher)
- Docker (optional, for containerization)
- Make (optional, for using Makefile commands)
-
Clone the repository
git clone https://github.com/aolus-software/clean-hono.git cd clean-hono -
Install dependencies
bun install
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Start development server
bun dev
# Install dependencies
bun install
# Start development server
bun dev
# Build for production
bun run build
# Start production server
bun start# View all available commands
make help
# Development Commands
make dev-api # Start API development server with hot reload
make dev-server # Start SERVER development server with hot reload
make dev-worker # Start WORKER development with hot reload
make dev-all # Run server and worker in dev mode concurrently
# Build Commands
make build-api # Build the API application
make build-server # Build the SERVER application
make build-worker # Build the WORKER application
make build-all # Build server and worker concurrently
# Production Commands
make start-api # Start the API production server
make start-server # Start the SERVER production server
make start-worker # Start the WORKER production service
make start-all # Run server and worker in production concurrently
# Code Quality
make lint # Run ESLint
make format # Format code with Prettier
# Database Commands
make db-generate # Generate migration files
make db-migrate # Run pending migrations
make db-push # Push schema to database (dev only)
make db-pull # Pull schema from database
make db-studio # Open Drizzle Studio
make db-drop # Drop all tables (dangerous!)
make db-seed # Run database seeder
# Combined Workflows
make fresh # Drop database, push schema, and seed
make reset # Generate migrations, migrate, and seed# Build and run with Docker Compose
docker-compose up --build
# Run in detached mode
docker-compose up -dclean-hono/
βββ apps/ # Application modules
β βββ apis/ # API application (Hono-based)
β β βββ errors/ # Custom error definitions
β β βββ handlers/ # Request handlers
β β βββ middleware/ # API middleware
β β βββ repositories/ # Data access layer
β β βββ routes/ # API routes
β β βββ services/ # Business logic
β β βββ types/ # TypeScript type definitions
β βββ worker/ # Background job workers
βββ packages/ # Shared packages and utilities
β βββ cache/ # Caching utilities
β βββ config/ # Configuration management
β βββ db/ # Database connectors
β β βββ clickhouse/ # ClickHouse integration
β β βββ postgres/ # PostgreSQL integration
β βββ default/ # Default configurations
β βββ event/ # Event handling
β β βββ queue/ # Queue management
β β βββ worker/ # Worker utilities
β βββ guards/ # Authentication guards
β βββ logger/ # Logging utilities
β βββ mail/ # Email service
β β βββ templates/ # Email templates
β βββ redis/ # Redis integration
β βββ security/ # Security utilities
β βββ toolkit/ # Common tools and helpers
βββ infra/ # Infrastructure and deployment
β βββ migrations/ # Database migrations
β β βββ meta/ # Migration metadata
β βββ seed/ # Database seeding scripts
βββ storage/ # File storage
β βββ logs/ # Application logs
βββ docs/ # Documentation
β βββ images/ # Documentation images
βββ .github/ # GitHub workflows and templates
βββ .husky/ # Git hooks
βββ Dockerfile # Container configuration
βββ docker-compose.yml # Multi-service setup
βββ drizzle.config.ts # Database configuration
βββ Makefile # Build and deployment commands
βββ package.json # Project dependencies and scripts
This template uses Drizzle ORM for database operations:
-
Configure your database in
.env:DATABASE_URL="your-database-connection-string"
-
Generate database migrations:
bun run db:generate
-
Run migrations:
bun run db:migrate
- ESLint: Configured for TypeScript and modern JavaScript
- Prettier: Automatic code formatting
- Husky: Pre-commit hooks for code quality
# Server Commands
bun run dev:server # Start development server with hot reload
bun run start:server # Start production server
bun run build:server # Build server for production
# Worker Commands
bun run dev:worker # Start development worker with hot reload
bun run start:worker # Start production worker
bun run build:worker # Build worker for production
# API Commands (alias for server)
bun run dev:api # Start development API with hot reload
bun run start:api # Start production API
bun run build:api # Build API for production
# Run All Services
bun run dev:all # Start both server and worker in development mode
bun run start:all # Start both server and worker in production mode
bun run build:all # Build both server and worker
# Code Quality
bun run lint # Run ESLint
bun run format # Format code with Prettier
# Database
bun run seed # Seed database with initial data# Build image
docker build -t clean-hono .
# Run container
docker run -p 3000:3000 clean-hono# Start all services
docker-compose up
# Scale specific services
docker-compose up --scale app=3- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the existing code style
- Run
bun lintandbun formatbefore committing - Write meaningful commit messages
Add tests for new features
- Hono - The web framework
- Bun - JavaScript runtime and package manager
- Drizzle ORM - Type-safe database toolkit
If you have any questions or issues, please:
- Open an issue
- Start a discussion
Made with β€οΈ by Aolus Software