Frontend Architecture
ποΈ Frontend Architecture
Section titled βποΈ 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.
π Overview
Section titled βπ Overviewβ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π§ Architectural Principles
Section titled βπ§ Architectural Principlesβ- 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 fromvue-shadcn.
π― Feature Module Structure Example
Section titled βπ― Feature Module Structure Exampleβsubscribers/βββ __tests__/βββ application/β βββ composables/β βββ index.tsβββ domain/β βββ models/β βββ repositories/β βββ usecases/βββ infrastructure/β βββ api/β βββ di/β βββ routing/β βββ store/β βββ views/βββ di.tsβββ index.tsπ§© How It Works
Section titled βπ§© How It Worksβ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
π§ͺ Testing Strategy
Section titled βπ§ͺ Testing Strategyβ- 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.