Skip to content

Commit 4a4407e

Browse files
committed
add Architecture section to README
1 parent f1846be commit 4a4407e

2 files changed

Lines changed: 111 additions & 0 deletions

File tree

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,85 @@ MatchFlow delivers real, measurable value by automating repetitive finance tasks
101101
- 🔄 **CI/CD:** GitHub Actions → Fly.io
102102
- 📈 **Monitoring:** Azure Application Insights
103103

104+
<a id="architecture"></a>
105+
## 🏛️ Architecture
106+
107+
[![Architecture Diagram](/frontend/public/architecture.svg)](/frontend/public/architecture.svg)
108+
109+
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.
110+
111+
### 🖥️ 1. Client Layer
112+
- **Browser (React SPA)**
113+
- Contains ten page components:
114+
AuthPage, LandingPage, CreatePOPage, PurchaseOrdersPage, PurchaseOrderDetailsPage, DashboardPage, InvoicePage, AutoMatchPage, UploadInvoicePage, and UploadResultPage.
115+
- Sends and receives JWT-protected HTTPS calls to the Nginx proxy.
116+
117+
### 🌐 2. Presentation Layer
118+
- **Nginx Reverse Proxy** (Fly.io container “React+Nginx”)
119+
- Terminates TLS, serves the React bundle, and forwards API requests.
120+
- **API Gateway** (.NET 6 Web API, Fly.io container “Backend”)
121+
- Hosts all controllers and orchestrates application logic.
122+
- **Redirector** (Fly.io container)
123+
- Routes requests from `matchflow.app``www.matchflow.app`.
124+
125+
### 🛡️ 3. Controller Layer
126+
_All running inside the API Gateway container:_
127+
- **AuthController** (handles login, JWT issuance & validation)
128+
- **PurchaseOrderListController**
129+
- **InvoiceListController**
130+
- **InvoiceMatchController**
131+
- **InvoiceUploadController**
132+
133+
### 🧩 4. Application Layer
134+
- **Services** (use-case implementations):
135+
- `CreatePurchaseOrderService`
136+
- `MatchingService`
137+
- `UploadInvoiceService`
138+
- `JWT Issuance & Validation` (via UserService)
139+
- **Ports / Interfaces** (abstractions for infrastructure):
140+
- `IInvoiceRepository`, `IPurchaseOrderRepository`
141+
- `IFormRecognizer`, `IBlobStorage`
142+
- `IExceptionRecordRepository`, `IServiceBusClient`, `IUserService`
143+
- Dependencies are injected here, following the Dependency Inversion Principle.
144+
145+
### 🛠️ 5. Infrastructure Layer
146+
_Concrete implementations of all ports:_
147+
- **EF Core Repositories**: `InvoiceRepository`, `PurchaseOrderRepository`, `ExceptionRecordRepository`, backed by `AppDbContext`
148+
- **Azure Clients**: `BlobStorageService`, `FormRecognizerClient`, `ServiceBusClient`
149+
- **UserService** (JWT key management & refresh logic)
150+
151+
### 📦 6. Domain Layer
152+
_Pure business entities with no external dependencies:_
153+
- `Invoice`, `PurchaseOrder`, `InvoiceLineItem`, `PurchaseOrderLineItem`, `ExceptionRecord`, `User`
154+
155+
### ☁️ Cloud Services
156+
- **Azure Blob Storage** (PDF persistence)
157+
- **Azure Form Recognizer** (OCR)
158+
- **Azure SQL Database** (POs, invoices, audit logs)
159+
- **Azure Service Bus** (discrepancy messaging)
160+
- **Application Insights** (telemetry & logging)
161+
162+
### 🐳 Local Development
163+
- **Docker Compose** spins up all containers (React+Nginx, API, SQL emulator, Blob emulator, etc.) for end-to-end testing without Azure.
164+
165+
---
166+
167+
### 🔄 Primary Data Flows
168+
169+
1. **User Upload**
170+
Browser → Nginx (HTTPS + JWT) → API Gateway
171+
2. **Invoice Processing**
172+
`UploadInvoiceController` → UploadInvoiceService
173+
→ BlobStorageService → Azure Blob (POST PDF)
174+
→ FormRecognizerClient → Azure Form Recognizer (extract JSON)
175+
3. **Matching Logic**
176+
`UploadInvoiceService` → MatchingService → EF Repositories → Azure SQL
177+
4. **Discrepancy Handling**
178+
On mismatch, UploadInvoiceService → ServiceBusClient → Azure Service Bus
179+
Front-end polls/subscribes for results
180+
5. **Telemetry**
181+
All API calls and repository operations log to Application Insights
182+
183+
---
184+
185+
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.

frontend/public/architecture.svg

Lines changed: 29 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)