# jgmelon22/miniofileprocessor architecture

> Architecture diagram of the GitHub repository jgmelon22/miniofileprocessor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jgmelon22/miniofileprocessor
- Repository: https://github.com/jgmelon22/miniofileprocessor

## Overview

#### Purpose and Runtime

System A is a .NET HTTP API that accepts CSV uploads, performs lightweight admission validation, stores the file in S3-compatible object storage, persists import metadata in MySQL, and emits a Kafka notification for asynchronous processing by System B. The solution entry point is `FileUploaderPartA.sln`; API startup is `src/FileUploaderPartA.API/Program.cs`.

#### API Boundary

`ImportsController` is the inbound HTTP boundary for import creation. It receives upload requests and delegates work through the application layer rather than directly accessing storage or persistence.

- `src/FileUploaderPartA.API/Controllers/ImportsController.cs`
- `src/FileUploaderPartA.API/Program.cs`
- `src/FileUploaderPartA.API/Extensions/IocExtensions.cs`

Swagger is part of the API runtime/documentation surface, as indicated by the README and API project.

#### Application Command Orchestration

Import submission is modeled as a create command and handler. The handler coordinates validation, object upload, metadata creation/persistence, and Kafka publication through abstractions supplied by infrastructure DI.

- `src/FileUploaderPartA.Application/Imports/Commands/CreateImportCommand.cs`
- `src/FileUploaderPartA.Application/Imports/Commands/Handlers/CreateImportCommandHandler.cs`
- `src/FileUploaderPartA.Application/FileUploaderPartA.Application.csproj`

This is the primary control-flow boundary between HTTP transport and business workflow.

#### Domain Model and Validation Gate

The core defines the import entity, request DTO, lifecycle status, mapping logic, and shared result semantics. Validation intentionally remains shallow and synchronous: CSV MIME type, expected header structure, and maximum 7 MB size. Full row-level/business processing is deferred to System B.

- `src/FileUploaderPartA.Core/Domains/Imports/Entities/Import.cs`
- `src/FileUploaderPartA.Core/Domains/Imports/Enums/Status.cs`
- `src/FileUploaderPartA.Core/Shared/Validations/ FileValidations/CsvValidations.cs`

The stored `Status` supports downstream idempotency/processing checks.

#### Object Storage Boundary

Files are uploaded through an S3 service abstraction and implementation. Configuration names Amazon S3, while the deployed/local target is MinIO, which exposes an S3-compatible API. The persisted import record retains the resulting storage path rather than file contents.

- `src/FileUploaderPartA.Infrastructure/Interfaces/Services/IS3Service.cs`
- `src/FileUploaderPartA.Infrastructure/Services/S3Service.cs`
- `src/FileUploaderPartA.Infrastructure/Configurations/AmazonS3Configuration.cs`

#### Persistence Boundary

MySQL stores import metadata and processing status. The infrastructure uses Dapper via a database context and an import-specific repository interface/implementation, keeping SQL persistence outside the domain and application workflow.

- `src/FileUploaderPartA.Infrastructure/Data/DapperDbContext.cs`
- `src/FileUploaderPartA.Infrastructure/Interfaces/Repository/IImportRepository.cs`
- `src/FileUploaderPartA.Infrastructure/Repositories/ImportRepository.cs`

#### Event Publication and Downstream Handoff

After upload and metadata persistence, the application publishes an import event through Kafka. System B consumes the topic, checks the database status, and processes file content asynchronously. This decouples costly CSV processing from request latency, but makes storage, database persistence, and message publication a multi-system consistency boundary.

- `src/FileUploaderPartA.Infrastructure/Interfaces/Services/IKafkaProducerService.cs`
- `src/FileUploaderPartA.Infrastructure/Services/KafkaProducerService.cs`
- `src/FileUploaderPartA.Infrastructure/Configurations/KafkaConfiguration.cs`

