A clean architecture backend API built with Hono, TypeScript, Bun, and Prisma ORM.
- Clean architecture pattern with separation of concerns
- Hono web framework with Zod OpenAPI integration
- PostgreSQL with Prisma ORM
- Redis for caching and rate limiting
- BullMQ for background job processing
- ClickHouse for analytics (optional)
- Comprehensive authentication and authorization (RBAC)
- API documentation with Scalar
- Docker support
- Runtime: Bun
- Framework: Hono
- Language: TypeScript
- Databases: PostgreSQL, Redis, ClickHouse
- ORM: Prisma
- Queue: BullMQ
- Validation: Zod
- API Docs: Zod OpenAPI + Scalar
- Bun 1.x or higher
- PostgreSQL
- Redis
- Docker (optional)
Install dependencies:
bun installCopy the example environment file and configure your environment variables:
cp .env.example .envConfigure the following environment variables:
- Database connections (PostgreSQL, Redis, ClickHouse)
- Mail settings
- JWT secrets
- Application settings
Generate the Prisma client:
bun run db:generateRun PostgreSQL migrations:
bun run db:migrateSeed the database with initial data:
bun run db:seedFor development, push schema directly without creating a migration:
bun run db:pushOpen Prisma Studio to view and edit data:
bun run db:studioRun ClickHouse migrations:
bun run db:clickhouse:migrateCheck ClickHouse migration status:
bun run db:clickhouse:statusRun the API server in development mode with hot reload:
bun run devThe API will be available at http://localhost:8001
Build the application:
bun run buildStart the production server:
bun run startBuild and run with Docker Compose:
docker-compose up -dsrc/
├── app.ts # Application setup
├── bootstrap.ts # DI container registrations
├── index.ts # Entry point
├── bull/ # Background jobs
│ ├── queue/ # Job queues
│ └── worker/ # Job workers
├── libs/ # Shared libraries
│ ├── cache/ # Cache utilities
│ ├── config/ # Configuration
│ ├── database/ # Database clients and repositories
│ │ ├── clickhouse/ # ClickHouse client and repositories
│ │ ├── postgres/ # Prisma client and repositories
│ │ └── redis/ # Redis client
│ ├── hono/ # Hono framework utilities
│ ├── mail/ # Email service
│ ├── types/ # TypeScript types
│ └── utils/ # Utility functions
└── modules/ # Feature modules
├── auth/ # Authentication
├── home/ # Health check
├── profile/ # User profile
└── settings/ # Application settings
├── permissions/ # Permission management
├── roles/ # Role management
├── select-options/ # Dropdown options
└── users/ # User management
Run linting:
bun run lintFix linting issues:
bun run lint:fixFormat code:
bun run formatType check:
bun run typecheckOnce the server is running, access the API documentation at:
http://localhost:8001/docs
bun run dev- Run API server with hot reload
bun run build- Build the applicationbun run start- Start in production mode
bun run lint- Run ESLintbun run lint:fix- Fix ESLint issuesbun run format- Format code with Prettier
bun run db:generate- Generate Prisma clientbun run db:migrate- Create and apply migrationsbun run db:push- Push schema to database (development only)bun run db:pull- Introspect database into schemabun run db:studio- Open Prisma Studiobun run db:reset- Reset database (dangerous!)bun run db:seed- Seed database with initial data
bun run db:clickhouse:migrate- Run ClickHouse migrationsbun run db:clickhouse:status- Check migration status
You can also use make commands:
make help- Show all available commandsmake dev- Start development servermake fresh- Reset, push schema, and seed (development)make reset- Migrate and seed
See TODO.md for a comprehensive list of planned improvements and enhancements.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.