# nagarehazh/skeleton-ddd-bun-hono-typescript architecture

> Architecture diagram of the GitHub repository nagarehazh/skeleton-ddd-bun-hono-typescript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nagarehazh/skeleton-ddd-bun-hono-typescript
- Repository: https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript

## Overview

##### Project type and purpose
- This is a backend API service written in TypeScript (running on Bun) that exposes at least a health-check endpoint (`HealthCheckController`).
- It follows a domain-driven, layered architecture (layers: infrastructure, application, domain).

##### File structure
- Top-level files:
- `bun.lockb`, `package.json`, `tsconfig.json`, CI config, `.gitignore`
- `migrations/` for database schema management
- `src/` splits into three layers:
- `infrastructure/`: HTTP controllers, routes, DI container, database config
- `application/`: orchestration of use cases
- `domain/`: core business entities and logic
- `src/utils`: environment variable loader

##### README for additional insights
- Run with `bun run dev` on port 3000
- No front-end; this is a pure backend service

##### Relationships and interactions
- Client → HTTP Server/Router
- Router → Controller
- Controller → Application service
- Application service → Domain (calls domain methods)
- Application service → Infrastructure (via injected repository or DB config)
- Infrastructure → Database

##### Architectural patterns and design principles
- Layered architecture (Presentation → Application → Domain → Infrastructure)
- Dependency Injection (via Inversify): Controllers and services receive dependencies by interface types
- Separation of concerns: migrations separate from runtime DB config; env vars in `utils`

##### Relevant technologies and frameworks
- Bun (runtime & package manager)
- TypeScript
- Inversify for DI
- Some ORM or query builder implied by `migrations/db.ts`
- Node-style HTTP server (imported in `src/index.ts`)

- Clear labels on all components (e.g., “HealthCheckController”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Client"]:::external

    %% Infrastructure: Env Loader loaded at startup
    EnvLoader["Environment Variable Loader"]:::infrastructure

    %% Presentation Layer
    subgraph "Presentation Layer"
        HTTPServer["HTTP Server / Entry Point"]:::presentation
        Router["Router Configuration"]:::presentation
        StatusRoute["Health-Check Route"]:::presentation
        BaseController["Base Controller Interface"]:::presentation
        HealthController["HealthCheckController"]:::presentation
    end

    %% Application & Domain Layer
    subgraph "Application & Domain Layer"
        AppLayer["Application Layer"]:::application
        DomainLayer["Domain Layer"]:::application
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DIContainer["DI Container"]:::infrastructure
        DITypes["DI Types Definitions"]:::infrastructure
        DBConfig["Database Configuration"]:::infrastructure
        Migrations["Database Migrations"]:::infrastructure
        Database["Database"]:::infrastructure
    end

    %% Data Flow and Dependencies
    Client -->|"HTTP GET /status"| HTTPServer
    HTTPServer -->|"initialize deps"| EnvLoader
    HTTPServer -->|"load routes"| Router
    Router -->|"register GET /status"| StatusRoute
    StatusRoute -->|"implements routing"| HealthController
    HealthController -->|"call executeHealthCheck()"| AppLayer
    AppLayer -->|"use domain logic"| DomainLayer
    AppLayer -->|"use DB connection"| DBConfig
    DBConfig -->|"SQL connection"| Database
    DIContainer -->|"injects into controllers & services"| HTTPServer
    DIContainer -->|"injects DBConfig"| AppLayer
    Migrations -->|"run migrations"| Database

    %% Click Events
    click HTTPServer "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/index.ts"
    click Router "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/routes/index.ts"
    click StatusRoute "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/routes/Status.route.ts"
    click BaseController "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/controllers/Controller.ts"
    click HealthController "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/controllers/HealthCheckController.ts"
    click AppLayer "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/application/index.ts"
    click DomainLayer "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/domain/index.ts"
    click DIContainer "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/configs/dependency-injection/inversify.ts"
    click DITypes "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/configs/dependency-injection/types.inversify.ts"
    click DBConfig "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/infrastructure/configs/database/db.ts"
    click Migrations "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/migrations/index.ts"
    click EnvLoader "https://github.com/nagarehazh/skeleton-ddd-bun-hono-typescript/blob/master/src/utils/enviroments.ts"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef application fill:#90EE90,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
