# anami283/legacy-demo-erp architecture

> Architecture diagram of the GitHub repository anami283/legacy-demo-erp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anami283/legacy-demo-erp
- Repository: https://github.com/anami283/legacy-demo-erp

## Overview

#### Purpose and runtime
Legacy ERP is an internal Java application for sales, inventory, and billing. It is packaged with Maven and containerized for local deployment via Docker Compose. The executable application entry point is `src/main/java/com/northstar/erp/LegacyErpApplication.java`; deployment artifacts are `Dockerfile` and `docker-compose.yml`.

#### Application boundary
The web-facing sales boundary is `src/main/java/com/northstar/erp/web/SalesController.java`. It accepts sales-oriented requests and delegates business work to domain services rather than directly managing storage. The README identifies a default `admin/admin` user, implying authentication is part of the deployed application or container configuration, though no auth source appears in the tree.

#### Sales-order domain
Order creation and lifecycle are centered on `src/main/java/com/northstar/erp/orders/OrderService.java`, with aggregate/request structures in:
- `src/main/java/com/northstar/erp/orders/SalesOrder.java`
- `src/main/java/com/northstar/erp/orders/SalesOrderRequest.java`
- `src/main/java/com/northstar/erp/orders/OrderLine.java`

Orders are persisted behind `src/main/java/com/northstar/erp/orders/OrderRepository.java`, currently implemented by `src/main/java/com/northstar/erp/orders/InMemoryOrderRepository.java`. This interface/implementation split is the main persistence replacement boundary.

#### Customer and inventory dependencies
Sales processing depends on customer lookup/management through `src/main/java/com/northstar/erp/customers/CustomerService.java` and `src/main/java/com/northstar/erp/customers/CustomerRepository.java`. Inventory availability and stock operations are owned by `src/main/java/com/northstar/erp/inventory/InventoryService.java`, backed by `src/main/java/com/northstar/erp/inventory/InventoryRepository.java`; products are represented by `src/main/java/com/northstar/erp/inventory/Product.java`.

The in-memory implementations (`InMemoryCustomerRepository.java`, `InMemoryInventoryRepository.java`) indicate process-local, non-durable state rather than an external database.

#### Billing and payment flow
Invoice generation/handling is isolated in `src/main/java/com/northstar/erp/invoices/InvoiceProcessor.java`, using `Invoice.java` and the `InvoiceRepository` abstraction. Payments are represented and processed separately by:
- `src/main/java/com/northstar/erp/payments/Payment.java`
- `src/main/java/com/northstar/erp/payments/PaymentService.java`

The likely control flow is sales request → order service → customer/inventory validation and stock changes → order persistence → invoice processing → payment handling. Invoice and payment concerns are distinct boundaries, enabling later integration with durable billing or payment services.

#### Shared domain contract
`src/main/java/com/northstar/erp/shared/Money.java` is the cross-domain monetary value type. Orders, invoices, and payments should exchange monetary amounts through this shared model rather than primitive numeric values, making it a key consistency boundary.

#### Infrastructure and extension points
No database, message broker, payment gateway, or other external service is visible in the repository tree. Runtime infrastructure is Docker/Docker Compose; persistence is presently in-memory. The repository interfaces in customers, inventory, orders, and invoices are the principal seams for introducing durable storage without changing service-level workflows.

Main entry points: [`src/main/java/com/northstar/erp/orders/OrderService.java`](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/OrderService.java) (Order service), [`src/main/java/com/northstar/erp/invoices/InvoiceProcessor.java`](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/invoices/InvoiceProcessor.java) (Invoice processor), [`src/main/java/com/northstar/erp/inventory/InventoryService.java`](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/InventoryService.java) (Inventory service), [`src/main/java/com/northstar/erp/shared/Money.java`](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/shared/Money.java) (Money)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime &amp; deployment"]
  node_compose["Docker Compose<br/>deployment<br/>[docker-compose.yml]"]
  node_dockerfile["Application image<br/>container build"]
  node_application{{"Legacy ERP application<br/>Java application"}}
end

subgraph group_web["Web boundary"]
  node_sales_controller["Sales controller<br/>web controller"]
end

subgraph group_sales["Sales orders"]
  node_order_service["Order service<br/>domain service<br/>[OrderService.java]"]
  node_sales_order["Sales order aggregate<br/>domain model<br/>[SalesOrder.java]"]
  node_order_request["Order request &amp; lines<br/>request model"]
end

subgraph group_dependencies["Customer, inventory &amp; billing"]
  node_customer_service["Customer service<br/>domain service"]
  node_inventory_service["Inventory service<br/>domain service"]
  node_product["Product<br/>domain model<br/>[Product.java]"]
  node_invoice_processor["Invoice processor<br/>billing service"]
  node_payment_service["Payment service"]
  node_money["Money<br/>shared value object<br/>[Money.java]"]
end

subgraph group_persistence["Persistence seams"]
  node_order_repository[("Order repository<br/>repository interface")]
  node_memory_orders[("In-memory orders<br/>repository implementation")]
  node_customer_repository[("Customer repository<br/>repository interface")]
  node_inventory_repository[("Inventory repository<br/>repository interface")]
  node_invoice_repository[("Invoice repository<br/>repository interface")]
end

