# ercanpasha/pathwise architecture

> Architecture diagram of the GitHub repository ercanpasha/pathwise, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ercanpasha/pathwise
- Repository: https://github.com/ercanpasha/pathwise

## Overview

1. **Repository shape**
   - PathWise is a monorepo with a .NET backend and a React/TypeScript frontend.
   - The backend is split into cleanly separated projects: API, Application, Domain, and Infrastructure.
   - The overall product is a travel-management system for Admin, Business Owner, and Standard User roles.

2. **Backend entry point and HTTP boundary**
   - `PathWise.API` is the outer web boundary built on ASP.NET Core.
   - `Program.cs` wires dependency injection, middleware, and configuration, while controllers expose the HTTP API.
   - `ExceptionHandlingMiddleware` centralizes API error translation so application exceptions become consistent HTTP responses.

3. **Backend use-case layer**
   - `PathWise.Application` holds the business workflows and orchestration logic.
   - Services such as `AuthService`, `VenueService`, `RecommendationService`-like logic via the engine, `UserAccountService`, `SavedPlanService`, `StarredVenueService`, `NotificationService`, `TagService`, and `PageService` represent the main use cases.
   - DTOs and validators live here, so requests are validated and shaped before reaching the domain/persistence layer.

4. **Core HTTP features**
   - Controllers are organized by business capability: authentication, venues, recommendations, saved plans, starred venues, tags, notifications, user accounts, and dashboard/page data.
   - This indicates the API is feature-oriented rather than purely CRUD-oriented.
   - `PageController` likely serves aggregated dashboard data, while `RecommendationController` exposes the trip-planning workflow.

5. **Recommendation subsystem**
   - The recommendation logic is a distinct application subsystem under `Application/Algorithm`.
   - `RecommendationEngine`, `CostCalculator`, and `TagMatcher` suggest a rule/score-based planner that combines budget constraints with tag matching.
   - Its outputs are trip-plan DTOs containing trip plans and plan venues, which likely flow back to the frontend as personalized itineraries.

6. **Domain model and business boundaries**
   - `PathWise.Domain` contains the core entities and enums with no web or persistence concerns.
   - Main entities include `User`, `Venue`, `Tag`, `TripPlan`, `TripPlanVenue`, `Notification`, `UserTag`, `VenueTag`, and `UserStarredVenue`.
   - Enums such as `UserRole`, `UserStatus`, `VenueStatus`, `VenueType`, and `NotificationType` define the key business state boundaries.

7. **Persistence and infrastructure**
   - `PathWise.Infrastructure` owns EF Core persistence, repositories, the unit of work, security helpers, and database seeding.
   - `AppDbContext`, entity configurations, and migrations define the relational schema.
   - Repositories such as `UserRepository`, `VenueRepository`, `TripPlanRepository`, and `StarredVenueRepository` isolate data access from application services.

8. **Authentication and security flow**
   - Auth uses JWT-based token generation (`JwtTokenGenerator`) and password hashing (`PasswordHasher`), with current-user resolution through `CurrentUserService`.
   - `JwtSettings` in application configuration and the auth DTOs show that login/register are first-class flows.
   - Role-based access is important because the UI and backend both distinguish admin/owner/user behavior.

9. **Validation, errors, and shared contracts**
   - Fluent validation-style request validators exist for auth, venue creation/update, profile updates, recommendation requests, and preference tags.
   - A shared exception hierarchy (`ValidationException`, `UnauthorizedException`, `ForbiddenException`, etc.) gives the application layer a consistent failure model.
   - Interfaces under `Common/Interfaces` define the dependency boundaries between layers, especially services, repositories, and cross-cutting concerns.

10. **Frontend architecture**
   - The frontend is a Vite + React + TypeScript app.
   - It is organized around pages, layouts, route guards, API clients, hooks, schemas, and strongly typed DTO-like models.
   - `AppRouter`, `ProtectedRoute`, and `RoleRoute` enforce authentication and role-based navigation in the client.

11. **Frontend data flow**
   - `src/api/axiosClient.ts` and endpoint modules centralize calls to the backend API.
   - Pages consume those endpoint modules directly or through hooks such as `useAuth`, `useSavedPlans`, `useStarredVenues`, and `useUnreadCount`.
   - `AuthContext` provides client-side session state, while token helpers manage JWT storage and decoding.

