|
34 | 34 |
|
35 | 35 | ## 🏗️ Architecture Overview |
36 | 36 |
|
| 37 | +### Development Workflow |
| 38 | + |
| 39 | +```mermaid |
| 40 | +flowchart LR |
| 41 | + subgraph DEV["🖥️ Development"] |
| 42 | + A["✏️ Write<br/>Code"] --> B["💾 Save<br/>File"] |
| 43 | + end |
| 44 | +
|
| 45 | + subgraph VCS["📦 Version Control"] |
| 46 | + B --> C["📝 Stage<br/>Changes"] |
| 47 | + C --> D["✅ Commit"] |
| 48 | + D --> E["🚀 Push<br/>to Remote"] |
| 49 | + end |
| 50 | +
|
| 51 | + subgraph GATES["🛡️ Automated Quality Gates"] |
| 52 | + direction TB |
| 53 | + D -.-> G1["🔍 Ruff<br/>Lint + Format"] |
| 54 | + D -.-> G2["🔷 Mypy<br/>Type Check"] |
| 55 | + D -.-> G3["🔒 Bandit<br/>Security Scan"] |
| 56 | + D -.-> G4["📋 Commitizen<br/>Conventional Commits"] |
| 57 | + end |
| 58 | +
|
| 59 | + style DEV fill:#e1f5fe,stroke:#01579b |
| 60 | + style VCS fill:#f3e5f5,stroke:#4a148c |
| 61 | + style GATES fill:#fff3e0,stroke:#e65100 |
37 | 62 | ``` |
38 | | -┌─────────────────────────────────────────────────────────────────────┐ |
39 | | -│ DEVELOPMENT WORKFLOW │ |
40 | | -├─────────────────────────────────────────────────────────────────────┤ |
41 | | -│ │ |
42 | | -│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ |
43 | | -│ │ Write │───▶│ Save │───▶│ Commit │───▶│ Push │ │ |
44 | | -│ │ Code │ │ File │ │ Changes │ │ to Repo │ │ |
45 | | -│ └──────────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │ |
46 | | -│ │ │ │ │ |
47 | | -│ ▼ ▼ ▼ │ |
48 | | -│ ┌─────────────────────────────────────────────────────────────┐ │ |
49 | | -│ │ AUTOMATED QUALITY GATES │ │ |
50 | | -│ ├─────────────────────────────────────────────────────────────┤ │ |
51 | | -│ │ │ │ |
52 | | -│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────────┐ │ │ |
53 | | -│ │ │ Ruff │ │ Mypy │ │ Bandit │ │ Commitizen │ │ │ |
54 | | -│ │ │ Lint + │ │ Type │ │Security │ │ Conventional │ │ │ |
55 | | -│ │ │ Format │ │ Check │ │ Scan │ │ Commits │ │ │ |
56 | | -│ │ └─────────┘ └─────────┘ └─────────┘ └─────────────────┘ │ │ |
57 | | -│ │ │ │ |
58 | | -│ └─────────────────────────────────────────────────────────────┘ │ |
59 | | -│ │ |
60 | | -└─────────────────────────────────────────────────────────────────────┘ |
61 | | -
|
62 | | -┌─────────────────────────────────────────────────────────────────────┐ |
63 | | -│ PROJECT STRUCTURE │ |
64 | | -├─────────────────────────────────────────────────────────────────────┤ |
65 | | -│ │ |
66 | | -│ {{ cookiecutter.project_slug }}/ │ |
67 | | -│ ├── src/ │ |
68 | | -│ │ └── {{ cookiecutter.project_slug }}/ │ |
69 | | -│ │ ├── __init__.py # Package initialization │ |
70 | | -│ │ ├── main.py # Core application logic │ |
71 | | -│ │ ├── my_cli.py # Typer CLI interface │ |
72 | | -│ │ └── rich_demo.py # Rich terminal UI examples │ |
73 | | -│ │ │ |
74 | | -│ ├── tests/ │ |
75 | | -│ │ └── test_main.py # Pytest test suite │ |
76 | | -│ │ │ |
77 | | -│ ├── pyproject.toml # Unified Python config │ |
78 | | -│ ├── .pre-commit-config.yaml # Git hooks configuration │ |
79 | | -│ └── README.md # Project documentation │ |
80 | | -│ │ |
81 | | -└─────────────────────────────────────────────────────────────────────┘ |
| 63 | + |
| 64 | +### Project Structure |
| 65 | + |
| 66 | +```mermaid |
| 67 | +flowchart TB |
| 68 | + subgraph ROOT["📁 project_name/"] |
| 69 | + direction TB |
| 70 | + subgraph SRC["📂 src/"] |
| 71 | + subgraph PKG["📂 project_name/"] |
| 72 | + INIT["📄 __init__.py<br/><small>Package init</small>"] |
| 73 | + MAIN["📄 main.py<br/><small>Core logic</small>"] |
| 74 | + CLI["📄 my_cli.py<br/><small>Typer CLI</small>"] |
| 75 | + RICH["📄 rich_demo.py<br/><small>Rich UI demos</small>"] |
| 76 | + end |
| 77 | + end |
| 78 | + subgraph TESTS["📂 tests/"] |
| 79 | + TEST["📄 test_main.py<br/><small>Pytest suite</small>"] |
| 80 | + end |
| 81 | + PYPROJ["📄 pyproject.toml<br/><small>Unified config</small>"] |
| 82 | + PRECOMMIT["📄 .pre-commit-config.yaml<br/><small>Git hooks</small>"] |
| 83 | + README["📄 README.md<br/><small>Documentation</small>"] |
| 84 | + GITIGNORE["📄 .gitignore"] |
| 85 | + end |
| 86 | +
|
| 87 | + style ROOT fill:#e8f5e9,stroke:#2e7d32 |
| 88 | + style SRC fill:#e3f2fd,stroke:#1565c0 |
| 89 | + style PKG fill:#fff8e1,stroke:#f9a825 |
| 90 | + style TESTS fill:#fce4ec,stroke:#c2185b |
82 | 91 | ``` |
83 | 92 |
|
84 | 93 | --- |
@@ -142,32 +151,50 @@ pre-commit install --install-hooks |
142 | 151 |
|
143 | 152 | ## 📦 Tool Stack |
144 | 153 |
|
145 | | -``` |
146 | | -┌────────────────────────────────────────────────────────────────┐ |
147 | | -│ MODERN PYTHON TOOLCHAIN │ |
148 | | -├────────────────────────────────────────────────────────────────┤ |
149 | | -│ │ |
150 | | -│ LINTING & FORMATTING TYPE CHECKING │ |
151 | | -│ ┌────────────────────┐ ┌────────────────────┐ │ |
152 | | -│ │ RUFF │ │ MYPY │ │ |
153 | | -│ │ ───────────────── │ │ ───────────────── │ │ |
154 | | -│ │ • Replaces Black │ │ • Strict mode │ │ |
155 | | -│ │ • Replaces isort │ │ • Type inference │ │ |
156 | | -│ │ • Replaces Flake8 │ │ • Plugin support │ │ |
157 | | -│ │ • 10-100x faster │ │ • IDE integration │ │ |
158 | | -│ └────────────────────┘ └────────────────────┘ │ |
159 | | -│ │ |
160 | | -│ TESTING SECURITY │ |
161 | | -│ ┌────────────────────┐ ┌────────────────────┐ │ |
162 | | -│ │ PYTEST │ │ BANDIT │ │ |
163 | | -│ │ ───────────────── │ │ ───────────────── │ │ |
164 | | -│ │ • Async support │ │ • SAST scanning │ │ |
165 | | -│ │ • Coverage report │ │ • OWASP checks │ │ |
166 | | -│ │ • Fixtures │ │ • CI integration │ │ |
167 | | -│ │ • Parameterized │ │ • Custom rules │ │ |
168 | | -│ └────────────────────┘ └────────────────────┘ │ |
169 | | -│ │ |
170 | | -└────────────────────────────────────────────────────────────────┘ |
| 154 | +```mermaid |
| 155 | +%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#e8f5e9', 'primaryBorderColor': '#2e7d32'}}}%% |
| 156 | +flowchart TB |
| 157 | + subgraph TOOLCHAIN["🐍 MODERN PYTHON TOOLCHAIN"] |
| 158 | + direction TB |
| 159 | + subgraph ROW1[" "] |
| 160 | + direction LR |
| 161 | + subgraph RUFF["🔍 RUFF<br/>Linting & Formatting"] |
| 162 | + R1["✓ Replaces Black"] |
| 163 | + R2["✓ Replaces isort"] |
| 164 | + R3["✓ Replaces Flake8"] |
| 165 | + R4["⚡ 10-100x faster"] |
| 166 | + end |
| 167 | + subgraph MYPY["🔷 MYPY<br/>Type Checking"] |
| 168 | + M1["✓ Strict mode"] |
| 169 | + M2["✓ Type inference"] |
| 170 | + M3["✓ Plugin support"] |
| 171 | + M4["✓ IDE integration"] |
| 172 | + end |
| 173 | + end |
| 174 | + subgraph ROW2[" "] |
| 175 | + direction LR |
| 176 | + subgraph PYTEST["🧪 PYTEST<br/>Testing"] |
| 177 | + P1["✓ Async support"] |
| 178 | + P2["✓ Coverage report"] |
| 179 | + P3["✓ Fixtures"] |
| 180 | + P4["✓ Parameterized"] |
| 181 | + end |
| 182 | + subgraph BANDIT["🔒 BANDIT<br/>Security"] |
| 183 | + B1["✓ SAST scanning"] |
| 184 | + B2["✓ OWASP checks"] |
| 185 | + B3["✓ CI integration"] |
| 186 | + B4["✓ Custom rules"] |
| 187 | + end |
| 188 | + end |
| 189 | + end |
| 190 | +
|
| 191 | + style TOOLCHAIN fill:#fafafa,stroke:#424242 |
| 192 | + style RUFF fill:#d7ff64,stroke:#827717 |
| 193 | + style MYPY fill:#bbdefb,stroke:#1565c0 |
| 194 | + style PYTEST fill:#fff9c4,stroke:#f9a825 |
| 195 | + style BANDIT fill:#ffcdd2,stroke:#c62828 |
| 196 | + style ROW1 fill:transparent,stroke:transparent |
| 197 | + style ROW2 fill:transparent,stroke:transparent |
171 | 198 | ``` |
172 | 199 |
|
173 | 200 | --- |
@@ -207,32 +234,34 @@ dev = [ |
207 | 234 |
|
208 | 235 | ## 🔄 Development Workflow |
209 | 236 |
|
210 | | -``` |
211 | | -┌─────────────────────────────────────────────────────────────┐ |
212 | | -│ COMMIT LIFECYCLE │ |
213 | | -├─────────────────────────────────────────────────────────────┤ |
214 | | -│ │ |
215 | | -│ git add . │ |
216 | | -│ │ │ |
217 | | -│ ▼ │ |
218 | | -│ git commit -m "feat: add feature" │ |
219 | | -│ │ │ |
220 | | -│ ▼ │ |
221 | | -│ ┌─────────────────────────────────────────────────────┐ │ |
222 | | -│ │ PRE-COMMIT HOOKS RUN │ │ |
223 | | -│ ├─────────────────────────────────────────────────────┤ │ |
224 | | -│ │ 1. ruff check --fix (auto-fix lint issues) │ │ |
225 | | -│ │ 2. ruff format (format code) │ │ |
226 | | -│ │ 3. mypy (type check) │ │ |
227 | | -│ │ 4. bandit (security scan) │ │ |
228 | | -│ │ 5. commitizen (validate message) │ │ |
229 | | -│ └─────────────────────────────────────────────────────┘ │ |
230 | | -│ │ │ |
231 | | -│ ▼ │ |
232 | | -│ ✅ Commit succeeds (all checks pass) │ |
233 | | -│ ❌ Commit blocked (fix issues and retry) │ |
234 | | -│ │ |
235 | | -└─────────────────────────────────────────────────────────────┘ |
| 237 | +```mermaid |
| 238 | +flowchart TD |
| 239 | + A["📝 <b>git add .</b><br/><small>Stage changes</small>"] --> B["💬 <b>git commit -m 'feat: ...'</b><br/><small>Create commit</small>"] |
| 240 | +
|
| 241 | + B --> HOOKS |
| 242 | +
|
| 243 | + subgraph HOOKS["🔗 PRE-COMMIT HOOKS"] |
| 244 | + direction TB |
| 245 | + H1["1️⃣ <b>ruff check --fix</b><br/><small>Auto-fix lint issues</small>"] |
| 246 | + H2["2️⃣ <b>ruff format</b><br/><small>Format code</small>"] |
| 247 | + H3["3️⃣ <b>mypy</b><br/><small>Type check</small>"] |
| 248 | + H4["4️⃣ <b>bandit</b><br/><small>Security scan</small>"] |
| 249 | + H5["5️⃣ <b>commitizen</b><br/><small>Validate message</small>"] |
| 250 | + H1 --> H2 --> H3 --> H4 --> H5 |
| 251 | + end |
| 252 | +
|
| 253 | + HOOKS --> CHECK{All Checks<br/>Pass?} |
| 254 | +
|
| 255 | + CHECK -->|"✅ Yes"| SUCCESS["🎉 <b>Commit Succeeds</b><br/><small>Changes recorded</small>"] |
| 256 | + CHECK -->|"❌ No"| FAIL["🔧 <b>Commit Blocked</b><br/><small>Fix issues & retry</small>"] |
| 257 | + FAIL --> A |
| 258 | +
|
| 259 | + style A fill:#e3f2fd,stroke:#1565c0 |
| 260 | + style B fill:#e3f2fd,stroke:#1565c0 |
| 261 | + style HOOKS fill:#fff3e0,stroke:#e65100 |
| 262 | + style CHECK fill:#f3e5f5,stroke:#7b1fa2 |
| 263 | + style SUCCESS fill:#e8f5e9,stroke:#2e7d32 |
| 264 | + style FAIL fill:#ffebee,stroke:#c62828 |
236 | 265 | ``` |
237 | 266 |
|
238 | 267 | ### Commands Reference |
|
0 commit comments