How captonseproject-spring2025/be_dotnetlaundryservice works
Project Type and Purpose
• This is a backend-only, full-stack service API (no bundled web frontend) for a laundry-service platform. It exposes REST endpoints (via ASP.NET Core), real-time hubs (SignalR), background jobs (Hangfire), and interfaces with external services (Firebase, Mapbox, SMS, payment gateway, OpenAI, file storage). Clients (mobile apps, admin dashboards) consume these APIs.
File Structure & Architectural Pattern
• Top‐Level Projects in the .sln:
• LaundryService.Api – ASP.NET Core Web API (Controllers, Middleware, Hubs, Dockerfile).
• LaundryService.Service – business logic / application services, background workers.
• LaundryService.Infrastructure – EF Core DbContext, Repository & UnitOf-Work, utilities, Hangfire config.
• LaundryService.Domain – domain entities, enums, constants, service interfaces (port definitions).
• LaundryService.Dto – data‐transfer objects (requests, responses, pagination).
• Patterns: Clean/Onion Architecture, Dependency Injection, Repository + Unit-Of-Work, layered separation, real-time messaging via SignalR, background scheduling via Hangfire.
Key Architectural Components
a. API Layer
• Controllers (e.g., OrderController, AuthController) expose HTTP endpoints.
• Middleware: global exception handler, authentication, Hangfire UI auth.
• SignalR Hubs: ChatHub, ComplaintHub, TrackingHub.
• Static file serving for uploads.
b. Application/Service Layer
• Implements domain service interfaces (IOrderService, IUserService, etc.).
• Orchestrates business rules and calls repositories and external‐service integrations.
• BackgroundServices (OrderAutoCompleteWorker, OrderJobService) for scheduled tasks.
c. Infrastructure Layer
• LaundryServiceDbContext: EF Core model for Persistence.
• Repository<T> + UnitOfWork: generic data access.
• HangfireConfig: configures background job storage and dashboard.
• Util: file uploads, Unit tests stubs.
d. Domain Layer
• Core Entities and Enums define data model (Order, User, Payment, etc.).
• Service interfaces define ports for business logic implementations.
e. External Services
• Firebase (push notifications, storage).
• Mapbox (geocoding, routing).
• SpeedSms (SMS OTP).
• PayOS or other Payment links.
• OpenAI (text/chat endpoints).
f. Data Store
• SQL Server (laundryservicedb.sql).
• Hangfire uses the same or dedicated storage.
g. Deployment
• Dockerfile under Api, docker-compose.yml in root.
• GitHub Actions (deploy.yml) for CI/CD.
Architectural Patterns & Principles
• Onion/Clean architecture: dependencies point inward to Domain.
• Single Responsibility per layer: Controllers only handle HTTP, Services only business, Infrastructure only data.
• Repository + UnitOfWork abstracts data store.
• DTOs for request/response separation.
• Real-time messaging decoupled via Hubs.
• Background scheduling for asynchronous tasks.
• Configuration & secrets externalized in appsettings.json and Docker secrets.