12. **Frontend feature surfaces**
   - The UI is split into auth pages, shared pages, admin pages, owner pages, and user-specific pages.
   - Shared areas include dashboard, venue search/detail, profile, notifications, and error pages.
   - Admin views cover user/owner lists and venue moderation; owner views cover venue add/edit; user views focus on preferences and recommendations.

13. **UI composition**
   - Layout components such as `AppShell`, `AuthLayout`, `NavBar`, `Sidebar`, and `NotificationBell` define the main shell around routed content.
   - Reusable UI primitives and form components suggest a component library approach for consistency across forms and modal/alert interactions.
   - Schemas and types in the frontend mirror backend DTOs and validation rules, keeping client/server contracts aligned.

14. **Operational and supporting assets**
   - The repo includes EF migrations, seed data, and a `docker-compose.yml`, indicating repeatable local environment setup and database provisioning.
   - Design and requirements documents are stored under `docs/` and `description/`, which support the implementation but are not runtime components.
   - A test project exists, though the architecture visible here suggests the main runtime system is the API + SPA pair backed by a relational database.

Main entry points: [`backend/PathWise.Application/Common/Interfaces`](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Common/Interfaces) (App contracts), [`backend/PathWise.API/Program.cs`](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Program.cs) (API host), [`backend/PathWise.Application/Services`](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Services) (Use cases), [`frontend/src/pages`](https://github.com/ercanpasha/pathwise/tree/main/frontend/src/pages) (Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_backend["Backend"]
  node_node_api["API host<br/>ASP.NET Core boundary<br/>[Program.cs]"]
  node_node_api_controllers["Controllers<br/>HTTP features<br/>[Controllers]"]
  node_node_api_middleware["Error middleware<br/>cross-cutting"]
  node_node_app_services["Use cases<br/>application services<br/>[Services]"]
  node_node_app_reco["Recommendation engine<br/>planning algorithm"]
  node_node_app_contracts["App contracts<br/>interfaces, DTOs, validators<br/>[Interfaces]"]
  node_node_domain[("Domain model<br/>core entities<br/>[Entities]")]
  node_node_infra_db[("Persistence<br/>EF Core storage<br/>[AppDbContext.cs]")]
  node_node_infra_repos["Repositories<br/>data access<br/>[Repositories]"]
  node_node_infra_security["Security<br/>auth helpers"]
end

subgraph group_grp_frontend["Frontend"]
  node_node_fe_router["App router<br/>client shell<br/>[AppRouter.tsx]"]
  node_node_fe_pages["Pages<br/>feature views"]
  node_node_fe_layouts["Layouts<br/>UI shell<br/>[AppShell.tsx]"]
  node_node_fe_api["API client<br/>data access<br/>[axiosClient.ts]"]
  node_node_fe_state["Client state<br/>hooks and context<br/>[AuthContext.tsx]"]
  node_node_fe_types["Schemas & types<br/>shared contracts"]
end

subgraph group_grp_ops["Ops & Docs"]
  node_node_ops_db["Compose setup<br/>local environment<br/>[docker-compose.yml]"]
  node_node_ops_docs["Docs<br/>supporting material"]
  node_node_tests["Tests<br/>test project"]
end

node_node_api -->|"hosts"| node_node_api_controllers
node_node_api -->|"uses"| node_node_api_middleware
node_node_api -->|"calls"| node_node_app_services
node_node_api -->|"binds"| node_node_app_contracts
node_node_app_services -->|"orchestrates"| node_node_app_reco
node_node_app_services -->|"operates on"| node_node_domain
node_node_app_services -->|"validates"| node_node_app_contracts
node_node_app_reco -->|"scores"| node_node_domain
node_node_app_contracts -->|"depends on"| node_node_infra_repos
node_node_infra_repos -->|"persists through"| node_node_infra_db
node_node_infra_security -->|"implements"| node_node_app_contracts
node_node_infra_db -->|"maps"| node_node_domain
node_node_fe_router -->|"navigates to"| node_node_fe_pages
node_node_fe_router -->|"wraps with"| node_node_fe_layouts
node_node_fe_pages -->|"fetches via"| node_node_fe_api
node_node_fe_pages -->|"consumes"| node_node_fe_state
node_node_fe_api -->|"mirrors"| node_node_app_contracts
node_node_fe_state -->|"shares"| node_node_fe_types
node_node_ops_db -->|"supports"| node_node_infra_db
node_node_ops_docs -.->|"informs"| node_node_app_contracts
node_node_tests -.->|"verifies"| node_node_api

click node_node_api "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Program.cs"
click node_node_api_controllers "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Controllers"
click node_node_api_middleware "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Middleware/ExceptionHandlingMiddleware.cs"
click node_node_app_services "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Services"
click node_node_app_reco "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Algorithm/RecommendationEngine.cs"
click node_node_app_contracts "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Common/Interfaces"
click node_node_domain "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Domain/Entities"
click node_node_infra_db "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Infrastructure/Persistence/AppDbContext.cs"
click node_node_infra_repos "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Infrastructure/Repositories"
click node_node_infra_security "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Infrastructure/Security/JwtTokenGenerator.cs"
click node_node_fe_router "https://github.com/ercanpasha/pathwise/blob/main/frontend/src/routes/AppRouter.tsx"
click node_node_fe_pages "https://github.com/ercanpasha/pathwise/tree/main/frontend/src/pages"
click node_node_fe_layouts "https://github.com/ercanpasha/pathwise/blob/main/frontend/src/components/layout/AppShell.tsx"
click node_node_fe_api "https://github.com/ercanpasha/pathwise/blob/main/frontend/src/api/axiosClient.ts"
click node_node_fe_state "https://github.com/ercanpasha/pathwise/blob/main/frontend/src/context/AuthContext.tsx"
click node_node_fe_types "https://github.com/ercanpasha/pathwise/tree/main/frontend/src/schemas"
click node_node_ops_db "https://github.com/ercanpasha/pathwise/blob/main/docker-compose.yml"
click node_node_ops_docs "https://github.com/ercanpasha/pathwise/tree/main/docs"
click node_node_tests "https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Tests/PathWise.Tests.csproj"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_api,node_node_api_controllers,node_node_api_middleware,node_node_app_services,node_node_app_reco,node_node_app_contracts,node_node_domain,node_node_infra_db,node_node_infra_repos,node_node_infra_security toneBlue
class node_node_fe_router,node_node_fe_pages,node_node_fe_layouts,node_node_fe_api,node_node_fe_state,node_node_fe_types toneAmber
class node_node_ops_db,node_node_ops_docs,node_node_tests toneMint
```

## Components

### Backend

ASP.NET Core API, application workflows, domain model, and infrastructure persistence.

- [API host](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Program.cs): ASP.NET Core boundary · Program startup, middleware, configuration, and controller hosting. · `backend/PathWise.API/Program.cs`
- [Controllers](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Controllers): HTTP features · Feature-oriented endpoints for auth, venues, recommendations, plans, tags, notifications, accounts, and dashboard pages. · `backend/PathWise.API/Controllers`
- [Error middleware](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.API/Middleware/ExceptionHandlingMiddleware.cs): cross-cutting · Translates application exceptions into consistent HTTP responses. · `backend/PathWise.API/Middleware/ExceptionHandlingMiddleware.cs`
- [Use cases](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Services): application services · Auth, venue, user account, saved plan, starred venue, notification, tag, and page workflows. · `backend/PathWise.Application/Services`
- [Recommendation engine](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Algorithm/RecommendationEngine.cs): planning algorithm · Rule and score based trip planning with cost and tag matching. · `backend/PathWise.Application/Algorithm/RecommendationEngine.cs`
- [App contracts](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Application/Common/Interfaces): interfaces, DTOs, validators · Layer boundaries, request/response shapes, settings, and validation rules. · `backend/PathWise.Application/Common/Interfaces`
- [Domain model](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Domain/Entities): core entities · Business entities and enums for users, venues, trip plans, tags, starred venues, and notifications. · `backend/PathWise.Domain/Entities`
- [Persistence](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Infrastructure/Persistence/AppDbContext.cs): EF Core storage · DbContext, entity configurations, migrations, and seeding. · `backend/PathWise.Infrastructure/Persistence/AppDbContext.cs`
- [Repositories](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Infrastructure/Repositories): data access · Repository implementations and unit of work abstractions for persistence operations. · `backend/PathWise.Infrastructure/Repositories`
- [Security](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Infrastructure/Security/JwtTokenGenerator.cs): auth helpers · JWT generation, password hashing, and current-user resolution. · `backend/PathWise.Infrastructure/Security/JwtTokenGenerator.cs`

### Frontend

Vite React TypeScript client with routed feature pages, API clients, and UI composition.

- [App router](https://github.com/ercanpasha/pathwise/blob/main/frontend/src/routes/AppRouter.tsx): client shell · Client routing and route guards for authenticated and role-based navigation. · `frontend/src/routes/AppRouter.tsx`
- [Pages](https://github.com/ercanpasha/pathwise/tree/main/frontend/src/pages): feature views · Auth, shared, admin, owner, and user pages for dashboard, venue, profile, notification, and recommendation flows. · `frontend/src/pages`
- [Layouts](https://github.com/ercanpasha/pathwise/blob/main/frontend/src/components/layout/AppShell.tsx): UI shell · App shell, auth layout, navigation, sidebar, and notification bell composition. · `frontend/src/components/layout/AppShell.tsx`
- [API client](https://github.com/ercanpasha/pathwise/blob/main/frontend/src/api/axiosClient.ts): data access · Axios client and endpoint modules for backend communication. · `frontend/src/api/axiosClient.ts`
- [Client state](https://github.com/ercanpasha/pathwise/blob/main/frontend/src/context/AuthContext.tsx): hooks and context · Auth context, session hooks, saved plan hooks, starred venue hooks, and unread-count hooks. · `frontend/src/context/AuthContext.tsx`
- [Schemas & types](https://github.com/ercanpasha/pathwise/tree/main/frontend/src/schemas): shared contracts · Typed models and schemas mirroring backend DTOs and validation rules. · `frontend/src/schemas`

### Ops & Docs

Database provisioning, tests, and supporting repository assets.

- [Compose setup](https://github.com/ercanpasha/pathwise/blob/main/docker-compose.yml): local environment · Docker compose and repository assets supporting repeatable local provisioning. · `docker-compose.yml`
- [Docs](https://github.com/ercanpasha/pathwise/tree/main/docs): supporting material · Project requirements, design, and domain documentation. · `docs`
- [Tests](https://github.com/ercanpasha/pathwise/blob/main/backend/PathWise.Tests/PathWise.Tests.csproj): test project · Backend test project for verifying system behavior. · `backend/PathWise.Tests/PathWise.Tests.csproj`

## Connections

- API host → Controllers: hosts · Startup exposes the HTTP feature controllers.
- API host → Error middleware: uses · Requests pass through centralized exception translation.
- API host → Use cases: calls · Controllers delegate business workflows to application services.
- API host → App contracts: binds · API configuration and request models rely on application contracts.
- Use cases → Recommendation engine: orchestrates · Recommendation use cases invoke the planner subsystem.
- Use cases → Domain model: operates on · Services coordinate business entities and state transitions.
- Use cases → App contracts: validates · DTOs and validators shape and guard incoming requests.
- Recommendation engine → Domain model: scores · The planner evaluates venues, tags, and trip plan outputs.
- App contracts → Repositories: depends on · Application boundaries are backed by repository abstractions implemented in infrastructure.
- Repositories → Persistence: persists through · Repositories execute against the EF Core database context.
- Security → App contracts: implements · Security helpers satisfy token, password, and current-user interfaces.
- Persistence → Domain model: maps · Entity configurations and migrations shape the domain model in storage.
- App router → Pages: navigates to · Routes deliver the feature pages under access control.
- App router → Layouts: wraps with · Route trees render inside shared client shells.
- Pages → API client: fetches via · Pages use endpoint modules or hooks backed by the API client.
- Pages → Client state: consumes · Pages read session and domain state from hooks and context.
- API client → App contracts: mirrors · Frontend contracts align with backend DTOs and schemas.
- Client state → Schemas & types: shares · Hooks and context use typed client models.
- Compose setup → Persistence: supports · Compose setup enables local database-backed development.
- Docs → App contracts: informs · Design and requirements docs describe the implemented contracts and flows.
- Tests → API host: verifies · Tests target the backend runtime and its exposed behaviors.
