11# GitHub Copilot Instructions
22
3- > ** ⚡ Token Efficiency Note** : This is a minimal pointer file (~ 500 tokens, auto-loaded by Copilot).
4- > For complete operational details, reference: ` #file:AGENTS.md ` (~ 2,500 tokens, loaded on-demand)
3+ > ** ⚡ Token Efficiency Note** : This is a minimal pointer file (~ 500 tokens, auto-loaded by Copilot).
4+ > For complete operational details, reference: ` #file:AGENTS.md ` (~ 2,500 tokens, loaded on-demand)
55> For specialized knowledge, use: ` #file:SKILLS/<skill-name>/SKILL.md ` (loaded on-demand when needed)
66
77## 🎯 Quick Context
88
9- ** Project** : FastAPI REST API demonstrating modern Python async patterns
10- ** Stack** : Python 3.13 • FastAPI • SQLAlchemy (async) • SQLite • Docker • pytest
11- ** Pattern** : Routes → Services → Database (layered architecture)
9+ ** Project** : FastAPI REST API demonstrating modern Python async patterns
10+ ** Stack** : Python 3.13 • FastAPI • SQLAlchemy (async) • SQLite • Docker • pytest
11+ ** Pattern** : Routes → Services → Database (layered architecture)
1212** Philosophy** : Learning-focused PoC emphasizing async/await and type safety
1313
1414## 📐 Core Conventions
2121
2222## 🏗️ Architecture at a Glance
2323
24- ```
24+ ``` text
2525Route → Service → Database
2626 ↓ ↓
2727Cache Session
@@ -31,7 +31,7 @@ Cache Session
3131- ** Services** : Async database operations via SQLAlchemy
3232- ** Database** : SQLite with async support (` aiosqlite ` )
3333- ** Models** : Pydantic for validation, SQLAlchemy for ORM
34- - ** Cache** : aiocache SimpleMemoryCache (10min/1hr TTL )
34+ - ** Cache** : aiocache SimpleMemoryCache (TTL: 600s / 10 min )
3535
3636## ✅ Copilot Should
3737
@@ -56,28 +56,26 @@ Cache Session
5656
5757``` bash
5858# Run with hot reload
59- uvicorn main:app --reload --host 0.0.0.0 --port 8000
59+ uvicorn main:app --reload --host 0.0.0.0 --port 9000
6060
6161# Test with coverage
6262pytest --cov=. --cov-report=term-missing
6363
6464# Docker
6565docker compose up
6666
67- # Swagger: http://localhost:8000 /docs
67+ # Swagger: http://localhost:9000 /docs
6868```
6969
7070## 📚 Need More Detail?
7171
72- ** For operational procedures** : Load ` #file:AGENTS.md `
73- ** For Docker expertise** : * (Planned)* ` #file:SKILLS/docker-containerization/SKILL.md `
72+ ** For operational procedures** : Load ` #file:AGENTS.md `
73+ ** For Docker expertise** : * (Planned)* ` #file:SKILLS/docker-containerization/SKILL.md `
7474** For testing patterns** : * (Planned)* ` #file:SKILLS/testing-patterns/SKILL.md `
7575
7676---
7777
7878💡 ** Why this structure?** Copilot auto-loads this file on every chat (~ 500 tokens). Loading ` AGENTS.md ` or ` SKILLS/ ` explicitly gives you deep context only when needed, saving 80% of your token budget!
79- 5 . ** Caching** : In-memory cache (10 min TTL) with ` X-Cache ` headers (HIT/MISS)
80- 6 . ** Async/Await** : All database operations are async
8179
8280## Coding Guidelines
8381
@@ -93,13 +91,15 @@ docker compose up
9391### File Exclusions
9492
9593Black and flake8 exclude:
94+
9695- ` .venv ` , ` .git ` , ` .github ` , ` .pytest_cache ` , ` __pycache__ `
9796- ` assets/ ` , ` htmlcov/ ` , ` postman_collections/ ` , ` scripts/ ` , ` storage/ `
9897- Exception: ` tests/test_main.py ` allows E501 (long lines for test names)
9998
10099### Commit Conventions
101100
102101Follow ** Conventional Commits** (enforced by commitlint):
102+
103103- ` feat: ` for new features
104104- ` fix: ` for bug fixes
105105- ` chore: ` for maintenance/tooling
@@ -163,17 +163,18 @@ docker compose down -v
163163
164164## API Endpoints
165165
166- | Method | Path | Description | Cache |
167- | --------| -------------------------------------| ------------------------------| -------|
168- | GET | ` /health ` | Health check | No |
169- | GET | ` /players/ ` | Get all players | Yes |
170- | GET | ` /players/{player_id} ` | Get player by ID | No |
171- | GET | ` /players/squadnumber/{squad_number} ` | Get player by squad number | No |
172- | POST | ` /players/ ` | Create new player | Clears|
173- | PUT | ` /players/{player_id} ` | Update existing player | Clears|
174- | DELETE | ` /players/{player_id} ` | Delete player | Clears|
166+ | Method | Path | Description | Cache |
167+ | --------| -------------------------------------- | ------------------------------| -------|
168+ | GET | ` /health ` | Health check | No |
169+ | GET | ` /players/ ` | Get all players | Yes |
170+ | GET | ` /players/{player_id} ` | Get player by ID | No |
171+ | GET | ` /players/squadnumber/{squad_number} ` | Get player by squad number | No |
172+ | POST | ` /players/ ` | Create new player | Clears|
173+ | PUT | ` /players/{player_id} ` | Update existing player | Clears|
174+ | DELETE | ` /players/{player_id} ` | Delete player | Clears|
175175
176176** Cache Notes** :
177+
177178- Cache key: ` "players" ` , TTL: 600s (10 min)
178179- Cache is cleared on POST/PUT/DELETE operations
179180- Response header ` X-Cache: HIT ` or ` MISS ` indicates cache status
@@ -189,6 +190,7 @@ docker compose down -v
189190## CI/CD Pipeline
190191
191192GitHub Actions workflow (` .github/workflows/python-app.yml ` ):
193+
1921941 . ** Lint Job** : Commitlint → Flake8 → Black (check mode)
1931952 . ** Test Job** : pytest with coverage report generation
1941963 . ** Coverage Job** : Upload to Codecov and Codacy (only for same-repo PRs)
@@ -198,18 +200,21 @@ GitHub Actions workflow (`.github/workflows/python-app.yml`):
198200## Common Pitfalls & Solutions
199201
2002021 . ** Virtual Environment** : Always activate ` .venv ` before running black, flake8, or pytest:
203+
201204 ``` bash
202205 source .venv/bin/activate
203206 ```
204207
2052082 . ** FastAPI Route Ordering** : Static routes MUST be defined before dynamic path parameters. Place ` /players/statistics ` before ` /players/{player_id} ` , or FastAPI will try to parse "statistics" as a player_id.
209+
206210 ``` python
207211 # CORRECT order:
208212 @api_router.get (" /players/statistics" ) # Static route first
209213 @api_router.get (" /players/{player_id} " ) # Dynamic route after
210214 ```
211215
2122163 . ** SQLAlchemy 2.0 Migration** : Use ` select() ` not ` session.query() ` . Example:
217+
213218 ``` python
214219 statement = select(Player).where(Player.id == player_id)
215220 result = await async_session.execute(statement)
@@ -220,6 +225,7 @@ GitHub Actions workflow (`.github/workflows/python-app.yml`):
2202255 . ** Cache Invalidation** : Remember to call ` await simple_memory_cache.clear(CACHE_KEY) ` after mutations (POST/PUT/DELETE).
221226
2222276 . ** Pydantic Model Conversion** : Use ` player_model.model_dump() ` to convert Pydantic to dict for SQLAlchemy:
228+
223229 ``` python
224230 player = Player(** player_model.model_dump())
225231 ```
@@ -231,11 +237,13 @@ GitHub Actions workflow (`.github/workflows/python-app.yml`):
231237## VS Code Configuration
232238
233239Recommended extensions (` .vscode/extensions.json ` ):
240+
234241- ` ms-python.python ` , ` ms-python.flake8 ` , ` ms-python.black-formatter `
235242- ` github.vscode-pull-request-github ` , ` github.vscode-github-actions `
236243- ` ms-azuretools.vscode-containers ` , ` sonarsource.sonarlint-vscode `
237244
238245Settings (` .vscode/settings.json ` ):
246+
239247- Auto-format on save with Black
240248- Pytest enabled (not unittest)
241249- Flake8 integration with matching CLI args
@@ -245,6 +253,6 @@ Settings (`.vscode/settings.json`):
245253
246254- ** Postman Collection** : ` postman_collections/python-samples-fastapi-restful.postman_collection.json `
247255- ** Architecture Diagram** : ` assets/images/structure.svg `
248- - ** FastAPI Docs** : https://fastapi.tiangolo.com/
249- - ** SQLAlchemy 2.0** : https://docs.sqlalchemy.org/en/20/
250- - ** Conventional Commits** : https://www.conventionalcommits.org/
256+ - ** FastAPI Docs** : < https://fastapi.tiangolo.com/ >
257+ - ** SQLAlchemy 2.0** : < https://docs.sqlalchemy.org/en/20/ >
258+ - ** Conventional Commits** : < https://www.conventionalcommits.org/ >
0 commit comments