Skip to content

Frontend Architecture

This document describes the frontend architecture for Hatchgrid, combining Screaming Architecture with Hexagonal principles, adapted to a Vue + Astro setup with vue-shadcn components.

We use a feature-first structure: every top-level folder under src/ represents a business domain or feature (e.g., subscribers/, publications/). Inside each feature, we apply Hexagonal layering (domain, application, infrastructure), without explicitly naming β€œports” or β€œadapters”.

src/
β”œβ”€β”€ subscribers/
β”‚ β”œβ”€β”€ domain/ # Business types, exceptions
β”‚ β”œβ”€β”€ application/ # Use cases (pure logic)
β”‚ └── infrastructure/ # APIs, stores, routing
β”œβ”€β”€ publications/
β”‚ └── ...
β”œβ”€β”€ components/
β”‚ └── ui/ # Common UI components from vue-shadcn
β”œβ”€β”€ layouts/ # Layout templates (DefaultLayout.vue, etc.)
β”œβ”€β”€ router/ # App-level router config
β”œβ”€β”€ App.vue
└── main.ts
  • Feature isolation: Each domain (e.g., subscribers) is self-contained and testable.
  • Hexagonal layering: Domain logic is decoupled from framework or UI concerns.
  • No explicit ports/adapters: File names and locations imply intent.
  • UI truth lives in components/ui/: All base components come from vue-shadcn.
subscribers/
β”œβ”€β”€ __tests__/
β”œβ”€β”€ application/
β”‚ β”œβ”€β”€ composables/
β”‚ └── index.ts
β”œβ”€β”€ domain/
β”‚ β”œβ”€β”€ models/
β”‚ β”œβ”€β”€ repositories/
β”‚ └── usecases/
β”œβ”€β”€ infrastructure/
β”‚ β”œβ”€β”€ api/
β”‚ β”œβ”€β”€ di/
β”‚ β”œβ”€β”€ routing/
β”‚ β”œβ”€β”€ store/
β”‚ └── views/
β”œβ”€β”€ di.ts
└── index.ts
graph TD
  UI["UI Components
(Vue/Astro)"] USE_CASE["Application
(Use Cases)"] DOMAIN["Domain
(Types, Rules)"] API["API Layer"] STORE["State Store"] EXTERNAL["External APIs"] UI --> USE_CASE USE_CASE --> DOMAIN USE_CASE --> API USE_CASE --> STORE API -.-> EXTERNAL
  • domain/ and application/: Pure unit tests, no mocks or DOM needed.
  • infrastructure/: Integration tests for API calls and state handling.
  • ui/ and pages: Component tests with Testing Library.