How dukanx/hearth works
1. Repository shape
- This is a full-stack monorepo with two major deployable parts: Hearth.Api on the backend and hearth-web on the frontend.
- The backend is a .NET 10 ASP.NET Core service; the frontend is a React 19 + TypeScript PWA built with Vite.
2. Top-level architecture style
- The backend follows Clean Architecture with CQRS and vertical feature slices.
- Dependency direction is inward: Api → Infrastructure → Application → Domain.
- The Application layer owns use cases and abstractions; Infrastructure provides persistence, identity, and push implementations; Api is a thin transport layer.
3. Domain layer
- Hearth.Domain contains the core business model only: entities such as Household, HouseholdTask, ShoppingItem, Notification, and PushSubscription.
- It also defines business enums like task status, shopping status, and task priority.
- This layer has no framework dependencies, which keeps business rules isolated from persistence and transport concerns.
4. Application layer as the use-case boundary
- Hearth.Application is organized by feature folders such as Auth, Households, Tasks, Shopping, Notifications, and Push.
- Each feature typically has a command/query, handler, and validator, using MediatR and FluentValidation.
- This layer defines the repository, identity, token, push, realtime, and current-user interfaces that the outer layers must implement.
5. Backend request flow
- HTTP requests enter Hearth.Api through controllers like AuthController, TasksController, ShoppingController, and others.
- Controllers do not contain business logic; they forward work to MediatR handlers through ISender.
- Results are converted into HTTP responses via shared result extensions and exception handling.
6. Persistence and identity
- Hearth.Infrastructure contains EF Core AppDbContext, repository implementations, migrations, and unit-of-work support.
- ASP.NET Identity is used for user accounts, roles, and authentication, with JWT generation handled by TokenService.
- Database state is PostgreSQL-backed via Npgsql, and migrations are part of the repository, so schema changes are first-class in the architecture.
7. Household-centric access model
- The app is centered around a household boundary: users belong to one household and collaborate inside it.
- Join codes are generated and stored through infrastructure services, with separate adult/child codes reflected in the domain and application logic.
- Role-based behavior is enforced at the use-case level, especially where children have limited permissions.
8. Tasks and shopping as collaborative workflows
- Tasks and shopping items are separate bounded areas but share the same household scope and notification patterns.
- Task use cases cover CRUD, assignment, and status transitions; shopping use cases cover item lifecycle, quantity, and bought/needed state.
- The application layer maps domain entities to DTOs for API consumption, keeping the frontend insulated from persistence shapes.
9. Notifications and realtime
- Notifications are generated by application event handlers for important domain actions such as task creation, task assignment, item addition, and item purchase.
- The system has two delivery channels: SignalR for live in-app updates and Web Push for background/system notifications.
- NotificationHub, RealtimeNotifier, and related services create a realtime boundary between backend events and connected clients.
10. Frontend architecture
- hearth-web is a React SPA/PWA with feature-oriented folders mirroring backend domains: auth, household, shopping, tasks, notifications, and lobby.
- Data access is split into a small API client layer and feature-specific API wrappers.
- State is mostly client-side and server-synced via TanStack Query, with route guards and auth context controlling access.
11. Frontend realtime and PWA behavior
- The frontend subscribes to SignalR notifications through a dedicated hook, and also manages push subscription lifecycle through a separate hook.
- A service worker in public/push-sw.js supports installed-app behavior and background push delivery.
- This makes the frontend architecturally more than a standard SPA: it is designed for persistent mobile-style engagement and offline shell support.
12. Cross-cutting concerns
- Authentication is JWT-based end to end; the API issues tokens, the frontend stores them, and requests are authenticated through the client layer.
- Validation is standardized in the application layer, while API-level exception handling translates failures into consistent responses.
- Shared DTOs and result types keep the contract between layers explicit and reduce coupling.
13. Deployment model
- The root Dockerfile builds the frontend and publishes the backend into a single container, so the app is deployed as one host.
- In production, the backend also serves the built frontend, which avoids CORS complexity and keeps SignalR same-origin.
- Railway is the intended deployment target, with PostgreSQL as the external state store and optional VAPID configuration for push notifications.
14. What an architecture diagram should emphasize
- Draw one backend host with three internal concentric layers: API transport, application use cases, and domain core, with infrastructure attached as the persistence/identity/push adapter layer.
- Show PostgreSQL, JWT/Identity, SignalR, and Web Push as external dependencies of the backend.
- Show the React PWA as a separate client that talks to the API, opens a SignalR connection, and registers for web push notifications.
Main entry points: Hearth.Infrastructure Infrastructure · hearth-web hearth-web · Hearth.Api Hearth.Api · Hearth.Application Application
Components 23
Backend host
ASP.NET Core API, application use cases, domain core, and infrastructure adapters.
- Hearth.Api · HTTP controllers, hubs, result mapping, and request entrypoint for the backend host.
Hearth.Api - Controllers · Auth, households, tasks, shopping, notifications, and push endpoints that forward to MediatR.
Hearth.Api/Controllers - SignalR Hub · Notification hub, connection tracking, and notifier bridge for live client updates.
Hearth.Api/Hubs - Application · CQRS features, validation, DTO mapping, and application-facing abstractions.
Hearth.Application - Feature slices · Auth, households, tasks, shopping, notifications, and push commands and queries.
Hearth.Application/Features - Ports · Repository, identity, token, join code, push, realtime, and current-user interfaces.
Hearth.Application/Common/Interfaces - Notifications · Domain-action events and handlers that fan out to realtime and push delivery.
Hearth.Application/Common/Notifications - Domain · Entities and enums for households, tasks, shopping, notifications, and subscriptions.
Hearth.Domain - Infrastructure · EF Core, repositories, identity, JWT, join codes, and web push implementations.
Hearth.Infrastructure - AppDbContext · Database model and unit-of-work boundary for PostgreSQL persistence.
Hearth.Infrastructure/Persistence/AppDbContext.cs - Repositories · Concrete household, task, shopping, notification, and push subscription stores.
Hearth.Infrastructure/Persistence/Repositories - Identity · ASP.NET Identity user management and JWT token issuance.
Hearth.Infrastructure/Identity - Push service · VAPID-backed push subscription management and notification delivery.
Hearth.Infrastructure/Services/WebPushNotifier.cs
Frontend PWA
React client with feature modules, API access, realtime hooks, and push support.
- hearth-web · Feature-oriented SPA/PWA client with auth, household, shopping, tasks, and notifications flows.
hearth-web - API client · Shared client and feature wrappers for authenticated server requests.
hearth-web/src/api - Auth state · JWT storage, auth context, and route guards for access control.
hearth-web/src/auth - Feature UI · Task, shopping, lobby, household, and notification screens and feature hooks.
hearth-web/src/features - Realtime hooks · Client subscription to notification hub updates and push subscription lifecycle.
hearth-web/src/features/notifications - Service worker · Background push and installed-app support for the web client.
hearth-web/public/push-sw.js
External systems
Runtime dependencies outside the repo boundary.
- PostgreSQL · Primary state store for application data and identity-backed records.
- SignalR · Live websocket-style transport used for in-app notification delivery.
- JWT auth · Bearer token authentication used between client and API.
- Web Push · Background notification delivery through push subscriptions and VAPID.
Connections 28
- hearth-web → API client: uses · The PWA sends all backend requests through shared HTTP client wrappers.
- hearth-web → Auth state: controls access · Auth context, storage, and route guards manage logged-in state.
- hearth-web → Feature UI: renders · Pages and feature widgets make up the main user experience.
- hearth-web → Realtime hooks: subscribes · The client listens for live notification updates and manages push registration.
- hearth-web → Service worker: registers · The installed app uses a service worker for background push support.
- API client → Hearth.Api: HTTP · Authenticated requests target the backend transport layer.
- Hearth.Api → Controllers: routes · Controllers are the public HTTP entrypoints.
- Hearth.Api → SignalR Hub: hosts · The API host exposes the notification hub and realtime boundary.
- Controllers → Application: delegates · Controllers forward work to MediatR instead of containing business logic.
- SignalR Hub → SignalR: connects to · Clients attach through SignalR for live updates.
- Application → Feature slices: organizes · Use cases are implemented as feature-based CQRS handlers.
- Application → Ports: depends on · Application code targets abstractions implemented by outer layers.
- Feature slices → Domain: uses · Commands and queries operate on the core entities and enums.
- Notifications → Ports: publishes via · Notification handlers dispatch through realtime and push ports.
- Notifications → SignalR Hub: broadcasts · Realtime notifications are sent to connected clients.
- Domain → Notifications: raises events · Task and shopping actions trigger notification events.
- Infrastructure → AppDbContext: contains · EF Core persistence is centered on the application DbContext.
- Infrastructure → Repositories: implements · Repository adapters fulfill the application persistence ports.
- Infrastructure → Identity: implements · Identity and token services support authentication and authorization.
- Infrastructure → Push service: implements · Push subscriptions and outbound web push delivery are provided here.
- Infrastructure → Ports: satisfies · Outer-layer services implement the application abstractions.
- Repositories → PostgreSQL: persists to · Entity state is stored in PostgreSQL.
- AppDbContext → PostgreSQL: maps to · The EF Core model is backed by PostgreSQL.
- Identity → JWT auth: issues · JWT tokens are generated for authenticated API access.
- Push service → Web Push: delivers via · Background notifications use browser push infrastructure.
- Auth state → JWT auth: stores · The client persists bearer tokens for subsequent requests.
- Realtime hooks → SignalR: listens on · The frontend opens a SignalR connection for live events.
- Realtime hooks → Web Push: subscribes · The client manages push subscription lifecycle with the browser push channel.