Skip to content

Commit 0e531be

Browse files
authored
Merge pull request #35 from getmarkus/cm-branch-33
docs: add design principles and improve diagrams formatting
2 parents 1a014c7 + 98b359b commit 0e531be

File tree

3 files changed

+93
-25
lines changed

3 files changed

+93
-25
lines changed

.windsurfrules

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Design and Principles
2+
3+
- Simple python template I am experimenting with around a set of overlapping concepts with a Fastapi implementation:
4+
- Domain Driven Design (DDD)
5+
- Clean architecture
6+
- Ports & Adapters
7+
- Vertical slice
8+
9+
## Core System Components
10+
11+
- The main application logic is in app.
12+
- Feature flags and configuration settings are in config.py.
13+
14+
## Code styles
15+
16+
- Use PEP 8 and pythonic code
17+
- Use type hints
18+
- Functions: Use `snake_case`
19+
- Variables: Use `snake_case`
20+
- Constants: Use `UPPER_CASE`
21+
- Classes: Use `CamelCase`
22+
- Use `loguru` for logging
23+
- Use `pydantic` for data validation
24+
- Use `sqlmodel` for database interactions
25+
- Use `pydantic-settings` for configuration
26+
- Use `python-dotenv` for environment variables
27+
- Use `pytest` for testing
28+
- Use `pytest-cov` for coverage
29+
- Use `uv` for dependency management
30+
31+
## Data & Storage
32+
33+
- Support for Sqlite and Postgres via sqlmodel.
34+
- Use `atlas` for database migrations
35+
- Use `migrations` directory for migration files
36+
- Use Bytebase and Supabase style guides
37+
- Identifier Style: snake_case, lowercase, descriptive
38+
- Table Names: snake_case, plural, no prefixes, descriptive
39+
- Column Names: snake_case, singular, descriptive, avoid generic, with `_id`
40+
- Data Types: Prefer specific types, ENUM for small sets, avoid CHAR(n)
41+
- Query Formatting: Lowercase keywords, whitespace, clear indentation
42+
- Functions: Lowercase, snake_case
43+
- Constraints: Explicit, descriptive names
44+
45+
## Testing & Debugging
46+
47+
- Unit, component and integration tests in app/tests
48+
- Create unit and component tests first before writing the actual code
49+
- Follow code implementation with integration tests
50+
51+
## Workflow and developer interaction
52+
53+
- TBD
54+
55+
## Bash commands
56+
57+
- Running api server:
58+
59+
```bash
60+
uv run fastapi dev main.py
61+
```
62+
63+
- Running tests:
64+
65+
```bash
66+
uv run pytest
67+
```
68+
69+
- Running database and migrations:
70+
71+
```bash
72+
docker compose up
73+
docker compose down -v
74+
```
75+
76+
- Various migration commands depending on database type:
77+
78+
```bash
79+
atlas schema inspect -u "sqlite://file?cache=shared&mode=memory" --format "{{ sql . }}"
80+
atlas schema inspect -u "sqlite://issues.db" --format "{{ sql . }}" > migrate.sql
81+
atlas schema inspect -u "postgres://app_user:change_this_password@localhost:5432/app_database?sslmode=disable" --schema "issue_analysis" --format "{{ sql . }}"
82+
83+
atlas schema apply --url "sqlite://issues.db" --to "file://migrate.sql" --dev-url "sqlite://file?mode=memory" --dry-run
84+
atlas schema apply --url "sqlite://issues.db" --to "file://migrate.sql" --dev-url "sqlite://file?mode=memory"
85+
86+
atlas schema apply --url "postgres://app_user:change_this_password@localhost:5432/app_database?sslmode=disable" --to "file://./migrations/migrate.sql" --dev-url "docker://postgres/17" --dry-run
87+
atlas schema apply --url "postgres://app_user:change_this_password@localhost:5432/app_database?sslmode=disable" --to "file://./migrations/migrate.sql" --dev-url "docker://postgres/17"
88+
```

README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,4 @@ atlas schema apply --url "postgres://app_user:change_this_password@localhost:543
2424

2525
```mermaid
2626
graph TD;
27-
analyze_endpoint["/issues/{issue_number}/analyze (POST)"] -->|Depends| configure_repository
28-
analyze_endpoint -->|Depends| configure_unit_of_work
29-
configure_repository -->|Returns| repo["RepositoryProtocol[Issue]"]
30-
configure_unit_of_work -->|Returns| uow["UnitOfWork[UnitOfWorkProtocol[ConnectionProtocol]]"]
31-
analyze_endpoint --> ApplicationFacade_analyze_issue["ApplicationFacade.analyze_issue()"]
32-
ApplicationFacade_analyze_issue --> AnalyzeIssue_constructor["AnalyzeIssue.__init__()"]
33-
AnalyzeIssue_constructor --> AnalyzeIssue_analyze["AnalyzeIssue.analyze()"]
34-
AnalyzeIssue_analyze --> repo_get_by_id["repo.get_by_id()"]
35-
repo_get_by_id -->|Issue found| AnalyzeIssue_analyze
36-
repo_get_by_id -->|Issue not found| repo_add["repo.add()"]
37-
repo_add --> AnalyzeIssue_analyze
38-
configure_unit_of_work --> UnitOfWork_constructor["UnitOfWork.__init__()"]
39-
UnitOfWork_constructor --> UnitOfWork_commit["UnitOfWork.commit()"]
40-
UnitOfWork_constructor --> UnitOfWork_rollback["UnitOfWork.rollback()"]
41-
UnitOfWork_constructor --> UnitOfWork_enter["UnitOfWork.__enter__()"]
42-
UnitOfWork_constructor --> UnitOfWork_exit["UnitOfWork.__exit__()"]
43-
UnitOfWork_commit --> Connection_commit["Connection.commit()"]
44-
UnitOfWork_rollback --> Connection_rollback["Connection.rollback()"]
45-
Connection_commit -.-> ConnectionProtocol
46-
Connection_rollback -.-> ConnectionProtocol
47-
UnitOfWork_commit -.-> UnitOfWorkProtocol
48-
UnitOfWork_rollback -.-> UnitOfWorkProtocol
49-
UnitOfWork_enter -.-> UnitOfWorkProtocol
50-
UnitOfWork_exit -.-> UnitOfWorkProtocol
5127
```

diagrams.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Diagrams
2+
13
```mermaid
24
graph TD;
35
analyze_endpoint["/issues/{issue_number}/analyze (POST)"] -->|Depends| configure_repository
@@ -10,8 +12,10 @@ graph TD;
1012
AnalyzeIssue_analyze --> repo_get_by_id["repo.get_by_id()"]
1113
repo_get_by_id -->|Issue found| AnalyzeIssue_analyze
1214
repo_get_by_id -->|Issue not found| repo_add["repo.add()"]
15+
1316
repo_add --> AnalyzeIssue_analyze
1417
```
18+
1519
```mermaid
1620
graph TD;
1721
analyze_endpoint["/issues/{issue_number}/analyze (POST)"] -->|Depends| configure_repository["configure_repository()"]
@@ -38,4 +42,4 @@ graph TD;
3842
UnitOfWork_rollback -.-> UnitOfWorkProtocol
3943
UnitOfWork_enter -.-> UnitOfWorkProtocol
4044
UnitOfWork_exit -.-> UnitOfWorkProtocol
41-
```
45+
```

0 commit comments

Comments
 (0)