You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 01_philosophy/mental-models.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
$NOTE
2
+
2
3
# Mental Models
3
4
4
5
This defines the thinking patterns behind design decisions.
@@ -8,7 +9,7 @@ These are not concrete rules, but the "way of thinking" from which rules emerge.
8
9
9
10
## 1. Constraints Breed Creativity
10
11
11
-
**"Fewer choices lead to faster and better decisions."**
12
+
> *"Fewer choices lead to faster and better decisions."*
12
13
13
14
"Faster" here means reduced decision fatigue and shorter code review cycles. When the framework constrains choices (e.g., "use Literal types over plain strings," "no bare `except`"), developers spend zero time debating the approach and reviewers can focus on logic rather than style. This compounds across a team — eliminating 10 micro-decisions per PR across 50 PRs/week saves meaningful cognitive load.
14
15
@@ -22,7 +23,7 @@ These are not concrete rules, but the "way of thinking" from which rules emerge.
22
23
23
24
## 2. Code is Read More Than Written
24
25
25
-
**"Write code that the future reader (including yourself 3 months later) can understand as quickly as possible."**
26
+
> *"Write code that the future reader (including yourself 3 months later) can understand as quickly as possible."*
26
27
27
28
- Write code where intent is clear, rather than optimizing for brevity or shortness
28
29
- Consistency in naming conventions directly impacts searchability and refactoring ease
@@ -34,9 +35,9 @@ These are not concrete rules, but the "way of thinking" from which rules emerge.
34
35
35
36
## 3. Validate at Boundaries
36
37
37
-
**"Trust the internals, but validate strictly at the points of contact with the outside."**
38
+
> *"Trust the internals, but validate strictly at the points of contact with the outside."*
38
39
39
-
```
40
+
```text
40
41
External Input ──[Pydantic]──> Route Handler ──[Type Hints]──> Service Layer ──[ORM]──> DB
Copy file name to clipboardExpand all lines: 01_philosophy/principles.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
$NOTE
2
+
2
3
# Design Principles
3
4
4
5
This document defines the fundamental principles that underpin all projects.
@@ -10,15 +11,15 @@ It articulates the "why" behind our guidelines and serves as the ultimate refere
10
11
11
12
All design decisions are made in this order of priority.
12
13
13
-
```
14
+
```text
14
15
1. Correctness — Guarantee correct behavior through types and validation
15
16
2. Observability — Ensure the running state can be observed and traced
16
17
3. Pragmatism — Achieve goals with the minimum necessary complexity
17
18
```
18
19
19
20
### 1. Correctness
20
21
21
-
**"Eliminate runtime errors by catching them during static analysis (mypy/pyright)."**
22
+
> *"Eliminate runtime errors by catching them during static analysis (mypy/pyright)."*
22
23
23
24
- Type hints catch errors via static analysis (mypy/pyright) before code reaches production
24
25
- Security is built into the architecture, not bolted on after the fact
@@ -27,7 +28,7 @@ All design decisions are made in this order of priority.
27
28
28
29
### 2. Observability
29
30
30
-
**"Understand what is happening in production without redeploying."**
31
+
> *"Understand what is happening in production without redeploying."*
31
32
32
33
- Assign a Trace ID to every request and propagate it across layers
33
34
- Automatically mask PII. Never expose secrets in logs
@@ -37,7 +38,7 @@ All design decisions are made in this order of priority.
37
38
38
39
### 3. Pragmatism
39
40
40
-
**"Don't build it until you need it. When you need it, build it the simplest way possible."**
41
+
> *"Don't build it until you need it. When you need it, build it the simplest way possible."*
41
42
42
43
- Copy-paste is not evil. Don't abstract until duplication appears in 3 places. The number 3 is deliberate: with 1 occurrence you have no pattern; with 2 you see similarity but may be misled by coincidence; with 3 you have enough evidence to extract a correct, stable abstraction. Abstracting at 2 often produces the *wrong* abstraction because you lack sufficient examples to identify the true commonality
43
44
- Convention over Configuration
@@ -66,7 +67,7 @@ All design decisions are made in this order of priority.
66
67
67
68
## Security Philosophy: Zero Trust
68
69
69
-
**"Trust no input. Every user is a potential attacker."**
70
+
> *"Trust no input. Every user is a potential attacker."*
Copy file name to clipboardExpand all lines: 02_decision-criteria/abstraction.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
$NOTE
2
+
2
3
# Decision Criteria for Generalization and Abstraction
3
4
4
5
Criteria for deciding whether to "extract" or "leave as-is" when you find code duplication.
@@ -7,7 +8,7 @@ Criteria for deciding whether to "extract" or "leave as-is" when you find code d
7
8
8
9
## Fundamental Principle
9
10
10
-
**"Premature abstraction leads to wrong abstraction."**
11
+
> *"Premature abstraction leads to wrong abstraction."*
11
12
12
13
Abstraction increases the cost of understanding. It only has value when "enough reuse" exists — meaning 3+ call sites with genuinely identical logic, not just superficially similar code. Two similar-looking functions that evolve independently don't justify abstraction.
Copy file name to clipboardExpand all lines: 02_decision-criteria/error-strategy.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
$NOTE
2
+
2
3
# Error Strategy Decision Criteria
3
4
4
5
Defines error handling policies, retry decisions, and how to communicate errors to users.
@@ -7,7 +8,7 @@ Defines error handling policies, retry decisions, and how to communicate errors
7
8
8
9
## Fundamental Principle
9
10
10
-
**"Don't try to prevent all failures — detect, contain, and communicate them."**
11
+
> *"Don't try to prevent all failures — detect, contain, and communicate them."*
11
12
12
13
---
13
14
@@ -23,7 +24,7 @@ Defines error handling policies, retry decisions, and how to communicate errors
23
24
24
25
The boundary between System and Application errors: "Could the developer have predicted it?" means — is this error a known, enumerable case in the domain logic? If yes (e.g., "user not found", "insufficient balance"), it's an Application error that should be handled with a specific code path. If no (e.g., database connection dropped, OOM), it's a System error that gets generic handling.
25
26
26
-
```
27
+
```text
27
28
Error Occurs
28
29
|
29
30
+-- Is this a known, enumerable domain case?
@@ -51,7 +52,7 @@ Error Occurs
51
52
52
53
### Retry Implementation Criteria
53
54
54
-
```
55
+
```text
55
56
Should we retry?
56
57
|
57
58
+-- Is the status code 5xx?
@@ -155,7 +156,7 @@ class AuthorizationError(AppError):
0 commit comments