Main entry points: [`src/FileUploaderPartA.Application/Imports/Commands/Handlers/CreateImportCommandHandler.cs`](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Application/Imports/Commands/Handlers/CreateImportCommandHandler.cs) (Create Import Handler), [`src/FileUploaderPartA.API/Extensions/IocExtensions.cs`](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Extensions/IocExtensions.cs) (IoC Extensions), [`src/FileUploaderPartA.Infrastructure/Services/S3Service.cs`](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Services/S3Service.cs) (S3 Service), [`src/FileUploaderPartA.Infrastructure/Repositories/ImportRepository.cs`](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Repositories/ImportRepository.cs) (Import Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Runtime"]
  node_startup["API Startup &amp; DI<br/>.NET host<br/>[Program.cs]"]
  node_ioc["IoC Extensions<br/>DI registration<br/>[IocExtensions.cs]"]
  node_imports_controller["Imports Controller<br/>HTTP controller"]
end

subgraph group_application["Application"]
  node_create_command["Create Import Command"]
  node_create_handler["Create Import Handler<br/>command handler"]
end

subgraph group_core["Core Domain"]
  node_import_domain["Import Entity &amp; Status<br/>domain model<br/>[Import.cs]"]
  node_csv_validation["CSV Admission Validation<br/>[CsvValidations.cs]"]
end

subgraph group_infrastructure["Infrastructure"]
  node_s3_service["S3 Service<br/>storage adapter<br/>[S3Service.cs]"]
  node_s3_contract["S3 Service Contract<br/>service interface<br/>[IS3Service.cs]"]
  node_dapper_context["Dapper DB Context<br/>database access<br/>[DapperDbContext.cs]"]
  node_import_repository["Import Repository"]
  node_repository_contract["Import Repository Contract<br/>repository interface"]
  node_kafka_producer["Kafka Producer<br/>event adapter"]
  node_kafka_contract["Kafka Producer Contract<br/>service interface"]
end

subgraph group_external["External Systems"]
  node_object_storage[("MinIO / S3 Storage<br/>object storage")]
  node_mysql[("MySQL<br/>metadata database")]
  node_kafka["Kafka Topic<br/>event stream"]
  node_system_b["System B<br/>downstream processor"]
end

node_startup -->|"loads registrations"| node_ioc
node_startup -->|"hosts"| node_imports_controller
node_ioc -.->|"binds"| node_create_handler
node_ioc -.->|"binds"| node_s3_service
node_ioc -.->|"binds"| node_import_repository
node_ioc -.->|"binds"| node_kafka_producer
node_imports_controller -->|"creates"| node_create_command
node_create_command -->|"handled by"| node_create_handler
node_create_handler -->|"validates"| node_csv_validation
node_create_handler -->|"creates metadata"| node_import_domain
node_create_handler -->|"uploads file"| node_s3_contract
node_s3_contract -.->|"implemented by"| node_s3_service
node_s3_service -->|"stores object"| node_object_storage
node_create_handler -->|"persists metadata"| node_repository_contract
node_repository_contract -.->|"implemented by"| node_import_repository
node_import_repository -->|"uses"| node_dapper_context
node_dapper_context -->|"writes"| node_mysql
node_create_handler -->|"publishes import event"| node_kafka_contract
node_kafka_contract -.->|"implemented by"| node_kafka_producer
node_kafka_producer -->|"produces"| node_kafka
node_kafka -->|"consumed by"| node_system_b
node_system_b -.->|"checks status"| node_mysql
node_system_b -.->|"reads CSV"| node_object_storage

click node_startup "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Program.cs"
click node_ioc "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Extensions/IocExtensions.cs"
click node_imports_controller "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Controllers/ImportsController.cs"
click node_create_command "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Application/Imports/Commands/CreateImportCommand.cs"
click node_create_handler "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Application/Imports/Commands/Handlers/CreateImportCommandHandler.cs"
click node_import_domain "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Core/Domains/Imports/Entities/Import.cs"
click node_csv_validation "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Core/Shared/Validations/%20FileValidations/CsvValidations.cs"
click node_s3_service "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Services/S3Service.cs"
click node_s3_contract "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Interfaces/Services/IS3Service.cs"
click node_dapper_context "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Data/DapperDbContext.cs"
click node_import_repository "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Repositories/ImportRepository.cs"
click node_repository_contract "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Interfaces/Repository/IImportRepository.cs"
click node_kafka_producer "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Services/KafkaProducerService.cs"
click node_kafka_contract "https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Interfaces/Services/IKafkaProducerService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_ioc,node_imports_controller toneBlue
class node_create_command,node_create_handler toneAmber
class node_import_domain,node_csv_validation toneMint
class node_s3_service,node_s3_contract,node_dapper_context,node_import_repository,node_repository_contract,node_kafka_producer,node_kafka_contract toneRose
class node_object_storage,node_mysql,node_kafka,node_system_b toneIndigo
```

## Components

### API Runtime

- [API Startup & DI](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Program.cs): .NET host · Configures HTTP runtime, Swagger, and infrastructure bindings. · `src/FileUploaderPartA.API/Program.cs`
- [IoC Extensions](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Extensions/IocExtensions.cs): DI registration · `src/FileUploaderPartA.API/Extensions/IocExtensions.cs`
- [Imports Controller](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.API/Controllers/ImportsController.cs): HTTP controller · Inbound endpoint for CSV import creation. · `src/FileUploaderPartA.API/Controllers/ImportsController.cs`

### Application

- [Create Import Command](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Application/Imports/Commands/CreateImportCommand.cs): command · `src/FileUploaderPartA.Application/Imports/Commands/CreateImportCommand.cs`
- [Create Import Handler](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Application/Imports/Commands/Handlers/CreateImportCommandHandler.cs): command handler · Coordinates validation, upload, persistence, and event publication. · `src/FileUploaderPartA.Application/Imports/Commands/Handlers/CreateImportCommandHandler.cs`

### Core Domain

- [Import Entity & Status](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Core/Domains/Imports/Entities/Import.cs): domain model · Metadata includes storage path and processing lifecycle status. · `src/FileUploaderPartA.Core/Domains/Imports/Entities/Import.cs`
- [CSV Admission Validation](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Core/Shared/Validations/%20FileValidations/CsvValidations.cs): validation · Checks MIME type, header structure, and 7 MB maximum size. · `src/FileUploaderPartA.Core/Shared/Validations/ FileValidations/CsvValidations.cs`

### Infrastructure

- [S3 Service](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Services/S3Service.cs): storage adapter · Uploads files through the S3 abstraction. · `src/FileUploaderPartA.Infrastructure/Services/S3Service.cs`
- [S3 Service Contract](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Interfaces/Services/IS3Service.cs): service interface · `src/FileUploaderPartA.Infrastructure/Interfaces/Services/IS3Service.cs`
- [Dapper DB Context](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Data/DapperDbContext.cs): database access · `src/FileUploaderPartA.Infrastructure/Data/DapperDbContext.cs`
- [Import Repository](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Repositories/ImportRepository.cs): repository · Persists import metadata and status. · `src/FileUploaderPartA.Infrastructure/Repositories/ImportRepository.cs`
- [Import Repository Contract](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Interfaces/Repository/IImportRepository.cs): repository interface · `src/FileUploaderPartA.Infrastructure/Interfaces/Repository/IImportRepository.cs`
- [Kafka Producer](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Services/KafkaProducerService.cs): event adapter · Publishes the import notification after persistence. · `src/FileUploaderPartA.Infrastructure/Services/KafkaProducerService.cs`
- [Kafka Producer Contract](https://github.com/jgmelon22/miniofileprocessor/blob/main/src/FileUploaderPartA.Infrastructure/Interfaces/Services/IKafkaProducerService.cs): service interface · `src/FileUploaderPartA.Infrastructure/Interfaces/Services/IKafkaProducerService.cs`

### External Systems

- **MinIO / S3 Storage**: object storage · S3-compatible file storage.
- **MySQL**: metadata database · Stores import metadata and processing status.
- **Kafka Topic**: event stream · Asynchronous handoff for import processing.
- **System B**: downstream processor · Consumes events, checks status, and processes CSV rows.

## Connections

- API Startup & DI → IoC Extensions: loads registrations
- API Startup & DI → Imports Controller: hosts
- IoC Extensions → Create Import Handler: binds
- IoC Extensions → S3 Service: binds
- IoC Extensions → Import Repository: binds
- IoC Extensions → Kafka Producer: binds
- Imports Controller → Create Import Command: creates
- Create Import Command → Create Import Handler: handled by
- Create Import Handler → CSV Admission Validation: validates
- Create Import Handler → Import Entity & Status: creates metadata
- Create Import Handler → S3 Service Contract: uploads file
- S3 Service Contract → S3 Service: implemented by
- S3 Service → MinIO / S3 Storage: stores object
- Create Import Handler → Import Repository Contract: persists metadata
- Import Repository Contract → Import Repository: implemented by
- Import Repository → Dapper DB Context: uses
- Dapper DB Context → MySQL: writes
- Create Import Handler → Kafka Producer Contract: publishes import event
- Kafka Producer Contract → Kafka Producer: implemented by
- Kafka Producer → Kafka Topic: produces
- Kafka Topic → System B: consumed by
- System B → MySQL: checks status
- System B → MinIO / S3 Storage: reads CSV
