Created
February 25, 2026 20:01
-
-
Save swaters86/3cdbb11791b402710bae53c9da2dd290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyCompany.MyProduct.Api/ | |
| ├── Features/ # Vertical slices grouped by business capability (preferred over Layers) | |
| │ ├── Billing/ # Business feature area: billing transactions, adjustments, etc. | |
| │ │ ├── CreateBillingTransaction/ # Single use case slice (Command) | |
| │ │ │ ├── CreateBillingTransactionCommand.cs # MediatR request (input for the use case) | |
| │ │ │ ├── CreateBillingTransactionValidator.cs # FluentValidation/input validation for command | |
| │ │ │ ├── CreateBillingTransactionHandler.cs # Use case logic; calls repo/db abstractions, maps result | |
| │ │ │ ├── CreateBillingTransactionRequest.cs # API request model (controller-facing model) if separate from command | |
| │ │ │ ├── CreateBillingTransactionResponse.cs # API response model / DTO for endpoint response | |
| │ │ │ └── Sql/ # SQL for this use case if feature-specific | |
| │ │ │ ├── InsertBillingTransaction.sql | |
| │ │ │ └── CheckDuplicateByHash.sql | |
| │ │ ├── GetBillingTransactionById/ # Single use case slice (Query) | |
| │ │ │ ├── GetBillingTransactionByIdQuery.cs | |
| │ │ │ ├── GetBillingTransactionByIdHandler.cs | |
| │ │ │ ├── GetBillingTransactionByIdResponse.cs | |
| │ │ │ └── Sql/ | |
| │ │ │ └── SelectBillingTransactionById.sql | |
| │ │ ├── SearchBillingTransactions/ # List/search query use case | |
| │ │ └── Common/ # Billing-specific shared types (enums, mappers, constants) | |
| │ │ | |
| │ ├── Returns/ # Another feature area | |
| │ │ ├── CreateReturn/ | |
| │ │ ├── GetReturn/ | |
| │ │ └── Common/ | |
| │ │ | |
| │ ├── Discounts/ # Another feature area | |
| │ │ ├── CreateDiscount/ | |
| │ │ ├── ListDiscounts/ | |
| │ │ └── Common/ | |
| │ │ | |
| │ ├── Integrations/ # Integration-related features (enrollment, pulls, hashes, dedupe) | |
| │ │ ├── EnrollAgent/ | |
| │ │ ├── SubmitRawPayload/ | |
| │ │ ├── ReprocessBatch/ | |
| │ │ ├── GetPullStatus/ | |
| │ │ └── Common/ | |
| │ │ | |
| │ └── Health/ # App-specific health/status endpoints (if business-related) | |
| │ └── GetSystemStatus/ | |
| │ | |
| ├── Controllers/ # Thin MVC controllers (API Controllers, not minimal APIs) | |
| │ ├── BillingController.cs # Route + HTTP concerns only; delegates to MediatR | |
| │ ├── ReturnsController.cs | |
| │ ├── DiscountsController.cs | |
| │ ├── IntegrationsController.cs | |
| │ └── HealthController.cs | |
| │ | |
| ├── Infrastructure/ # Technical implementations (db, auth, files, messaging, etc.) | |
| │ ├── Persistence/ # Data access and DB concerns | |
| │ │ ├── Connections/ | |
| │ │ │ ├── IDbConnectionFactory.cs # Factory abstraction for opening DB connections | |
| │ │ │ └── SqlConnectionFactory.cs # Dapper/SQL Server implementation | |
| │ │ ├── Dapper/ # Dapper helpers and conventions | |
| │ │ │ ├── SqlRunner.cs # Wrapper for Query/Execute patterns, logging, retries (optional) | |
| │ │ │ ├── SqlParameterBuilder.cs # Optional helper for parameter consistency | |
| │ │ │ └── TypeHandlers/ # Dapper custom type handlers (DateOnly, enums, JSON, etc.) | |
| │ │ ├── Repositories/ # Shared repositories only (avoid generic repo overuse) | |
| │ │ │ ├── IBillingReadRepository.cs | |
| │ │ │ ├── BillingReadRepository.cs | |
| │ │ │ └── ... | |
| │ │ ├── Sql/ # Shared SQL scripts used across features (optional) | |
| │ │ └── Migrations/ # SQL migrations (if not in separate migrator project) | |
| │ │ | |
| │ ├── Authentication/ # JWT, Cognito/Entra, policies, auth handlers | |
| │ │ ├── Jwt/ | |
| │ │ ├── Policies/ | |
| │ │ └── ApiKey/ # If used for agent enrollment/bootstrap only | |
| │ │ | |
| │ ├── Observability/ # Logging, tracing, metrics enrichers | |
| │ │ ├── LoggingScopes/ | |
| │ │ ├── Telemetry/ | |
| │ │ └── Correlation/ | |
| │ │ | |
| │ ├── Messaging/ # Queue/event bus implementations if applicable | |
| │ ├── Files/ # File storage, blob clients, etc. | |
| │ └── Time/ # System clock implementation (ITimeProvider) | |
| │ | |
| ├── Application/ # Cross-feature app-layer concerns (still thin in vertical slice) | |
| │ ├── Behaviors/ # MediatR pipeline behaviors (cross-cutting) | |
| │ │ ├── ValidationBehavior.cs # Runs validators before handlers | |
| │ │ ├── LoggingBehavior.cs # Request/response logging | |
| │ │ ├── PerformanceBehavior.cs # Timing/metrics | |
| │ │ ├── TransactionBehavior.cs # DB transaction boundary (when needed) | |
| │ │ ├── IdempotencyBehavior.cs # Request dedupe / replay safety (great for ingestion) | |
| │ │ └── ExceptionHandlingBehavior.cs # Maps/normalizes exceptions | |
| │ │ | |
| │ ├── Abstractions/ # Interfaces shared across features (e.g., IHashService, ICurrentUser) | |
| │ ├── Common/ # Result<T>, error models, paging, sort, filters, etc. | |
| │ ├── Mapping/ # Shared mapping profiles/extensions (if not feature-local) | |
| │ └── Validation/ # Shared validation helpers/rules | |
| │ | |
| ├── Domain/ # Domain entities/value objects/business rules (if your app benefits from it) | |
| │ ├── Entities/ # Rich entities (only if you truly have domain behavior) | |
| │ ├── ValueObjects/ # Money, TransactionHash, DateRange, etc. | |
| │ ├── Enums/ # Domain enums (PaymentType, AdjustmentType, etc.) | |
| │ ├── Events/ # Domain events (optional) | |
| │ └── Services/ # Domain services (pure business logic, no infrastructure) | |
| │ | |
| ├── Endpoints/ # Optional: endpoint metadata conventions, route constants | |
| │ └── RouteNames.cs | |
| │ | |
| ├── Middleware/ # ASP.NET middleware (exception handling, correlation, etc.) | |
| │ ├── ExceptionHandlingMiddleware.cs | |
| │ ├── CorrelationIdMiddleware.cs | |
| │ └── RequestBodyBufferingMiddleware.cs # If needed for canonical hashing/idempotency | |
| │ | |
| ├── Filters/ # MVC filters (if using controller filters instead of middleware) | |
| │ ├── ValidateModelFilter.cs | |
| │ └── ApiExceptionFilter.cs | |
| │ | |
| ├── Authorization/ # Policy names, requirement handlers (if not under Infrastructure/Auth) | |
| │ ├── Policies.cs | |
| │ ├── Requirements/ | |
| │ └── Handlers/ | |
| │ | |
| ├── Configuration/ # Options classes and DI setup by concern | |
| │ ├── DependencyInjection/ | |
| │ │ ├── ApiServiceCollectionExtensions.cs # High-level registration entry point | |
| │ │ ├── MediatRServiceCollectionExtensions.cs | |
| │ │ ├── DapperServiceCollectionExtensions.cs | |
| │ │ ├── AuthenticationServiceCollectionExtensions.cs | |
| │ │ └── SwaggerServiceCollectionExtensions.cs | |
| │ ├── Options/ | |
| │ │ ├── DatabaseOptions.cs | |
| │ │ ├── AuthOptions.cs | |
| │ │ └── ... | |
| │ └── StartupValidation/ # Validates options/config at startup | |
| │ | |
| ├── Contracts/ # API-wide request/response models (only truly shared ones) | |
| │ ├── Errors/ | |
| │ │ ├── ProblemDetailsExtensions.cs | |
| │ │ └── ApiErrorResponse.cs | |
| │ ├── Pagination/ | |
| │ └── Common/ | |
| │ | |
| ├── OpenApi/ # Swagger examples, operation filters, schema filters | |
| │ ├── Examples/ | |
| │ ├── OperationFilters/ | |
| │ └── SchemaFilters/ | |
| │ | |
| ├── Properties/ # launchSettings.json etc. | |
| ├── appsettings.json # Base config | |
| ├── appsettings.Development.json # Dev config | |
| ├── Program.cs # Composition root (DI, middleware, MVC, auth, swagger) | |
| └── GlobalUsings.cs # Global using directives (optional) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment