Skip to content

This is a simple project to demonstrate the Clean Architecture using the Hono and Bun as an example.

Notifications You must be signed in to change notification settings

kbkn3/hono-bun-cleanArchitecture

Repository files navigation

Hono Bun Clean Architecture

ζ—₯本θͺžη‰ˆ README | πŸ“Š Performance Analysis

Description

A Clean Architecture implementation using Hono framework with support for both Bun and Node.js runtimes. This project demonstrates modern TypeScript development with Docker deployment and comprehensive performance testing.

Demo

Features

  • πŸ—οΈ Clean Architecture - Separation of concerns with clear dependency boundaries
  • πŸš€ Dual Runtime Support - Works with both Bun and Node.js
  • 🐳 Docker Ready - Production-ready containerization
  • πŸ“Š Performance Testing - Comprehensive K6 load testing suite
  • πŸ”§ TypeScript - Full type safety with modern TS features
  • ✨ Hot Reload - Fast development experience

Tech Stack

  • Package Manager: Bun
  • HTTP Server: Hono
  • Test Framework: Bun
  • Linter/Formatter: Biome
  • Containerization: Docker & Docker Compose
  • Performance Testing: K6

Quick Start

Prerequisites

  • Bun (recommended) or Node.js 20+
  • Docker (optional, for containerized deployment)

Setup

# Clone the repository
git clone <repository-url>
cd hono-bun-cleanArchitecture

# Install dependencies
bun install

# Start development server
bun dev

The application will be available at http://localhost:3000.

Development

Available Scripts

# Development
bun dev                 # Start with Bun (recommended)
npm run dev:node        # Start with Node.js

# Production
bun run deploy          # Deploy to Cloudflare Workers
npm run start:node      # Run Node.js production server

# Testing
bun test                # Run tests
bun test:watch          # Run tests in watch mode
bun test:coverage       # Run tests with coverage

# Code Quality
bun run lint            # Run linter
bun run format          # Format code
bun run typecheck       # Type checking

Docker Deployment

Node.js (Recommended for Production)

npm run docker:build    # Build production image
npm run docker:run      # Run container

Bun

npm run docker:build:bun # Build Bun image
npm run docker:run:bun   # Run Bun container

Docker Compose

npm run docker:compose   # Run with docker-compose

Performance Testing

This project includes comprehensive performance testing with K6.

Quick Performance Test

# Install K6
brew install k6  # macOS

# Run performance comparison
./compare-performance.sh

Performance Summary

Based on extensive testing (local, Docker, and statistical analysis):

Environment Best Runtime Key Advantage
Local Development Bun 4.3% faster, better developer experience
Docker Production Node.js More consistent, reliable performance
Overall Recommendation Context-dependent See full analysis

πŸ“Š Complete Performance Analysis - Detailed comparison with statistical significance testing.

πŸ§ͺ K6 Testing Guide - Comprehensive testing documentation.

Architecture

This project follows Clean Architecture principles:

  • Domain Layer (src/domain/) - Pure business logic
  • Application Layer (src/application/) - Use cases and interfaces
  • Adapters Layer (src/adapters/) - External integrations
  • Infrastructure Layer - Framework-specific code

Key patterns:

  • Dependency Injection (InversifyJS)
  • Repository Pattern
  • Value Objects
  • Domain Error Handling

Documentation

License

This project is for demonstration purposes.

About

This is a simple project to demonstrate the Clean Architecture using the Hono and Bun as an example.

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •