@@ -239,95 +239,99 @@ MatchFlow delivers real, measurable value by automating repetitive finance tasks
239239
240240
241241<a id =" architecture " ></a >
242- ## Architecture
242+ ## Architecture
243243
244- [ ![ Architecture Diagram ] ( /frontend/public/ architecture.svg )] ( /frontend/public/architecture.svg )
244+ MatchFlow’s architecture is described in two C4-style component views plus a layer breakdown:
245245
246- [ View on Eraser![ ] ( https://app.eraser.io/workspace/1wX2yEL4ckFloMZ5chjD/preview?elements=22osCHEEW3uJF1qCVzKzKQ&type=embed )] ( https://app.eraser.io/workspace/1wX2yEL4ckFloMZ5chjD?elements=22osCHEEW3uJF1qCVzKzKQ )
246+ 1 . ** System Context & High-Level Components**
247+ 2 . ** Detailed Clean-Architecture Components**
248+ 3 . ** Layer-by-Layer Breakdown**
247249
248- MatchFlow is built on Clean Architecture principles, with clear separation of concerns across six horizontal layers. Requests flow from left to right (and back), while dependencies always point inward toward the core Domain layer. Below is a breakdown of each layer, the major components within it, and the primary data flows.
250+ ---
249251
250- ### 1. Client Layer
251- - ** Browser (React SPA)**
252- - Contains ten page components:
253- AuthPage, LandingPage, CreatePOPage, PurchaseOrdersPage, PurchaseOrderDetailsPage, DashboardPage, InvoicePage, AutoMatchPage, UploadInvoicePage, and UploadResultPage.
254- - Sends and receives JWT-protected HTTPS calls to the Nginx proxy.
255-
256- ### 2. Presentation Layer
257- - ** Nginx Reverse Proxy** (Fly.io container “React+Nginx”)
258- - Terminates TLS, serves the React bundle, and forwards API requests.
259- - ** API Gateway** (.NET 6 Web API, Fly.io container “Backend”)
260- - Hosts all controllers and orchestrates application logic.
261- - ** Redirector** (Fly.io container)
262- - Routes requests from ` matchflow.app ` → ` www.matchflow.app ` .
263-
264- ### 3. Controller Layer
265- _ All running inside the API Gateway container:_
266- - ** AuthController** (handles login, JWT issuance & validation)
267- - ** PurchaseOrderListController**
268- - ** InvoiceListController**
269- - ** InvoiceMatchController**
270- - ** InvoiceUploadController**
271-
272- ### 4. Application Layer
273- - ** Services** (use-case implementations):
274- - ` CreatePurchaseOrderService `
275- - ` MatchingService `
276- - ` UploadInvoiceService `
277- - ` JWT Issuance & Validation ` (via UserService)
278- - ** Ports / Interfaces** (abstractions for infrastructure):
279- - ` IInvoiceRepository ` , ` IPurchaseOrderRepository `
280- - ` IFormRecognizer ` , ` IBlobStorage `
281- - ` IExceptionRecordRepository ` , ` IServiceBusClient ` , ` IUserService `
282- - Dependencies are injected here, following the Dependency Inversion Principle.
283-
284- ### 5. Infrastructure Layer
285- _ Concrete implementations of all ports:_
286- - ** EF Core Repositories** : ` InvoiceRepository ` , ` PurchaseOrderRepository ` , ` ExceptionRecordRepository ` , backed by ` AppDbContext `
287- - ** Azure Clients** : ` BlobStorageService ` , ` FormRecognizerClient ` , ` ServiceBusClient `
288- - ** UserService** (JWT key management & refresh logic)
289-
290- ### 6. Domain Layer
291- _ Pure business entities with no external dependencies:_
292- - ` Invoice ` , ` PurchaseOrder ` , ` InvoiceLineItem ` , ` PurchaseOrderLineItem ` , ` ExceptionRecord ` , ` User `
293-
294- ### Cloud Services
295- - ** Azure Blob Storage** (PDF persistence)
296- - ** Azure Form Recognizer** (OCR)
297- - ** Azure SQL Database** (POs, invoices, audit logs)
298- - ** Azure Service Bus** (discrepancy messaging)
299- - ** Application Insights** (telemetry & logging)
300-
301- ### Local Development
302- - ** Docker Compose** spins up all containers (React+Nginx, API, SQL emulator, Blob emulator, etc.) for end-to-end testing without Azure.
252+ ### 1. System Context & High-Level Components
253+ * Who uses the system and the major “boxes” it interacts with*
303254
304- ---
255+ ![ System Context Diagram] ( /frontend/public/context_diagram.png )
256+ ![ High-Level Component Diagram] ( /frontend/public/component_diagram.png )
305257
306- ### Primary Data Flows
307-
308- 1 . ** User Upload**
309- Browser → Nginx (HTTPS + JWT) → API Gateway
310- 2 . ** Invoice Processing**
311- ` UploadInvoiceController ` → UploadInvoiceService
312- → BlobStorageService → Azure Blob (POST PDF)
313- → FormRecognizerClient → Azure Form Recognizer (extract JSON)
314- 3 . ** Matching Logic**
315- ` UploadInvoiceService ` → MatchingService → EF Repositories → Azure SQL
316- 4 . ** Discrepancy Handling**
317- On mismatch, UploadInvoiceService → ServiceBusClient → Azure Service Bus
318- Front-end polls/subscribes for results
319- 5 . ** Telemetry**
320- All API calls and repository operations log to Application Insights
258+ - ** Users** (Invoice Managers) in their browser
259+ - ** React SPA + Nginx** (Fly.io container “React+Nginx”): serves UI, terminates TLS, forwards API calls
260+ - ** .NET 6 API Gateway** (Fly.io container “Backend”): hosts all Controllers and Services
261+ - ** Redirector** (Fly.io): 301-redirects ` matchflow.app ` → ` www.matchflow.app `
262+ - ** Azure Cloud Services** :
263+ - Blob Storage (PDF persistence)
264+ - Form Recognizer (OCR)
265+ - SQL Database (POs, invoices, audit logs)
266+ - Service Bus (discrepancy messaging)
267+ - Application Insights (telemetry & logging)
321268
322269---
323270
324- By following Clean Architecture, MatchFlow achieves high testability, clear module boundaries, and the ability to swap out or mock any external dependency (databases, cloud services, UI) without impacting the business core.
271+ ### 2. Detailed Clean-Architecture Components
272+ * Internal layering and dependencies*
325273
274+ ![ Detailed Architecture Diagram] ( /frontend/public/architecture.svg )
275+ [ View on Eraser![ ] ( https://app.eraser.io/workspace/1wX2yEL4ckFloMZ5chjD/preview?elements=22osCHEEW3uJF1qCVzKzKQ&type=embed )] ( https://app.eraser.io/workspace/1wX2yEL4ckFloMZ5chjD?elements=22osCHEEW3uJF1qCVzKzKQ )
276+
277+ - ** Controllers**
278+ - AuthController, PurchaseOrderListController, InvoiceListController, InvoiceMatchController, InvoiceUploadController
279+ - ** Application Services (Use-Cases)**
280+ - CreatePurchaseOrderService
281+ - MatchingService
282+ - UploadInvoiceService
283+ - JWT issuance & validation via UserService
284+ - ** Ports / Interfaces**
285+ - IInvoiceRepository, IPurchaseOrderRepository
286+ - IFormRecognizer, IBlobStorage
287+ - IExceptionRecordRepository, IServiceBusClient, IUserService
288+ - ** Infrastructure**
289+ - EF Core Repositories: InvoiceRepository, PurchaseOrderRepository, ExceptionRecordRepository (via AppDbContext)
290+ - Azure SDK Clients: BlobStorageService, FormRecognizerClient, ServiceBusClient
291+ - UserService (JWT key management & refresh logic)
292+ - ** Domain Entities**
293+ - Invoice, PurchaseOrder, InvoiceLineItem, PurchaseOrderLineItem, ExceptionRecord, User
326294
327- ![ Context Diagram] ( /frontend/public/context_diagram.png )
328- ![ Context Diagram] ( /frontend/public/component_diagram.png )
295+ ---
329296
297+ ### 3. Layer-by-Layer Breakdown
330298
299+ #### Client Layer
300+ - ** Browser (React SPA)**
301+ - Pages: AuthPage, LandingPage, CreatePOPage, PurchaseOrdersPage, PurchaseOrderDetailsPage, DashboardPage, InvoicePage, AutoMatchPage, UploadInvoicePage, UploadResultPage
302+ - Communicates over HTTPS+JWT with Nginx
303+
304+ #### Presentation Layer
305+ - ** Nginx Reverse Proxy**
306+ - TLS termination, static-file serving, API forwarding
307+ - ** Redirector**
308+ - 301 redirects apex domain → ` www `
309+
310+ #### Controller Layer
311+ _ All inside the .NET API Gateway container_
312+ - AuthController
313+ - PurchaseOrderListController
314+ - InvoiceListController
315+ - InvoiceMatchController
316+ - InvoiceUploadController
317+
318+ #### Application Layer
319+ - ** Use-Case Services**
320+ - CreatePurchaseOrderService
321+ - MatchingService
322+ - UploadInvoiceService
323+ - ** Dependency-Inverted Ports**
324+ - IInvoiceRepository, IPurchaseOrderRepository, IFormRecognizer, IBlobStorage, IExceptionRecordRepository, IServiceBusClient, IUserService
325+
326+ #### Infrastructure Layer
327+ - ** EF Core Repositories** (Invoice, PO, ExceptionRecord)
328+ - ** Azure SDK Clients** (BlobStorage, FormRecognizer, ServiceBus)
329+ - ** UserService** (JWT management)
330+
331+ #### Domain Layer
332+ - Plain C# business entities: Invoice, PurchaseOrder, InvoiceLineItem, PurchaseOrderLineItem, ExceptionRecord, User
333+
334+
331335
332336## Screenshots
333337### Authentication
0 commit comments