Skip to content

SyahrulBhudiF/Hono-Starter-Code

Repository files navigation

🚀 Hono RestAPI Starter Kit

A modern, production-ready API starter kit built with cutting-edge technologies for rapid development and scalable performance.

✨ Features

  • 🔥 Hono - Ultra-fast web framework for the edge
  • 🔐 Authentication & Authorization
    • JWT token-based authentication
    • OAuth2 integration (Google)
    • Email OTP verification
  • 📊 Database Integration
    • Drizzle ORM - Type-safe SQL query builder
    • PostgreSQL - Reliable, open-source relational database
  • 🗄️ Caching
    • Redis for high-performance caching and session management
  • 🐳 DevOps Ready
    • Docker & Docker Compose for containerization
  • 📝 API Documentation
    • Auto-generated OpenAPI documentation
    • Interactive SwaggerUI interface

🛠️ Tech Stack

Category Technologies
Framework Hono
Authentication JWT, OAuth2, Email OTP
Database PostgreSQL, Drizzle ORM
Caching Redis
Containerization Docker
Package Manager Bun
Documentation OpenAPI, SwaggerUI

🚀 Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/SyahrulBhudiF/Hono-Starter-Code
    cd Hono-Starter-Code
  2. Install dependencies

    bun install
  3. Set up environment variables

    cp .env.example .env
    # Edit .env with your configuration

🏃‍♂️ Running the Application

Development Mode

Start the application and all required services (PostgreSQL, Redis) using Docker:

docker compose build
docker compose up

This will launch the development environment with hot reloading enabled.

Production Mode

For production deployment, use the same Docker Compose setup with minor configuration adjustments at Dockerfile and docker-compose.yml.

# Run in production mode
docker compose build --no-cache
docker compose up

📖 API Documentation

Once the application is running, you can access the API documentation at:

📁 Project Structure

📦 ROOT
├── 📂 drizzle/             # 🔄 Drizzle ORM migration
├── 📂 src/
│   ├── 📂 config/          # ⚙️ Configuration files
│   ├── 📂 controllers/     # 🎮 Request handlers
│   ├── 📂 middleware/      # 🔌 Custom middleware
│   ├── 📂 models/          # 📊 Database models
│   ├── 📂 routes/          # 🛣️ API routes and Swagger documentation
│   ├── 📂 services/        # 🧩 Business logic
│   ├── 📂 types/           # 📝 Type definitions and Repository abstraction
│   ├── 📂 utils/           # 🔧 Utility functions
│   ├── 📂 validation/      # ✅ Request validation schemas
│   ├── 📄 index.ts         # 🚀 App entry point
│   └── 📄 worker.ts        # 👷 Worker entry point
├── 📄 .env.example         # 🔐 Environment variables example
├── 📄 compose.yml          # 🐳 Docker Compose configuration
├── 📄 Dockerfile           # 📦 Docker configuration
├── 📄 drizzle.config.ts    # 🗃️ Drizzle ORM configuration
└── 📄 package.json         # 📋 Dependencies and scripts

🤝 Contributing

Contributions, issues, and feature requests are welcome! See CONTRIBUTING.md for more information.