node_compose -->|"builds"| node_dockerfile
node_dockerfile -->|"packages"| node_application
node_application -->|"hosts"| node_sales_controller
node_sales_controller -->|"delegates sales requests"| node_order_service
node_order_service -->|"accepts"| node_order_request
node_order_service -->|"creates and manages"| node_sales_order
node_order_service -->|"validates customer"| node_customer_service
node_order_service -->|"checks and reserves stock"| node_inventory_service
node_order_service -->|"persists orders"| node_order_repository
node_order_service -->|"triggers invoicing"| node_invoice_processor
node_invoice_processor -->|"hands off payment handling"| node_payment_service
node_customer_service -->|"uses"| node_customer_repository
node_inventory_service -->|"uses"| node_inventory_repository
node_inventory_service -->|"manages"| node_product
node_invoice_processor -->|"uses"| node_invoice_repository
node_order_repository -->|"implemented by"| node_memory_orders
node_sales_order -.->|"uses amounts"| node_money
node_invoice_processor -.->|"uses amounts"| node_money
node_payment_service -.->|"uses amounts"| node_money

click node_compose "https://github.com/anami283/legacy-demo-erp/blob/main/docker-compose.yml"
click node_dockerfile "https://github.com/anami283/legacy-demo-erp/blob/main/Dockerfile"
click node_application "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/LegacyErpApplication.java"
click node_sales_controller "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/web/SalesController.java"
click node_order_service "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/OrderService.java"
click node_sales_order "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/SalesOrder.java"
click node_order_request "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/SalesOrderRequest.java"
click node_customer_service "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/customers/CustomerService.java"
click node_inventory_service "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/InventoryService.java"
click node_product "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/Product.java"
click node_invoice_processor "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/invoices/InvoiceProcessor.java"
click node_payment_service "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/payments/PaymentService.java"
click node_money "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/shared/Money.java"
click node_order_repository "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/OrderRepository.java"
click node_memory_orders "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/InMemoryOrderRepository.java"
click node_customer_repository "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/customers/CustomerRepository.java"
click node_inventory_repository "https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/InventoryRepository.java"

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_compose,node_dockerfile,node_application toneBlue
class node_sales_controller toneAmber
class node_order_service,node_sales_order,node_order_request toneMint
class node_customer_service,node_inventory_service,node_product,node_invoice_processor,node_payment_service,node_money toneRose
class node_order_repository,node_memory_orders,node_customer_repository,node_inventory_repository,node_invoice_repository toneIndigo
```

## Components

### Runtime & deployment

- [Docker Compose](https://github.com/anami283/legacy-demo-erp/blob/main/docker-compose.yml): deployment · `docker-compose.yml`
- [Application image](https://github.com/anami283/legacy-demo-erp/blob/main/Dockerfile): container build · `Dockerfile`
- [Legacy ERP application](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/LegacyErpApplication.java): Java application · `src/main/java/com/northstar/erp/LegacyErpApplication.java`

### Web boundary

- [Sales controller](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/web/SalesController.java): web controller · Accepts sales requests and delegates business work. · `src/main/java/com/northstar/erp/web/SalesController.java`

### Sales orders

- [Order service](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/OrderService.java): domain service · Coordinates order creation and lifecycle. · `src/main/java/com/northstar/erp/orders/OrderService.java`
- [Sales order aggregate](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/SalesOrder.java): domain model · `src/main/java/com/northstar/erp/orders/SalesOrder.java`
- [Order request & lines](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/SalesOrderRequest.java): request model · `src/main/java/com/northstar/erp/orders/SalesOrderRequest.java`

### Customer, inventory & billing

- [Customer service](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/customers/CustomerService.java): domain service · `src/main/java/com/northstar/erp/customers/CustomerService.java`
- [Inventory service](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/InventoryService.java): domain service · Validates availability and changes stock. · `src/main/java/com/northstar/erp/inventory/InventoryService.java`
- [Product](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/Product.java): domain model · `src/main/java/com/northstar/erp/inventory/Product.java`
- [Invoice processor](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/invoices/InvoiceProcessor.java): billing service · `src/main/java/com/northstar/erp/invoices/InvoiceProcessor.java`
- [Payment service](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/payments/PaymentService.java): payment service · `src/main/java/com/northstar/erp/payments/PaymentService.java`
- [Money](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/shared/Money.java): shared value object · Cross-domain monetary contract. · `src/main/java/com/northstar/erp/shared/Money.java`

### Persistence seams

Current repository implementations keep state in process memory.

- [Order repository](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/OrderRepository.java): repository interface · Durable-storage replacement seam. · `src/main/java/com/northstar/erp/orders/OrderRepository.java`
- [In-memory orders](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/orders/InMemoryOrderRepository.java): repository implementation · Process-local, non-durable order state. · `src/main/java/com/northstar/erp/orders/InMemoryOrderRepository.java`
- [Customer repository](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/customers/CustomerRepository.java): repository interface · Durable-storage replacement seam. · `src/main/java/com/northstar/erp/customers/CustomerRepository.java`
- [Inventory repository](https://github.com/anami283/legacy-demo-erp/blob/main/src/main/java/com/northstar/erp/inventory/InventoryRepository.java): repository interface · Durable-storage replacement seam. · `src/main/java/com/northstar/erp/inventory/InventoryRepository.java`
- **Invoice repository**: repository interface · Billing persistence seam.

## Connections

- Docker Compose → Application image: builds
- Application image → Legacy ERP application: packages
- Legacy ERP application → Sales controller: hosts
- Sales controller → Order service: delegates sales requests
- Order service → Order request & lines: accepts
- Order service → Sales order aggregate: creates and manages
- Order service → Customer service: validates customer
- Order service → Inventory service: checks and reserves stock
- Order service → Order repository: persists orders
- Order service → Invoice processor: triggers invoicing
- Invoice processor → Payment service: hands off payment handling
- Customer service → Customer repository: uses
- Inventory service → Inventory repository: uses
- Inventory service → Product: manages
- Invoice processor → Invoice repository: uses
- Order repository → In-memory orders: implemented by
- Sales order aggregate → Money: uses amounts
- Invoice processor → Money: uses amounts
- Payment service → Money: uses amounts
