How tingtt/hackbar-copilot works
Main Components
a. Frontend Client:
• Located in the “client” folder.
• Contains UI components (Provider.tsx, index.ts, etc.), tooling for code generation (interface.gen, query.gen, etc.) and configuration files.
• Communicates to the backend via GraphQL queries and mutations.
b. API Server / Backend:
• Startup entry points in “cmd/registry” (and a secondary “cmd/tui” for alternative interfaces).
• Responsible for exposing the GraphQL playground (http://localhost:8080/playground) and handling API calls.
c. GraphQL Layer:
• Found under “internal/interface-adapter/handler/graphql”.
• Contains the GraphQL schema, resolvers, adapters (for example, authentication, menu, order, recipe, stock, user) that directly bind client requests to internal business logic.
d. Application & Usecase Layer:
• Implemented in “internal/usecase” and “internal/usecase/copilot” and others.
• Contains business logic routines such as processing orders, managing recipes, and handling cashout and checkout.
e. Domain Layer:
• Under “internal/domain”, this layer defines the core business entities and types for several domains (recipe, order, menu, stock, etc.).
• Includes validations, transformations, and domain-specific logic.
f. Infrastructure Layer:
• Found in “internal/infrastructure”, where the actual data persistence is handled.
• Provides implementations (e.g., using a filesystem-based datasource with TOML encoding) that the domain and usecase layers utilize.
g. External Integrations and Tools:
• Dockerfile, .dockerignore, CI configurations (.github/workflows), and additional tooling in the “client/tools” folder suggest containerized deployment and automated processes.
• The README quickly shows how to start the registry server and access the playground.
Relationships and Interactions
• The frontend client makes GraphQL queries and mutations to the API server.
• The API server (with its GraphQL handler) routes requests to the corresponding usecase functions.
• The usecase layer interacts with the domain layer where business rules and validations are applied.
• For data persistence or external data interactions, the usecase layer calls into the infrastructure layer, which implements filesystem or TOML-based storage.
Architectural Patterns and Design Principles
• Clean Architecture / Hexagonal Architecture: Separate concerns via layers (interface adapters, usecase, domain, and infrastructure).
• GraphQL as a communication/interaction pattern between client and backend.
• Dependency inversion where high-level modules (domain, usecase) do not depend on infrastructure specifics, which are plugged in via adapters.
• Additionally, note the tooling for code generation in the client, ensuring the client can properly and consistently interface with the backend API.
Technologies, Frameworks, and Libraries
• Go is the primary language for the backend – using modules (go.mod, go.sum) and a directory structure that hints at industry best practices.
• GraphQL is used for the API, evidenced by the GraphQL schema and resolver files.
• For the client, modern JavaScript/TypeScript tooling is evident (Prettier, ESLint, TSConfig) which might align with popular frontend frameworks.
• Docker and CI/CD configurations indicate containerized deployment and automated builds/releases.