How grabjke/petfamily works
Purpose and runtime
PetFamily is a modular .NET backend for managing animal-care volunteers, their pets, species/breeds, volunteer applications, user accounts, discussions, and files. The executable API host is backend/src/PetFamily.Web/Program.cs; solution-level build orchestration is backend/backend.sln. Container deployment is defined by backend/src/PetFamily.Web/Dockerfile and backend/compose.yaml, with Nginx configuration at backend/nginx.conf.
Modular architecture and request boundary
Each business module follows layered boundaries: Presentation controllers map HTTP requests to application commands/queries; Application owns use cases and repository interfaces; Domain owns aggregates/rules; Infrastructure implements persistence and external integrations. Module registrations are composed through dependency injection, e.g. backend/src/Volunteers/PetFamily.Volunteers.Infrastructure/DependencyInjection.cs and backend/src/Accounts/PetFamily.Accounts.Application/DependencyInjection.cs. Shared command/query abstractions are in backend/src/Shared/PetFamily.Core/Abstractions/ICommand.cs and backend/src/Shared/PetFamily.Core/Abstractions/IQuery.cs. API errors are centralized through backend/src/PetFamily.Web/Middlewares/ExceptionMiddlware.cs.
Accounts, identity, and authorization
Accounts manage registration, login, logout, refresh sessions, JWT issuance, roles, permissions, and account types (participant, volunteer, admin). HTTP entry is backend/src/Accounts/PetFamily.Accounts.Presentation/AccountController.cs; authentication workflows reside in backend/src/Accounts/PetFamily.Accounts.Application/AccountsManagement/Commands/LoginUser/LoginHandler.cs and backend/src/Accounts/PetFamily.Accounts.Application/AccountsManagement/Commands/RefreshTokens/RefreshTokensHandler.cs. Infrastructure persists identity entities through backend/src/Accounts/PetFamily.Accounts.Infrastructure/AccountDbContext.cs, creates JWTs via backend/src/Accounts/PetFamily.Accounts.Infrastructure/JwtTokenProvider.cs, and enforces dynamic permission policies through backend/src/Accounts/PetFamily.Accounts.Infrastructure/PermissionPolicyProvider.cs.
Volunteer and animal management
The Volunteers module is the core operational catalog: volunteers own pets, with lifecycle, profile, status, ordering, and photo operations. Its API boundary is backend/src/Volunteers/PetFamily.Volunteers.Presentation/VolunteersController.cs; domain aggregates are backend/src/Volunteers/PetFamily.Volunteers.Domain/PetManagement/Volunteer.cs and backend/src/Volunteers/PetFamily.Volunteers.Domain/PetManagement/Pet.cs. Commands mutate the write model, such as backend/src/Volunteers/PetFamily.Volunteers.Application/Volunteers/Commands/AddPet/AddPetHandler.cs; paginated reads use handlers such as backend/src/Volunteers/PetFamily.Volunteers.Application/Volunteers/Queries/GetPetsWithPagination/GetPetsWithPaginationHandler.cs.
Species and discussions
Species/breeds are a separate reference-data module, exposed by backend/src/Species/PetFamily.Species.Presentation/Species/SpeciesController.cs and stored through distinct read/write contexts at backend/src/Species/PetFamily.Species.Infrastructure/DbContexts/SpeciesReadDbContext.cs and backend/src/Species/PetFamily.Species.Infrastructure/DbContexts/WriteSpeciesDbContext.cs. Discussions provide relation-scoped conversations with message editing/deletion and close operations; API entry is backend/src/Discussions/PetFamily.Discussions.Presentation/DiscussionsController.cs, domain state is backend/src/Discussions/PetFamily.Discussions.Domain/DiscussionManagement/Discussion.cs, and persistence likewise separates reads and writes.
Volunteer application workflow and asynchronous integration
Volunteer applications model submission, assignment/take, revision, approval, and rejection. The public boundary is backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Presentation/VolunteersApplicationsController.cs; approval behavior is in backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Application/VolunteersApplications/Commands/Approve/ApproveApplicationHandler.cs. Approval emits ApprovedApplicationEvent via a transactional outbox represented by backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Infrastructure/Outbox/OutboxMessage.cs and processed by backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Infrastructure/Outbox/ProcessOutboxMessagesJob.cs. Accounts consumes volunteer-registration events at backend/src/Accounts/PetFamily.Accounts.Infrastructure/Consumers/RegisterVolunteerConsumer.cs.
Persistence, files, and services
Entity Framework-style write/read persistence is evident across module-specific DbContexts, repositories, UnitOfWork implementations, and migrations. File APIs are exposed at backend/src/Files/PetFamily.Files.Presentation/FileController.cs; uploads, removal, and presigned access flow through backend/src/Files/PetFamily.Files.Application/Files/Upload/UploadFilesHandler.cs and backend/src/Files/PetFamily.Files.Application/Files/Presigned/PresignedFileHandler.cs. Object storage is abstracted by backend/src/Shared/PetFamily.Core/IFileProvider.cs and implemented with MinIO at backend/src/Volunteers/PetFamily.Volunteers.Infrastructure/Providers/MinioProvider.cs. A background cleaner (backend/src/Volunteers/PetFamily.Volunteers.Infrastructure/BackgroundServices/FilesCleanerBackgroundService.cs) removes queued obsolete files using an in-memory message queue.
Main entry points: Program.cs Web API host · LoginHandler.cs Account authentication · AddPetHandler.cs Volunteer and pet use cases · SpeciesController.cs Species API
Components 25
API Runtime
- Solution build
backend/backend.sln - Container deployment · Compose deploys the API behind Nginx.
backend/compose.yaml - Nginx
backend/nginx.conf - Web API host · Composes module dependency injection registrations.
backend/src/PetFamily.Web/Program.cs - Exception middleware
backend/src/PetFamily.Web/Middlewares/ExceptionMiddlware.cs - Command/query contracts
backend/src/Shared/PetFamily.Core/Abstractions/ICommand.cs
Business Modules
- Accounts API
backend/src/Accounts/PetFamily.Accounts.Presentation/AccountController.cs - Account authentication · Login and refresh-session workflows.
backend/src/Accounts/PetFamily.Accounts.Application/AccountsManagement/Commands/LoginUser/LoginHandler.cs - Identity and authorization · Persists accounts and supplies JWTs and dynamic permission policies.
backend/src/Accounts/PetFamily.Accounts.Infrastructure/AccountDbContext.cs - Volunteers API
backend/src/Volunteers/PetFamily.Volunteers.Presentation/VolunteersController.cs - Volunteer and pet use cases · Commands update pets; queries provide paginated reads.
backend/src/Volunteers/PetFamily.Volunteers.Application/Volunteers/Commands/AddPet/AddPetHandler.cs - Volunteer and pet model · Volunteers own pets and their lifecycle data.
backend/src/Volunteers/PetFamily.Volunteers.Domain/PetManagement/Volunteer.cs - Species API
backend/src/Species/PetFamily.Species.Presentation/Species/SpeciesController.cs - Discussions API
backend/src/Discussions/PetFamily.Discussions.Presentation/DiscussionsController.cs - Discussion model · Relation-scoped conversations support edits, deletion, and closure.
backend/src/Discussions/PetFamily.Discussions.Domain/DiscussionManagement/Discussion.cs - Applications API
backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Presentation/VolunteersApplicationsController.cs - Application approval · Approves applications and emits registration events.
backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Application/VolunteersApplications/Commands/Approve/ApproveApplicationHandler.cs - Files API
backend/src/Files/PetFamily.Files.Presentation/FileController.cs - File upload and access · Uploads, removal, and presigned-file access.
backend/src/Files/PetFamily.Files.Application/Files/Upload/UploadFilesHandler.cs
Persistence & Integration
- Species read store
backend/src/Species/PetFamily.Species.Infrastructure/DbContexts/SpeciesReadDbContext.cs - Species write store
backend/src/Species/PetFamily.Species.Infrastructure/DbContexts/WriteSpeciesDbContext.cs - Transactional outbox · Background job publishes approved-application events reliably.
backend/src/VolunteersApplications/PetFamily.VolunteersApplications.Infrastructure/Outbox/ProcessOutboxMessagesJob.cs - Volunteer registration consumer
backend/src/Accounts/PetFamily.Accounts.Infrastructure/Consumers/RegisterVolunteerConsumer.cs - MinIO object storage
backend/src/Volunteers/PetFamily.Volunteers.Infrastructure/Providers/MinioProvider.cs - Obsolete file cleaner · Removes queued obsolete files.
backend/src/Volunteers/PetFamily.Volunteers.Infrastructure/BackgroundServices/FilesCleanerBackgroundService.cs
Connections 26
- Solution build → Web API host: builds
- Container deployment → Nginx: deploys
- Nginx → Web API host: proxies requests
- Web API host → Exception middleware: uses
- Web API host → Accounts API: routes
- Web API host → Volunteers API: routes
- Web API host → Species API: routes
- Web API host → Discussions API: routes
- Web API host → Applications API: routes
- Web API host → Files API: routes
- Accounts API → Account authentication: invokes
- Account authentication → Command/query contracts: implements
- Account authentication → Identity and authorization: uses
- Volunteers API → Volunteer and pet use cases: invokes
- Volunteer and pet use cases → Command/query contracts: implements
- Volunteer and pet use cases → Volunteer and pet model: applies rules
- Species API → Species read store: queries
- Species API → Species write store: updates
- Discussions API → Discussion model: manages
- Applications API → Application approval: invokes
- Application approval → Transactional outbox: writes event
- Transactional outbox → Volunteer registration consumer: publishes registration event
- Volunteer registration consumer → Identity and authorization: creates volunteer account
- Files API → File upload and access: invokes
- File upload and access → MinIO object storage: stores and signs files
- Obsolete file cleaner → MinIO object storage: deletes obsolete files