How casolanki/maitree works
1. Overall shape
- This repository is a two-tier full-stack application: an ASP.NET Core backend in API/ and an Angular SPA frontend in client/.
- The app appears centered on user/member profiles, likes, messaging, admin moderation, and presence, with the backend exposing HTTP APIs and real-time SignalR channels.
2. Backend entrypoint and host boundary
- API/Program.cs is the backend composition root.
- API/Controllers/* expose the REST API surface, while API/wwwroot/ contains the built frontend assets, indicating the backend can also serve the SPA in production.
- API/Middleware/ExceptionMiddleware.cs and API/Errors/ApiException.cs provide centralized API error handling.
3. Domain model and persistence
- The core entities live in API/Entities/: AppUser, AppRole, AppUserRole, Photo, Message, Group, Connection, UserLike.
- This is an EF Core-backed domain with a social/messaging model:
- users can have photos,
- users can like other users,
- users can exchange messages,
- users connect to SignalR groups/connections for presence and chat.
4. Data access pattern
- Persistence is organized around repositories and a unit-of-work layer:
- API/Data/UserRepository.cs
- API/Data/LikesRepository.cs
- API/Data/MessageRepository.cs
- API/Data/UnitOfWork.cs
- interfaces in API/Interface/*
- API/Data/DataContext.cs is the EF Core context, with migrations under API/Data/Migrations/.
- The app uses a repository abstraction over EF Core rather than direct context access from controllers.
5. Authentication and authorization
- Authentication is token-based via API/Services/TokenService.cs and API/Interface/ITokenService.cs.
- API/Extensions/IdentityServiceExtensions.cs and identity-related entities indicate ASP.NET Core Identity is used for user/role management.
- The backend has admin-specific surfaces (AdminController.cs) and the client has guards/directives for role-based UI control, so authorization is a first-class boundary.
6. Photos and external storage
- API/Services/PhotoService.cs, API/Interface/IphotoService.cs, and API/Helpers/CloudinarySettings.cs show that photo upload/management is delegated to an external cloud photo service (Cloudinary).
- Photo is a core entity, so media handling is part of the main user profile flow, not an auxiliary feature.
7. Real-time subsystem
- API/SignalR/MessageHub.cs, PresenceHub.cs, and PresenceTracker.cs implement the real-time layer.
- This supports at least two live concerns:
- presence/online status tracking
- instant messaging updates
- These hubs sit alongside the REST API, meaning the app combines request/response and persistent socket-based interaction.
8. Backend API surface
- Controllers are split by feature:
- AccountController for login/register/account actions
- UsersController for member browsing/profile editing
- Likescontroller for like relationships
- MessagesController for messaging
- AdminController for moderation/administration
- DTOs in API/DTOs/ separate API contracts from entities, so the backend does mapping between persistence models and transport models.
9. Frontend application structure
- The Angular client is feature-organized under client/src/app/:
- members/ for member list/detail/edit/photo editor
- messages/ for messaging UI
- lists/ for likes/match lists
- admin/ for admin dashboards and moderation
- register/, home/, nav/, and error pages
- This suggests the SPA is the primary user interface, with feature modules and shared components rather than a monolithic page structure.
10. Frontend-to-backend data flow
- Angular services in client/src/app/_services/ (account.service.ts, members.service.ts, message.service.ts, presence.service.ts) are the main API boundary.
- HTTP cross-cutting concerns are handled by interceptors:
- jwt.interceptor.ts attaches auth tokens
- error.interceptor.ts normalizes API failures
- loading.interceptor.ts and busy.service.ts manage UI loading state
- Guards (auth.guard.ts, admin.guard.ts, prevent-unsaved-changes.guard.ts) enforce route-level access and editing protection.
11. Client state, models, and UI composition
- Client-side models mirror backend contracts: member, message, photo, pagination, user, group, likeParams, userParams.
- Resolvers such as member.detailed.resolver.ts prefetch data before route activation.
- Shared UI building blocks live in _forms/, _directives/, and _modules/shared.module.ts, indicating a reusable component architecture.
12. Administration boundary
- The admin experience is separated both in backend and frontend:
- backend: AdminController
- frontend: admin-panel, user-management, photo-management, admin.service.ts, roles-modal
- This creates a distinct privileged subsystem for role assignment and moderation, rather than blending admin features into regular user screens.
13. Deployment and packaging
- There are Docker assets for the backend (API/Dockerfile) and CI/CD workflows in .github/workflows/ plus cicd-bckup/.
- fly.toml suggests deployment to Fly.io or a similarly configured container platform.
- The presence of built assets in API/wwwroot/ implies a production build that packages the SPA with the API container or deployable unit.
14. What to draw as the key architecture boundaries
- At minimum, the diagram should show:
- Angular SPA client
- ASP.NET Core API
- EF Core/PostgreSQL persistence
- Identity/token auth
- Cloudinary external media storage
- SignalR real-time channel
- The main flows are: user authentication → token-protected API calls, profile/photo management → DB + Cloudinary, and messaging/presence → SignalR plus database-backed message history.
Main entry points: app.module.ts SPA shell · Program.cs API host · Controllers REST controllers · _services Client services
Components 20
Angular SPA
Browser application with feature modules, shared UI, and API services.
- SPA shell · Root Angular application, routing, and top-level layout.
client/src/app/app.module.ts - Members · Browse, view, edit, and manage member profiles and photos.
client/src/app/members - Messages · Messaging UI for conversations and live updates.
client/src/app/messages - Likes lists · Screens for likes and match-oriented member lists.
client/src/app/lists - Admin UI · Admin dashboard, user moderation, photo review, and role management.
client/src/app/admin - Client services · HTTP and signal services for account, members, messages, presence, busy state, and pagination.
client/src/app/_services - Guards/interceptors · Route guards and HTTP interceptors for auth, errors, loading, and unsaved changes.
client/src/app/_guards - Shared UI · Reusable forms, directives, modal dialogs, and shared module.
client/src/app/_forms
ASP.NET Core API
Backend host exposing REST endpoints, identity, persistence, and real-time hubs.
- API host · Composition root, middleware, controllers, SPA fallback, and static hosting.
API/Program.cs - Identity/auth · ASP.NET Core Identity and token-based authentication/authorization.
API/Extensions/IdentityServiceExtensions.cs - REST controllers · Account, users, likes, messages, and admin endpoints.
API/Controllers - DTO mapping · Request and response models separating transport from entities.
API/DTOs - Domain entities · Users, roles, photos, likes, messages, connections, and groups.
API/Entities - Repositories · Repository and unit-of-work layer over EF Core persistence.
API/Data - Db context · Database context and migrations for the application schema.
API/Data/DataContext.cs - SignalR hubs · Presence and messaging hubs plus presence tracking.
API/SignalR - Photo service · Photo upload and management through Cloudinary.
API/Services/PhotoService.cs - Error handling · Centralized API exception middleware and error model.
API/Middleware/ExceptionMiddleware.cs
External / deploy
Non-application services and packaging boundaries.
- SPA assets · Built frontend files served from the backend wwwroot in production.
API/wwwroot/index.html - CI/CD · Docker build and push workflows plus Fly deployment config.
fly.toml
Connections 24
- SPA shell → Members: routes to · Primary member browsing and editing area.
- SPA shell → Messages: routes to · Messaging feature entry point.
- SPA shell → Likes lists: routes to · Likes and match list screens.
- SPA shell → Admin UI: routes to · Privileged admin area.
- SPA shell → Client services: uses · All feature modules call backend through services.
- SPA shell → Guards/interceptors: protected by · Route and request cross-cutting controls.
- SPA shell → Shared UI: composes · Reusable UI building blocks.
- Client services → REST controllers: calls · HTTP boundary from Angular to REST endpoints.
- Client services → SignalR hubs: connects to · Presence and message live updates.
- API host → REST controllers: exposes · REST API surface.
- API host → Error handling: uses · Centralized exception handling.
- API host → Identity/auth: configures · Authentication and authorization setup.
- API host → Repositories: wires · Repository and unit-of-work dependencies.
- API host → SignalR hubs: hosts · SignalR hubs alongside HTTP endpoints.
- API host → SPA assets: serves · Production SPA static files.
- REST controllers → DTO mapping: uses · Transport contracts for requests and responses.
- REST controllers → Repositories: depends on · Feature data access through repositories.
- Repositories → Db context: wraps · EF Core persistence implementation.
- Db context → Domain entities: maps · Entity model and relationships.
- REST controllers → Identity/auth: secures · User, role, and token-based access control.
- REST controllers → Photo service: uploads photos · Profile photo management flow.
- SignalR hubs → Db context: persists state · Message history, groups, and presence-related data.
- CI/CD → API host: builds/deploys · Container and release pipeline for the backend.
- CI/CD → SPA shell: packages · Frontend build artifacts included in deployment.