- type
- concept
- created
- Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
- updated
- Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
- sources
- raw/notes/systemPatterns
- tags
- architecture layers data-bootstrap entity action output
Four-Layer Architecture
Overview
The Four-Layer Architecture is the structural backbone of the wiki/entities/b2bpaper platform. It was defined in the V1 System Diagram and organizes all system functionality into four distinct layers with clear responsibilities and data flow direction.
The Layers
Layer 1: Data Bootstrap Layer (Bottom)
Purpose: Get data into the system.
- Initial data collection and onboarding
- Excel import from mills
- Email ingestion pipeline
- Scraper data import (from wiki/entities/b2bpaper-scraper)
This layer handles the messy reality of paper surplus data: varying Excel formats, different languages, inconsistent column names. The wiki/concepts/zero-friction-mill-pattern lives here -- mills email spreadsheets, and this layer transforms them into structured data.
Layer 2: Entity Layer
Purpose: Store and manage structured data.
The six core entities live here (see wiki/concepts/six-core-entities):
| Entity | Role |
|---|---|
| Products | Master catalog of paper product types |
| Surplus Availability | Current mill surplus inventory |
| Mills | Paper manufacturing facilities |
| Mills Surplus Visibility | Geographic visibility configuration |
| Buyers | Purchasing companies |
| Buyer Specifics | Detailed buyer requirements |
These are the Django models, the database tables, the serializers. Clean, structured, validated data.
Layer 3: Action Layer
Purpose: Execute business logic on entity data.
The eight core actions live here (see wiki/concepts/eight-core-actions):
- Matching surplus to buyer specifications
- Container assembly optimization
- 48-hour exclusivity window management
- Newsletter generation
- Excel ingestion orchestration
- Visibility configuration
- Buyer and supplier extraction/onboarding
- Pre-production tracking
Business logic is organized via the wiki/concepts/service-layer-pattern -- pure functions in services.py files, called by views, testable without HTTP context.
Layer 4: Output Layer (Top)
Purpose: Deliver results to users.
- Newsletters sent to matched buyers
- Container assembly proposals
- Reports and analytics
- Notifications (email, in-app)
This is what users actually see and interact with. Everything below it is plumbing.
Data Flow
Data flows upward through the layers:
Mill emails Excel
↓
[Data Bootstrap] parses and structures
↓
[Entity Layer] stores as Surplus, linked to Mill
↓
[Action Layer] matches to Buyer Specifics, assembles containers
↓
[Output Layer] sends newsletter to matched Buyers
Each layer depends only on the layer below it. The Output Layer never directly touches the Data Bootstrap Layer.
Sources
- raw/notes/systemPatterns -- architecture diagram and layer definitions
Related
- wiki/concepts/six-core-entities -- the Entity Layer in detail
- wiki/concepts/eight-core-actions -- the Action Layer in detail
- wiki/concepts/service-layer-pattern -- how Action Layer logic is organized
- wiki/concepts/zero-friction-mill-pattern -- the Data Bootstrap philosophy
- wiki/entities/b2bpaper-scraper -- feeds the Data Bootstrap Layer
- wiki/summaries/systempatterns-summary -- full system patterns summary