How trycatchlearn/datingapp works
1. This repo is a two-part monorepo: an ASP.NET Core 9 backend in API/ and an Angular 20 SPA in client/. The backend also serves the built frontend from API/wwwroot, so the deployed app is a single hosted system with an API and static SPA assets behind the same origin.
2. The backend is the application boundary for all data and security. HTTP entry points are organized by controller: AccountController for auth, MembersController for profile/member data, LikesController for matching/likes, MessagesController for chat, AdminController for moderation/admin workflows, plus FallbackController for SPA routing and BuggyController/WeatherForecastController for testing and template remnants.
3. The core domain is a dating/social model centered on AppUser, Member, Photo, Message, MemberLike, and the SignalR connection types Connection/Group. AppDbContext is the EF Core persistence boundary, with migrations under API/Data/Migrations defining the relational schema.
4. Data access is deliberately split behind repositories and a unit-of-work layer. MemberRepository, LikesRepository, MessageRepository, and PhotoRepository implement the main query/update paths, while UnitOfWork coordinates shared transaction-style changes. This keeps controllers thin and makes member browsing, likes, and messaging the main backend workflows.
5. Authentication is token-based. TokenService issues JWTs, ClaimsPrincipalExtensions and AppUserExtensions help read identity/claim data, and the Angular client stores and replays the token through a JWT interceptor. Authorization is enforced both server-side and client-side, including an admin-only path via AdminController and admin-guard.
6. Realtime behavior is handled with SignalR. PresenceHub and PresenceTracker manage online/offline state, while MessageHub supports live message delivery. This creates a separate realtime channel alongside normal REST calls, especially for chat status and message arrival.
7. Photo handling is an externalized subsystem. IPhotoService/PhotoService abstract image upload and management, with CloudinarySettings indicating cloud-hosted media storage rather than local file persistence. The admin photo review flow is also explicit via PhotoForApprovalDto and the admin photo-management UI.
8. The Angular app is structured by feature area rather than by technical layer. app.routes.ts, app.config.ts, and app.ts define the shell and route composition; layout/nav provides the top-level navigation; shared/ contains reusable UI pieces like paginator, confirm dialog, star button, image upload, text input, and error pages.
9. Major frontend features map directly to backend domains: account registration, member list/detail/profile, member photos/messages, likes/lists, admin, and error-testing pages. Each feature has its own component tree, which makes the architecture easy to diagram as route-driven feature islands around a common shell.
10. Cross-cutting frontend behavior is centralized in services, guards, interceptors, and pipes. Services such as account-service, member-service, message-service, likes-service, presence-service, and admin-service encapsulate API access; interceptors handle JWT attachment, HTTP errors, and busy/loading state; guards protect authenticated/admin routes and unsaved edits; pipes handle domain presentation like age and time-ago formatting.
11. The data flow is straightforward: Angular screens call typed services, services hit ASP.NET controllers, controllers use DTOs to avoid exposing entities directly, and repositories/EF Core persist to the database. Realtime message/presence updates bypass the normal request/response flow through SignalR hubs, and photo operations route through the dedicated photo service.
12. Supporting infrastructure includes seeding and deployment helpers. Seed.cs and UserSeedData.json bootstrap initial users/data, ExceptionMiddleware standardizes API error handling, and the repo includes docker-compose.yml plus GitHub Actions workflow files for automation and environment setup.
Main entry points: services Client services · Program.cs Program · Controllers Controllers · AppDbContext.cs AppDbContext
Components 20
ASP.NET Core backend
API, domain, data, realtime, and hosting boundary.
- Program · Composes middleware, controllers, SignalR, auth, and static SPA hosting.
API/Program.cs - Controllers · Primary HTTP entry points for account, members, likes, messages, admin, fallback, and test routes.
API/Controllers - DTOs · Request/response models that keep entities out of the API surface.
API/DTOs - Domain model · Users, members, photos, likes, messages, and realtime connection/group state.
API/Entities - AppDbContext · Database context and schema mapping for the core dating app model.
API/Data/AppDbContext.cs - Repositories · Member, likes, message, and photo repositories behind shared query/update paths.
API/Data - UnitOfWork · Coordinates shared persistence changes across repositories.
API/Data/UnitOfWork.cs - Services · Token issuance and photo management implementations.
API/Services - SignalR · Presence and message hubs plus online-user tracking.
API/SignalR - Middleware · Centralized API exception translation and response shaping.
API/Middleware
Angular SPA
Route-driven client shell, features, and shared UI.
- Angular app · Frontend application shell, routing, and build output served by the API.
client/src/app - Routes · Top-level route composition and app bootstrap configuration.
client/src/app/app.routes.ts - Features · Account, members, messages, lists, admin, home, and test-error views.
client/src/features - Shared UI · Reusable controls, dialogs, uploaders, pagination, errors, and directives.
client/src/shared - Client services · Typed services for accounts, members, likes, messages, presence, admin, busy state, and toast/confirm flows.
client/src/core/services - Guards · Auth, admin, and unsaved-change route guards.
client/src/core/guards - Interceptors · JWT attachment, error handling, and loading-state interception.
client/src/core/interceptors - Pipes · Age and time-ago formatting for domain views.
client/src/core/pipes
Infrastructure
Deployment, seeding, and automation support.
- Seed data · Initial user/data seeding and bundled seed payload.
API/Data/Seed.cs - Deployment · Docker compose and CI workflow for build and environment automation.
docker-compose.yml
Connections 25
- Program → Controllers: maps HTTP · Registers controller endpoints and SPA fallback.
- Program → AppDbContext: configures · Wires EF Core persistence and connection settings.
- Program → Services: registers · Adds token and photo services to DI.
- Program → SignalR: hosts · Mounts realtime hubs alongside REST APIs.
- Program → Middleware: uses · Places exception handling in the request pipeline.
- Controllers → DTOs: exchanges · Uses DTOs for input and output models.
- Controllers → Repositories: queries · Member, likes, and message workflows delegate to repositories.
- Controllers → UnitOfWork: commits · Coordinates multi-step persistence operations.
- Controllers → Services: calls · Auth and photo operations depend on service layer.
- Services → Domain model: operates on · Token and photo services work with app entities and claims.
- Repositories → AppDbContext: persists via · Repository implementations run through the EF Core boundary.
- AppDbContext → Domain model: maps · Defines relational storage for the core entities.
- SignalR → Domain model: tracks · Presence and chat state use connection and group entities.
- Angular app → Routes: boots · The SPA shell starts from app routing and config.
- Routes → Features: loads · Routes resolve into feature areas.
- Features → Shared UI: reuses · Feature screens share common controls and error views.
- Features → Client services: calls · Screens talk to backend through typed services.
- Client services → Interceptors: passes through · HTTP calls are wrapped by JWT, error, and loading interceptors.
- Client services → Guards: protected by · Route access is constrained by auth and admin guards.
- Client services → Pipes: formats with · Presentation helpers support member and message views.
- Client services → Controllers: requests · Client services consume the backend API surface.
- Client services → SignalR: subscribes to · Presence and chat services use realtime hubs.
- Seed data → AppDbContext: seeds · Bootstrap data is loaded through the persistence layer.
- Deployment → Program: packages · Deployment bundles the hosted backend and SPA.
- Deployment → Angular app: builds · Frontend assets are part of the deployable system.