# gakuto06250177/hackbar-copilot architecture

> Architecture diagram of the GitHub repository gakuto06250177/hackbar-copilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gakuto06250177/hackbar-copilot
- Repository: https://github.com/gakuto06250177/hackbar-copilot

## Overview

##### Project type and purpose
- This is primarily a GraphQL-based backend service implemented in Go using a hexagonal (ports-and-adapters) architecture. It exposes a GraphQL HTTP API (via gqlgen), persists data to the filesystem (TOML), and offers both a CLI (cmd/tui) and a TypeScript client package (client/) with generated query/mutation code.

##### File structure
- Top-level:
- cmd/registry – the main HTTP GraphQL server
- cmd/tui – an interactive CLI client
- client/ – TypeScript GraphQL client code (+ codegen tools)
- internal/domain – core domain entities and business rules
- internal/usecase – application services/use-case implementations
- internal/interface-adapter – GraphQL resolvers, JWT middleware
- internal/infrastructure/datasource – filesystem repositories
- internal/infrastructure/api/http – HTTP server setup
- Patterns:
- Hexagonal layering (domain/usecase/adapters/infrastructure)
- Repository pattern for persistence
- Code generation for GraphQL and client interfaces

##### README for additional insights
- Running `cmd/registry` serves `/playground` for GraphQL queries/mutations
- Sample queries/mutations show recipe/menu/order/cash‐out workflows

##### Elements
- Clear labels: e.g., “GraphQL Client”, “gqlgen Resolvers”, “Use-Case: saveRecipe”, “Domain: Recipe”, “Filesystem Repository”
- Client → Server (HTTP request)
- Resolvers → Use-cases → Domain → Repositories → Filesystem
- CLI → Use-cases or Server
- Application layer (use-cases) in another

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    TSClient["GraphQL Client (Playground/TS)"]:::client
    CLIClient["CLI Client (TUI)"]:::client

    %% Server Components
    GraphQLServer["HTTP GraphQL Server"]:::infra
    HTTPServerInfra["HTTP Server Setup"]:::infra

    %% Interface Adapters
    Resolvers["gqlgen Resolvers"]:::adapter
    AdapterFuncs["GraphQL Adapter Functions"]:::adapter
    JWTMiddleware["JWT Middleware"]:::adapter

    %% Application Layer
    UseCase["Use-Case Layer"]:::application

    %% Domain Layer
    Domain["Domain Layer"]:::domain

    %% Infrastructure Datastore
    FSRepo["Filesystem Repositories & TOML Gateway"]:::datastore

    %% Data Flow
    TSClient -->|"GraphQL over HTTP/JSON"| GraphQLServer
    GraphQLServer -->|configures| HTTPServerInfra
    HTTPServerInfra -->|routes requests| Resolvers
    Resolvers -->|invoke| AdapterFuncs
    Resolvers -->|apply auth| JWTMiddleware
    AdapterFuncs -->|call| UseCase
    JWTMiddleware -->|authorize| AdapterFuncs
    UseCase -->|business logic| Domain
    Domain -->|persist/read| FSRepo
    CLIClient -->|CLI commands| UseCase

    %% Click Events
    click TSClient "https://github.com/gakuto06250177/hackbar-copilot/tree/main/client/"
    click GraphQLServer "https://github.com/gakuto06250177/hackbar-copilot/blob/main/cmd/registry/main.go"
    click CLIClient "https://github.com/gakuto06250177/hackbar-copilot/blob/main/cmd/tui/main.go"
    click Resolvers "https://github.com/gakuto06250177/hackbar-copilot/tree/main/internal/interface-adapter/handler/graphql/graph/"
    click AdapterFuncs "https://github.com/gakuto06250177/hackbar-copilot/tree/main/internal/interface-adapter/handler/graphql/adapter/"
    click JWTMiddleware "https://github.com/gakuto06250177/hackbar-copilot/blob/main/internal/interface-adapter/handler/middleware/jwt.go"
    click UseCase "https://github.com/gakuto06250177/hackbar-copilot/tree/main/internal/usecase/"
    click Domain "https://github.com/gakuto06250177/hackbar-copilot/tree/main/internal/domain/"
    click HTTPServerInfra "https://github.com/gakuto06250177/hackbar-copilot/blob/main/internal/infrastructure/api/http/server.go"
    click FSRepo "https://github.com/gakuto06250177/hackbar-copilot/tree/main/internal/infrastructure/datasource/filesystem/"

    %% Styles
    classDef client fill:#D6EAF8,stroke:#2980B9
    classDef infra fill:#EBDEF0,stroke:#9B59B6
    classDef adapter fill:#FADBD8,stroke:#E74C3C
    classDef application fill:#D5F5E3,stroke:#27AE60
    classDef domain fill:#FCF3CF,stroke:#F1C40F
    classDef datastore fill:#FDEBD0,stroke:#BA4A00
```
