How ercanpasha/pathwise works
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: Interfaces App contracts · Program.cs API host · Services Use cases · pages Pages
Components 19
Backend
ASP.NET Core API, application workflows, domain model, and infrastructure persistence.
- API host · Program startup, middleware, configuration, and controller hosting.
backend/PathWise.API/Program.cs - Controllers · Feature-oriented endpoints for auth, venues, recommendations, plans, tags, notifications, accounts, and dashboard pages.
backend/PathWise.API/Controllers - Error middleware · Translates application exceptions into consistent HTTP responses.
backend/PathWise.API/Middleware/ExceptionHandlingMiddleware.cs - Use cases · Auth, venue, user account, saved plan, starred venue, notification, tag, and page workflows.
backend/PathWise.Application/Services - Recommendation engine · Rule and score based trip planning with cost and tag matching.
backend/PathWise.Application/Algorithm/RecommendationEngine.cs - App contracts · Layer boundaries, request/response shapes, settings, and validation rules.
backend/PathWise.Application/Common/Interfaces - Domain model · Business entities and enums for users, venues, trip plans, tags, starred venues, and notifications.
backend/PathWise.Domain/Entities - Persistence · DbContext, entity configurations, migrations, and seeding.
backend/PathWise.Infrastructure/Persistence/AppDbContext.cs - Repositories · Repository implementations and unit of work abstractions for persistence operations.
backend/PathWise.Infrastructure/Repositories - Security · 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 · Client routing and route guards for authenticated and role-based navigation.
frontend/src/routes/AppRouter.tsx - Pages · Auth, shared, admin, owner, and user pages for dashboard, venue, profile, notification, and recommendation flows.
frontend/src/pages - Layouts · App shell, auth layout, navigation, sidebar, and notification bell composition.
frontend/src/components/layout/AppShell.tsx - API client · Axios client and endpoint modules for backend communication.
frontend/src/api/axiosClient.ts - Client state · Auth context, session hooks, saved plan hooks, starred venue hooks, and unread-count hooks.
frontend/src/context/AuthContext.tsx - Schemas & types · Typed models and schemas mirroring backend DTOs and validation rules.
frontend/src/schemas
Ops & Docs
Database provisioning, tests, and supporting repository assets.
- Compose setup · Docker compose and repository assets supporting repeatable local provisioning.
docker-compose.yml - Docs · Project requirements, design, and domain documentation.
docs - Tests · Backend test project for verifying system behavior.
backend/PathWise.Tests/PathWise.Tests.csproj
Connections 21
- 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.