Skip to content

Commit 044c4dd

Browse files
committed
models se[aration of concerns
1 parent 1426701 commit 044c4dd

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
label: "Server Architecture"
2+
position: 6

docs/architecture/server/index.md renamed to docs/architecture/server/command-query-separation.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 1
33
---
44

5-
# Server Architecture
6-
7-
## Command Query Separation (CQS)
5+
# Command Query Separation (CQS)
86

97
Our server architecture uses the Command Query Separation (CQS) pattern.
108

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Models separation of concerns
6+
7+
To maintain clean architecture and separation of concerns, **API contracts** (request/response
8+
models) must be kept separate from **data models**. This separation allows:
9+
10+
- **API contracts to evolve independently** from internal data structures
11+
- **Versioning of APIs** without affecting internal business logic
12+
- **Validation and serialization** specific to API layer
13+
14+
### Model Types and Their Purposes
15+
16+
#### Request Models (`*RequestModel`)
17+
18+
- Define the shape of data received from API clients
19+
- Handle data validation (e.g., `[Required]`, `[StringLength]`)
20+
- Convert to data models via `ToData()` methods
21+
22+
#### Response Models (`*ResponseModel`)
23+
24+
- Define the shape of data sent to API clients
25+
- Construct from data models via constructors or factory methods
26+
- Handle API-specific formatting and structure
27+
28+
#### Data Models
29+
30+
- Internal representation used by business logic
31+
- Handle domain logic and transformations
32+
- Should be clearly distinguishable from API models
33+
34+
### Guidelines
35+
36+
1. **Never expose data models directly in API endpoints**
37+
2. **Provide conversion methods**
38+
3. **Keep validation at the API layer**

0 commit comments

Comments
 (0)