Here's a comprehensive folder structure for a Lost and Found backend service using DDD principles with ASP.NET:
LostAndFound.Solution/
├── src/
│ ├── LostAndFound.Domain/
│ │ ├── Entities/
│ │ │ ├── Item.cs
│ │ │ ├── User.cs
│ │ │ ├── QRCode.cs
│ │ │ └── Location.cs
│ │ ├── ValueObjects/
│ │ │ ├── ItemDescription.cs
│ │ │ ├── ContactInfo.cs
│ │ │ └── QRCodeData.cs
│ │ ├── Aggregates/
│ │ │ ├── ItemAggregate/
│ │ │ │ ├── Item.cs (Aggregate Root)
│ │ │ │ ├── ItemStatus.cs
│ │ │ │ └── ItemEvents.cs
│ │ │ └── UserAggregate/
│ │ │ ├── User.cs (Aggregate Root)
│ │ │ └── UserProfile.cs
│ │ ├── DomainServices/
│ │ │ ├── QRCodeGenerationService.cs
│ │ │ └── ItemMatchingService.cs
│ │ ├── Repositories/
│ │ │ ├── IItemRepository.cs
│ │ │ ├── IUserRepository.cs
│ │ │ └── IQRCodeRepository.cs
│ │ ├── Events/
│ │ │ ├── ItemFoundEvent.cs
│ │ │ ├── ItemClaimedEvent.cs
│ │ │ └── QRCodeScannedEvent.cs
│ │ └── Exceptions/
│ │ ├── ItemNotFoundException.cs
│ │ └── InvalidQRCodeException.cs
│ │
│ ├── LostAndFound.Application/
│ │ ├── Commands/
│ │ │ ├── Items/
│ │ │ │ ├── CreateLostItemCommand.cs
│ │ │ │ ├── CreateFoundItemCommand.cs
│ │ │ │ └── ClaimItemCommand.cs
│ │ │ └── QRCodes/
│ │ │ ├── GenerateQRCodeCommand.cs
│ │ │ └── ScanQRCodeCommand.cs
│ │ ├── Queries/
│ │ │ ├── Items/
│ │ │ │ ├── GetLostItemsQuery.cs
│ │ │ │ ├── GetFoundItemsQuery.cs
│ │ │ │ └── GetItemByIdQuery.cs
│ │ │ └── QRCodes/
│ │ │ └── GetQRCodeDataQuery.cs
│ │ ├── Handlers/
│ │ │ ├── CommandHandlers/
│ │ │ │ ├── CreateLostItemHandler.cs
│ │ │ │ ├── ScanQRCodeHandler.cs
│ │ │ │ └── ClaimItemHandler.cs
│ │ │ └── QueryHandlers/
│ │ │ ├── GetLostItemsHandler.cs
│ │ │ └── GetQRCodeDataHandler.cs
│ │ ├── DTOs/
│ │ │ ├── ItemDto.cs
│ │ │ ├── QRCodeDto.cs
│ │ │ └── UserDto.cs
│ │ ├── Services/
│ │ │ ├── INotificationService.cs
│ │ │ ├── IImageProcessingService.cs
│ │ │ └── IQRCodeService.cs
│ │ └── Validators/
│ │ ├── CreateItemValidator.cs
│ │ └── QRCodeValidator.cs
│ │
│ ├── LostAndFound.Infrastructure/
│ │ ├── Data/
│ │ │ ├── LostAndFoundDbContext.cs
│ │ │ ├── Configurations/
│ │ │ │ ├── ItemConfiguration.cs
│ │ │ │ ├── UserConfiguration.cs
│ │ │ │ └── QRCodeConfiguration.cs
│ │ │ └── Migrations/
│ │ ├── Repositories/
│ │ │ ├── ItemRepository.cs
│ │ │ ├── UserRepository.cs
│ │ │ └── QRCodeRepository.cs
│ │ ├── Services/
│ │ │ ├── QRCodeService.cs
│ │ │ ├── NotificationService.cs
│ │ │ ├── ImageProcessingService.cs
│ │ │ └── EmailService.cs
│ │ ├── External/
│ │ │ ├── QRCodeLibrary/
│ │ │ └── CloudStorage/
│ │ └── DependencyInjection.cs
│ │
│ └── LostAndFound.API/
│ ├── Controllers/
│ │ ├── ItemsController.cs
│ │ ├── QRCodesController.cs
│ │ └── UsersController.cs
│ ├── Middleware/
│ │ ├── ExceptionHandlingMiddleware.cs
│ │ └── QRCodeValidationMiddleware.cs
│ ├── Filters/
│ │ └── ValidationFilter.cs
│ ├── Models/
│ │ ├── Requests/
│ │ │ ├── CreateItemRequest.cs
│ │ │ └── ScanQRCodeRequest.cs
│ │ └── Responses/
│ │ ├── ItemResponse.cs
│ │ └── QRCodeResponse.cs
│ ├── Configuration/
│ │ ├── SwaggerConfiguration.cs
│ │ └── CorsConfiguration.cs
│ ├── Program.cs
│ └── appsettings.json
│
├── tests/
│ ├── LostAndFound.Domain.Tests/
│ ├── LostAndFound.Application.Tests/
│ ├── LostAndFound.Infrastructure.Tests/
│ └── LostAndFound.API.Tests/
│
└── docs/
├── api-documentation.md
└── qr-code-specification.md
Design Rationale
Domain Layer: Contains the core business logic with clear separation between entities, value objects, and aggregates. The Item aggregate manages the lifecycle of lost/found items, while QR codes are treated as entities with their own behavior. Domain services handle complex business operations like QR code generation and item matching algorithms.
Application Layer: Implements CQRS pattern with separate commands and queries, making the system more scalable and maintainable. Handlers encapsulate business use cases like scanning QR codes, creating items, and claiming found items. DTOs provide clean data contracts between layers.
Infrastructure Layer: Handles all external concerns including database access, QR code generation libraries, notification services, and image processing. The repository pattern abstracts data access, while services implement technical capabilities like email notifications and cloud storage integration.
API Layer: Provides RESTful endpoints with proper separation of concerns. Controllers are thin and delegate to application handlers. Request/response models ensure clean API contracts, while middleware handles cross-cutting concerns like exception handling and QR code validation.
Testing Structure: Mirrors the main project structure, enabling comprehensive unit and integration testing across all layers.
This structure supports the QR code scanning workflow where users can scan codes to report found items, generate QR codes for lost items, and facilitate the matching process between lost and found items. The DDD approach ensures the business logic remains clean and testable while supporting the specific requirements of a lost and found service.