How abhishek-kumar24698e/safecity-fullstack works
1. Repo shape
- This is a three-part monorepo: SafeCity backend API, SafeCity.Domain shared domain model, and SafeCity-Frontend Angular SPA.
- The backend owns business logic and persistence; the frontend is a thin client; the domain project holds the EF Core entity model and enums.
2. Primary architectural boundary
- The clearest boundary is between the Angular app and the ASP.NET Core API.
- All state-changing and query operations flow from Angular components/services to REST controllers, then through service and repository layers to SQL Server via EF Core.
- Real-time updates bypass the normal request/response path and go through SignalR.
3. Frontend structure
- The Angular app uses standalone components and route-based lazy loading.
- src/app/features/* contains the major screens: auth, dashboard, incidents, cases, patrols, field reports, dispatch, resources, crisis, response, audits, compliance, users, notifications, profile, landing.
- src/app/layout/* provides the application shell: main-layout and sidebar.
- src/app/core/* contains cross-cutting client concerns: auth guards, HTTP interceptors, typed API models, and feature-specific services.
4. Frontend request flow
- User interaction starts in a feature component.
- Feature services in src/app/core/services call the API over HTTP.
- auth.interceptor.ts attaches the JWT to outgoing requests.
- auth.guard.ts protects authenticated routes, and route access is further shaped by role-based navigation in the sidebar and route config.
5. Backend API layer
- The backend is organized by feature/module, with one controller per major area: Auth, User, Incident, Case, Patrol, FieldReport, Dispatch, Resource, Crisis, Response, Audit, Compliance, and Notification.
- Controllers are the HTTP edge: routing, authorization, request binding, and response formatting.
- The naming suggests a fairly explicit REST API surface aligned to the same business domains visible in the frontend.
6. Service layer
- Each business area has a service class under Services/*.
- These services are the main orchestration layer: validation, workflow/state transitions, audit/logging concerns, and coordination across repositories.
- The presence of interfaces for each service indicates a dependency-injected, testable boundary between controllers and data access.
7. Repository and persistence layer
- Each domain module has a repository pair under Repository/* with interface plus implementation.
- Repositories encapsulate EF Core queries against SafeCityDbContext.
- This keeps SQL/ORM concerns isolated from business rules and makes the backend a conventional layered architecture rather than an anemic controller-to-DbContext setup.
8. Shared domain model
- SafeCity.Domain contains the core entities, enums, and SafeCityDbContext.
- Entities include User, Incident, Case, Dispatch, Resource, Patrol, FieldReport, Crisis, Response, Team, Audit, and AuditLog, plus supporting role and status enums.
- Keeping the domain in a separate project makes the model reusable and keeps API concerns out of the persistence model.
9. DTO and mapping boundary
- The API does not expose entities directly; it uses DTOs grouped by feature under DTOs/*.
- Mapper/MappingProfile.cs centralizes entity-to-DTO translation through AutoMapper.
- This is an important architecture boundary because it separates persistence shape from network contract shape.
10. Authentication, authorization, and audit
- Identity is centered around AuthController/AuthService and UserController/UserService.
- The repo contains JWT, password hashing helpers, auth guards, and auth utilities, indicating token-based stateless sessions.
- Audit concerns are first-class: AuditController, AuditService, AuditLogger, and AuditLog show that operational actions are tracked separately from normal business entities.
11. Real-time notifications
- Hubs/NotificationHub.cs is the real-time boundary for push messaging.
- The frontend has a notifications feature and the backend has a dedicated notification service and controller, which suggests that notifications are both persisted and broadcast live.
- This is the main non-REST subsystem in the architecture.
12. Cross-cutting utilities
- The backend Utility folder contains shared validation and helper logic such as email/password/phone helpers, exception helpers, and custom validation attributes.
- These utilities support the service layer but are not themselves application features.
- On the frontend, shared/constants.ts, shared/auth-utils.ts, and shared/icon.component.ts serve the same cross-cutting role.
13. How the modules line up
- The frontend feature pages map closely to backend modules: incidents/cases, dispatch/resources, patrols/field reports, crisis/response, audits/compliance, and user/auth flows.
- That symmetry makes the architecture easy to diagram as a set of domain modules connected through one API and one database, rather than as unrelated screens.
14. Infrastructure/runtime implications
- The backend expects SQL Server through EF Core and runs as an ASP.NET Core Web API.
- The frontend is an Angular SPA built with Tailwind-based styling and client-side routing.
- The system is therefore deployed as at least two independently running services: browser SPA plus API, with the API also hosting SignalR connections.
Main entry points: AuthController.cs Controllers · AuthService.cs Services · app.routes.ts Routes · MappingProfile.cs Mapping
Components 17
SafeCity-Frontend
Angular SPA with feature routes, layout shell, and client-side API access
- Angular SPA · Browser client with route-based features and standalone components
SafeCity-Frontend/src/app/app.ts - Routes · Top-level client routing and lazy-loaded feature boundaries
SafeCity-Frontend/src/app/app.routes.ts - App Shell · Main layout and sidebar navigation for authenticated screens
SafeCity-Frontend/src/app/layout/main-layout/main-layout.ts - Auth Client · JWT handling, route protection, and HTTP interception
SafeCity-Frontend/src/app/core/interceptors/auth.interceptor.ts - API Services · Typed service layer for feature-specific API calls
SafeCity-Frontend/src/app/core/services/auth.service.ts - Feature Screens · Primary domain screens such as incidents, cases, patrols, dispatch, and users
SafeCity-Frontend/src/app/features/incidents/incidents-page.ts - Shared UI · Cross-cutting constants, auth helpers, and reusable icon component
SafeCity-Frontend/src/app/shared/constants.ts
SafeCity API
ASP.NET Core REST API with services, repositories, DTOs, and SignalR
- Controllers · REST endpoints for auth, users, incidents, cases, operations, and notifications
SafeCity/SafeCity/Controllers/AuthController.cs - DTOs · Request and response contracts separating API shape from entities
SafeCity/SafeCity/DTOs/User/LoginRequestDto.cs - Mapping · AutoMapper profile translating entities to API contracts
SafeCity/SafeCity/Mapper/MappingProfile.cs - Services · Workflow orchestration, validation, and coordination across repositories
SafeCity/SafeCity/Services/Auth/AuthService.cs - Repositories · EF Core repository layer encapsulating persistence queries and updates
SafeCity/SafeCity/Repository/User/UserRepository.cs - Notification Hub · Real-time push channel for live notifications
SafeCity/SafeCity/Hubs/NotificationHub.cs - Audit Logging · Dedicated logging boundary for operational tracking and audit events
SafeCity/SafeCity/Services/AuditLog/AuditLogger.cs
SafeCity.Domain
Shared entities, enums, and EF Core DbContext
- DbContext · Shared EF Core context used by repositories
SafeCity.Domain/SafeCity.Domain/Data/SafeCityDbContext.cs - Entities · Core entities for users, incidents, cases, dispatch, resources, patrols, reports, crisis, response, audit, compliance, and teams
SafeCity.Domain/SafeCity.Domain/Entity/User.cs - Enums · Status, role, type, and result enums used across the model
SafeCity.Domain/SafeCity.Domain/Enum/UserRoleOption.cs
Connections 19
- Angular SPA → Routes: uses · The app boots into the routed shell
- Routes → App Shell: mounts · Authenticated routes render inside the main application shell
- Routes → Feature Screens: lazy loads · Feature areas are split into route-based screens
- Feature Screens → API Services: calls · Feature components invoke typed services for data access
- API Services → Auth Client: secured by · Outgoing requests rely on JWT attachment and route guards
- Auth Client → Controllers: requests · Client HTTP traffic targets REST controllers
- Shared UI → Feature Screens: supports · Shared helpers and UI primitives are used across screens
- Controllers → DTOs: binds · Controllers accept and return DTO contracts
- Controllers → Services: delegates · HTTP edge forwards work into business services
- Services → Repositories: uses · Services coordinate persistence through repositories
- Services → Audit Logging: logs · Operational actions are captured through audit logging
- Repositories → DbContext: queries · Repositories use the shared EF Core context
- DbContext → Entities: tracks · The context is built around the shared entity model
- Entities → Enums: uses · Entities depend on status and role enumerations
- Mapping → Entities: maps · AutoMapper translates between persistence models and DTOs
- Mapping → DTOs: maps · Mapping profile produces API response and request shapes
- Controllers → Notification Hub: pushes · Notification controller/service interactions can publish live updates
- Services → Notification Hub: broadcasts · Notification workflows can emit real-time messages
- Controllers → Mapping: formats · Controllers rely on mapped contract shapes for responses