diff --git a/README.md b/README.md index 96adb6a..a6bbb47 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,48 @@ Track shared costs, calculate who owes whom, and manage group finances effortles Follows DDD principles for separting the application into generic, core, and supporting domains - enforced by [deptrac](https://github.com/deptrac/deptrac). +## Architecture diagram + +``` + Browser / Client + │ + ┌────────────────┼─────────────────┐ + │ :8000 │ :8080 │ :5173 (dev) + ▼ ▼ ▼ + ┌────────────┐ ┌──────────────┐ ┌───────────────┐ + │ dashboard │ │ web (Nginx) │ │ npm-dev │ + │ (Homer) │ │ │ │ (Vite/React/ │ + └────────────┘ └──────┬───────┘ │ TypeScript) │ + │ FastCGI └───────────────┘ + │ :9000 + ▼ + ┌──────────────────┐ async ┌──────────────┐ + │ app (PHP-FPM) │────messages────▶│ worker │ + │ Symfony │ │ (Messenger) │ + └──────────────────┘ └──────────────┘ + │ │ + └────────────────┬────────────────┘ + │ SQL + ▼ + ┌─────────────────┐ + │ db (MySQL) │ + └─────────────────┘ + + ───────────────────────── Backend Layers ───────────────────────── + + ┌─────────────────────────────────────────────────────────────────┐ + │ Supporting │ Controllers · Auth · Repositories · Async │ + │ │ Normalizers · Instrumentation · EventListeners │ + ├──────────────┴──────────────────────────────────────────────────┤ + │ Core │ ExpenseTracker · Calculator │ + │ (Domain) │ Event Sourcing · Expenses · Compensation │ + ├──────────────┴──────────────────────────────────────────────────┤ + │ Generic │ Symfony · Doctrine · Twig · DomPDF · Monolog | + | │ PhpParser · phpDocumenter · OpenAPI | + └─────────────────────────────────────────────────────────────────┘ + Supporting depends on Core & Generic · Core has no deps +``` + ## Prerequisites - [Make](https://www.gnu.org/software/make/) diff --git a/backend/deptrac.yaml b/backend/deptrac.yaml index c25cc5f..c3cac72 100644 --- a/backend/deptrac.yaml +++ b/backend/deptrac.yaml @@ -31,8 +31,6 @@ deptrac: value: .*Monolog\\.* - type: classLike value: .*OpenApi\\Attributes\\.* - - type: classLike - value: .*OpenTelemetry\\.* - type: classLike value: .*phpDocumentor\\Reflection\\.* - type: classLike diff --git a/backend/src/Controller/API/CalculateExpensesController.php b/backend/src/Controller/API/CalculateExpensesController.php index 5247c46..4d2d77a 100644 --- a/backend/src/Controller/API/CalculateExpensesController.php +++ b/backend/src/Controller/API/CalculateExpensesController.php @@ -27,7 +27,7 @@ public function calculate(): JsonResponse $expenses = $this->calculator->calculate(); - Ensure::that(2 === count($expenses)); + Ensure::that(2 === count($expenses), 'Track your expenses first!'); $compensation = Compensation::calculate($expenses[0], $expenses[1]); diff --git a/frontend/src/features/calculation/api.ts b/frontend/src/features/calculation/api.ts index 503424d..6aaf0ab 100644 --- a/frontend/src/features/calculation/api.ts +++ b/frontend/src/features/calculation/api.ts @@ -30,7 +30,8 @@ export async function fetchCalculation(): Promise { }) if (!response.ok) { - throw new Error('Failed to fetch calculation') + const error = await response.json() + throw new Error(error.detail || 'Failed to fetch calculation') } return response.json()