FastAPI-fastkit 1.4.1__py3-none-any.whl → 1.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. fastapi_fastkit/__init__.py +1 -1
  2. fastapi_fastkit/backend/main.py +35 -40
  3. fastapi_fastkit/backend/route_generators.py +163 -0
  4. fastapi_fastkit/backend/route_wiring.py +117 -0
  5. fastapi_fastkit/cli.py +13 -2
  6. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/pyproject.toml-tpl +2 -2
  7. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/requirements.txt-tpl +2 -2
  8. fastapi_fastkit/fastapi_project_template/fastapi-auth-jwt/pyproject.toml-tpl +3 -3
  9. fastapi_fastkit/fastapi_project_template/fastapi-auth-jwt/requirements.txt-tpl +2 -2
  10. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/pyproject.toml-tpl +2 -2
  11. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/requirements.txt-tpl +2 -2
  12. fastapi_fastkit/fastapi_project_template/fastapi-default/pyproject.toml-tpl +2 -2
  13. fastapi_fastkit/fastapi_project_template/fastapi-default/requirements.txt-tpl +2 -2
  14. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/pyproject.toml-tpl +2 -2
  15. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/requirements.txt-tpl +3 -3
  16. fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/pyproject.toml-tpl +2 -2
  17. fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/requirements.txt-tpl +2 -2
  18. fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/src/app/api/router.py-tpl +1 -1
  19. fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/src/app/domains/items/router.py-tpl +1 -1
  20. fastapi_fastkit/fastapi_project_template/fastapi-domain-starter/tests/conftest.py-tpl +16 -4
  21. fastapi_fastkit/fastapi_project_template/fastapi-empty/pyproject.toml-tpl +2 -2
  22. fastapi_fastkit/fastapi_project_template/fastapi-empty/requirements.txt-tpl +2 -2
  23. fastapi_fastkit/fastapi_project_template/fastapi-llm-agent/pyproject.toml-tpl +2 -2
  24. fastapi_fastkit/fastapi_project_template/fastapi-llm-agent/requirements.txt-tpl +1 -1
  25. fastapi_fastkit/fastapi_project_template/fastapi-mcp/pyproject.toml-tpl +4 -4
  26. fastapi_fastkit/fastapi_project_template/fastapi-mcp/requirements.txt-tpl +5 -5
  27. fastapi_fastkit/fastapi_project_template/fastapi-mcp/setup.cfg-tpl +2 -2
  28. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/pyproject.toml-tpl +2 -2
  29. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/requirements.txt-tpl +2 -2
  30. fastapi_fastkit/fastapi_project_template/fastapi-single-module/requirements.txt-tpl +1 -1
  31. fastapi_fastkit/fastapi_project_template/fastapi-sqlmodel/pyproject.toml-tpl +2 -2
  32. fastapi_fastkit/fastapi_project_template/fastapi-sqlmodel/requirements.txt-tpl +1 -1
  33. fastapi_fastkit/fastapi_project_template/modules/domain/__init__.py-tpl +10 -0
  34. fastapi_fastkit/fastapi_project_template/modules/domain/models.py-tpl +11 -0
  35. fastapi_fastkit/fastapi_project_template/modules/domain/repository.py-tpl +50 -0
  36. fastapi_fastkit/fastapi_project_template/modules/domain/router.py-tpl +66 -0
  37. fastapi_fastkit/fastapi_project_template/modules/domain/schemas.py-tpl +16 -0
  38. fastapi_fastkit/fastapi_project_template/modules/domain/service.py-tpl +47 -0
  39. {fastapi_fastkit-1.4.1.dist-info → fastapi_fastkit-1.5.1.dist-info}/METADATA +4 -2
  40. {fastapi_fastkit-1.4.1.dist-info → fastapi_fastkit-1.5.1.dist-info}/RECORD +43 -35
  41. {fastapi_fastkit-1.4.1.dist-info → fastapi_fastkit-1.5.1.dist-info}/WHEEL +1 -1
  42. {fastapi_fastkit-1.4.1.dist-info → fastapi_fastkit-1.5.1.dist-info}/entry_points.txt +0 -0
  43. {fastapi_fastkit-1.4.1.dist-info → fastapi_fastkit-1.5.1.dist-info}/licenses/LICENSE +0 -0
@@ -2,19 +2,31 @@
2
2
  # pytest fixtures for <project_name>.
3
3
  # --------------------------------------------------------------------------
4
4
  from collections.abc import Generator
5
+ from importlib import import_module
6
+ from pkgutil import iter_modules
5
7
 
6
8
  import pytest
7
9
  from fastapi.testclient import TestClient
10
+ from src.app import domains
8
11
  from src.app.domains.items.repository import ItemRepository
9
12
  from src.app.main import app
10
13
 
11
14
 
12
- @pytest.fixture(autouse=True)
13
- def reset_items_store() -> Generator[None, None, None]:
14
- """Each test starts with an empty items store."""
15
+ def reset_stores() -> None:
15
16
  ItemRepository().reset()
17
+ for module in iter_modules(domains.__path__, prefix=f"{domains.__name__}."):
18
+ if module.ispkg:
19
+ domain = import_module(module.name)
20
+ reset = getattr(getattr(domain, "service", None), "reset_store", None)
21
+ if reset is not None:
22
+ reset()
23
+
24
+
25
+ @pytest.fixture(autouse=True)
26
+ def reset_domain_stores() -> Generator[None, None, None]:
27
+ reset_stores()
16
28
  yield
17
- ItemRepository().reset()
29
+ reset_stores()
18
30
 
19
31
 
20
32
  @pytest.fixture
@@ -19,7 +19,7 @@ dependencies = [
19
19
  dev = [
20
20
  "pytest>=9.1.1",
21
21
  "httpx>=0.28.1",
22
- "black>=26.5.1",
22
+ "black>=26.10.1",
23
23
  "isort>=9.0.1",
24
24
  "mypy>=2.3.1",
25
25
  ]
@@ -28,7 +28,7 @@ dev = [
28
28
  dev = [
29
29
  "pytest>=9.1.1",
30
30
  "httpx>=0.28.1",
31
- "black>=26.5.1",
31
+ "black>=26.10.1",
32
32
  "isort>=9.0.1",
33
33
  "mypy>=2.3.1",
34
34
  ]
@@ -2,8 +2,8 @@ annotated-doc==0.0.5
2
2
  annotated-types==0.8.0
3
3
  anyio==4.15.0
4
4
  ast-serialize==0.9.0
5
- black==26.5.1
6
- certifi==2026.7.22
5
+ black==26.10.1
6
+ certifi==2026.10.23
7
7
  click==8.5.0
8
8
  fastapi==0.141.1
9
9
  h11==0.16.0
@@ -23,7 +23,7 @@ dev = [
23
23
  "pytest>=9.1.1",
24
24
  "pytest-asyncio>=1.4.0",
25
25
  "httpx>=0.28.1",
26
- "black>=26.5.1",
26
+ "black>=26.10.1",
27
27
  "isort>=9.0.1",
28
28
  "mypy>=2.3.1",
29
29
  ]
@@ -33,7 +33,7 @@ dev = [
33
33
  "pytest>=9.1.1",
34
34
  "pytest-asyncio>=1.4.0",
35
35
  "httpx>=0.28.1",
36
- "black>=26.5.1",
36
+ "black>=26.10.1",
37
37
  "isort>=9.0.1",
38
38
  "mypy>=2.3.1",
39
39
  ]
@@ -10,6 +10,6 @@ sse-starlette==3.4.10
10
10
  pytest==9.1.1
11
11
  pytest-asyncio==1.4.0
12
12
  httpx==0.28.1
13
- black==26.5.1
13
+ black==26.10.1
14
14
  isort==9.0.1
15
15
  mypy==2.3.1
@@ -16,9 +16,9 @@ dependencies = [
16
16
  "SQLAlchemy>=2.0.52",
17
17
  "python-dotenv>=1.2.3",
18
18
  "fastapi-mcp>=0.3.7,<0.4.0",
19
- "mcp>=1.29.1,<2.0.0",
19
+ "mcp>=1.30.0,<2.0.0",
20
20
  "pwdlib[argon2]>=0.3.1",
21
- "PyJWT[crypto]>=2.13.0",
21
+ "PyJWT[crypto]>=2.15.1",
22
22
  "python-multipart>=0.0.32",
23
23
  ]
24
24
 
@@ -27,7 +27,7 @@ dev = [
27
27
  "pytest>=9.1.1",
28
28
  "pytest-cov>=7.1.0",
29
29
  "httpx>=0.28.1",
30
- "black>=26.5.1",
30
+ "black>=26.10.1",
31
31
  "isort>=9.0.1",
32
32
  "mypy>=2.3.1",
33
33
  "PyYAML>=6.0.3",
@@ -38,7 +38,7 @@ dev = [
38
38
  "pytest>=9.1.1",
39
39
  "pytest-cov>=7.1.0",
40
40
  "httpx>=0.28.1",
41
- "black>=26.5.1",
41
+ "black>=26.10.1",
42
42
  "isort>=9.0.1",
43
43
  "mypy>=2.3.1",
44
44
  "PyYAML>=6.0.3",
@@ -5,8 +5,8 @@ argon2-cffi==25.1.0
5
5
  argon2-cffi-bindings==26.1.0
6
6
  ast-serialize==0.9.0
7
7
  attrs==26.1.0
8
- black==26.5.1
9
- certifi==2026.7.22
8
+ black==26.10.1
9
+ certifi==2026.10.23
10
10
  cffi==2.1.1
11
11
  charset-normalizer==3.5.1
12
12
  click==8.5.0
@@ -26,7 +26,7 @@ jsonschema==4.26.0
26
26
  jsonschema-specifications==2025.9.1
27
27
  librt==0.15.0
28
28
  markdown-it-py==4.2.0
29
- mcp==1.29.1
29
+ mcp==1.30.0
30
30
  mdurl==0.1.2
31
31
  mypy==2.3.1
32
32
  mypy-extensions==1.1.0
@@ -40,7 +40,7 @@ pydantic==2.13.5
40
40
  pydantic-core==2.46.5
41
41
  pydantic-settings==2.15.0
42
42
  pygments==2.21.0
43
- PyJWT==2.13.0
43
+ PyJWT==2.15.1
44
44
  pytest==9.1.1
45
45
  pytest-cov==7.1.0
46
46
  python-dotenv==1.2.3
@@ -59,7 +59,7 @@ tomli==2.4.1
59
59
  typer==0.27.2
60
60
  typing-extensions==4.16.0
61
61
  typing-inspection==0.4.4
62
- urllib3==2.7.0
62
+ urllib3==2.8.0
63
63
  uvicorn==0.52.4
64
64
  uvloop==0.22.1
65
65
  watchfiles==1.2.0
@@ -29,7 +29,7 @@ install_requires =
29
29
  pydantic>=2.10.6
30
30
  pydantic-settings>=2.7.1
31
31
  python-dotenv>=1.0.1
32
- PyJWT[crypto]>=2.10.0
32
+ PyJWT[crypto]>=2.15.1
33
33
  pwdlib[argon2]>=0.3.1
34
34
  python-multipart>=0.0.17
35
35
 
@@ -37,7 +37,7 @@ install_requires =
37
37
  dev =
38
38
  pytest>=8.3.4
39
39
  pytest-cov>=4.0.0
40
- black>=25.1.0
40
+ black>=26.10.1
41
41
  isort>=6.0.0
42
42
  mypy>=1.15.0
43
43
  httpx>=0.28.1
@@ -25,7 +25,7 @@ dependencies = [
25
25
  dev = [
26
26
  "pytest>=9.1.1",
27
27
  "httpx>=0.28.1",
28
- "black>=26.5.1",
28
+ "black>=26.10.1",
29
29
  "isort>=9.0.1",
30
30
  "mypy>=2.3.1",
31
31
  "PyYAML>=6.0.3",
@@ -35,7 +35,7 @@ dev = [
35
35
  dev = [
36
36
  "pytest>=9.1.1",
37
37
  "httpx>=0.28.1",
38
- "black>=26.5.1",
38
+ "black>=26.10.1",
39
39
  "isort>=9.0.1",
40
40
  "mypy>=2.3.1",
41
41
  "PyYAML>=6.0.3",
@@ -3,8 +3,8 @@ annotated-doc==0.0.5
3
3
  annotated-types==0.8.0
4
4
  anyio==4.15.0
5
5
  ast-serialize==0.9.0
6
- black==26.5.1
7
- certifi==2026.7.22
6
+ black==26.10.1
7
+ certifi==2026.10.23
8
8
  click==8.5.0
9
9
  fastapi==0.141.1
10
10
  h11==0.16.0
@@ -1,7 +1,7 @@
1
1
  annotated-doc==0.0.5
2
2
  annotated-types==0.8.0
3
3
  anyio==4.15.0
4
- certifi==2026.7.22
4
+ certifi==2026.10.23
5
5
  click==8.5.0
6
6
  fastapi==0.141.1
7
7
  h11==0.16.0
@@ -29,7 +29,7 @@ dev = [
29
29
  "pytest>=9.1.1",
30
30
  "pytest-asyncio>=1.4.0",
31
31
  "httpx>=0.28.1",
32
- "black>=26.5.1",
32
+ "black>=26.10.1",
33
33
  "isort>=9.0.1",
34
34
  "mypy>=2.3.1",
35
35
  ]
@@ -39,7 +39,7 @@ dev = [
39
39
  "pytest>=9.1.1",
40
40
  "pytest-asyncio>=1.4.0",
41
41
  "httpx>=0.28.1",
42
- "black>=26.5.1",
42
+ "black>=26.10.1",
43
43
  "isort>=9.0.1",
44
44
  "mypy>=2.3.1",
45
45
  ]
@@ -16,6 +16,6 @@ greenlet==3.5.5
16
16
  pytest==9.1.1
17
17
  pytest-asyncio==1.4.0
18
18
  httpx==0.28.1
19
- black==26.5.1
19
+ black==26.10.1
20
20
  isort==9.0.1
21
21
  mypy==2.3.1
@@ -0,0 +1,10 @@
1
+ # --------------------------------------------------------------------------
2
+ # <new_route> domain.
3
+ # --------------------------------------------------------------------------
4
+ from <domain_module> import ( # noqa: F401
5
+ models,
6
+ repository,
7
+ router,
8
+ schemas,
9
+ service,
10
+ )
@@ -0,0 +1,11 @@
1
+ # --------------------------------------------------------------------------
2
+ # <new_route> domain models.
3
+ # --------------------------------------------------------------------------
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ @dataclass
9
+ class <entity_class>:
10
+ id: int
11
+ name: str
@@ -0,0 +1,50 @@
1
+ # --------------------------------------------------------------------------
2
+ # <new_route> repository.
3
+ #
4
+ # Data is stored in memory, lost on restart, and not shared between workers.
5
+ # --------------------------------------------------------------------------
6
+
7
+ from threading import Lock
8
+
9
+ from <domain_module>.models import <entity_class>
10
+
11
+
12
+ class <entity_class>Repository:
13
+ """In-memory storage for <entity_class>."""
14
+
15
+ def __init__(self) -> None:
16
+ self._data: dict[int, <entity_class>] = {}
17
+ self._next_id = 1
18
+ self._lock = Lock()
19
+
20
+ def list_all(self) -> list[<entity_class>]:
21
+ with self._lock:
22
+ return list(self._data.values())
23
+
24
+ def get(self, entity_id: int) -> <entity_class> | None:
25
+ with self._lock:
26
+ return self._data.get(entity_id)
27
+
28
+ def add(self, name: str) -> <entity_class>:
29
+ with self._lock:
30
+ entity = <entity_class>(id=self._next_id, name=name)
31
+ self._data[entity.id] = entity
32
+ self._next_id += 1
33
+ return entity
34
+
35
+ def replace(self, entity_id: int, name: str) -> <entity_class> | None:
36
+ with self._lock:
37
+ if entity_id not in self._data:
38
+ return None
39
+ entity = <entity_class>(id=entity_id, name=name)
40
+ self._data[entity_id] = entity
41
+ return entity
42
+
43
+ def delete(self, entity_id: int) -> bool:
44
+ with self._lock:
45
+ return self._data.pop(entity_id, None) is not None
46
+
47
+ def reset(self) -> None:
48
+ with self._lock:
49
+ self._data.clear()
50
+ self._next_id = 1
@@ -0,0 +1,66 @@
1
+ # --------------------------------------------------------------------------
2
+ # <new_route> API routes.
3
+ # --------------------------------------------------------------------------
4
+
5
+ from fastapi import APIRouter, Depends, HTTPException, Response, status
6
+ from <domain_module>.schemas import <entity_class>Create, <entity_class>Read
7
+ from <domain_module>.service import <entity_class>NotFoundError, <entity_class>Service
8
+
9
+ router = APIRouter()
10
+
11
+
12
+ def get_<new_route>_service() -> <entity_class>Service:
13
+ return <entity_class>Service()
14
+
15
+
16
+ @router.get("", response_model=list[<entity_class>Read])
17
+ def list_<new_route>(
18
+ service: <entity_class>Service = Depends(get_<new_route>_service),
19
+ ) -> list[<entity_class>Read]:
20
+ return [<entity_class>Read.model_validate(entity) for entity in service.list_<new_route>()]
21
+
22
+
23
+ @router.get("/{entity_id}", response_model=<entity_class>Read)
24
+ def get_<new_route>(
25
+ entity_id: int, service: <entity_class>Service = Depends(get_<new_route>_service)
26
+ ) -> <entity_class>Read:
27
+ try:
28
+ return <entity_class>Read.model_validate(service.get_<new_route>(entity_id))
29
+ except <entity_class>NotFoundError as exc:
30
+ raise HTTPException(
31
+ status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)
32
+ ) from exc
33
+
34
+
35
+ @router.post("", response_model=<entity_class>Read, status_code=status.HTTP_201_CREATED)
36
+ def create_<new_route>(
37
+ payload: <entity_class>Create, service: <entity_class>Service = Depends(get_<new_route>_service)
38
+ ) -> <entity_class>Read:
39
+ return <entity_class>Read.model_validate(service.create_<new_route>(payload))
40
+
41
+
42
+ @router.put("/{entity_id}", response_model=<entity_class>Read)
43
+ def replace_<new_route>(
44
+ entity_id: int,
45
+ payload: <entity_class>Create,
46
+ service: <entity_class>Service = Depends(get_<new_route>_service),
47
+ ) -> <entity_class>Read:
48
+ try:
49
+ return <entity_class>Read.model_validate(service.replace_<new_route>(entity_id, payload))
50
+ except <entity_class>NotFoundError as exc:
51
+ raise HTTPException(
52
+ status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)
53
+ ) from exc
54
+
55
+
56
+ @router.delete("/{entity_id}", status_code=status.HTTP_204_NO_CONTENT)
57
+ def delete_<new_route>(
58
+ entity_id: int, service: <entity_class>Service = Depends(get_<new_route>_service)
59
+ ) -> Response:
60
+ try:
61
+ service.delete_<new_route>(entity_id)
62
+ except <entity_class>NotFoundError as exc:
63
+ raise HTTPException(
64
+ status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)
65
+ ) from exc
66
+ return Response(status_code=status.HTTP_204_NO_CONTENT)
@@ -0,0 +1,16 @@
1
+ # --------------------------------------------------------------------------
2
+ # <new_route> API schemas.
3
+ # --------------------------------------------------------------------------
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+
8
+ class <entity_class>Create(BaseModel):
9
+ name: str = Field(min_length=1, max_length=120)
10
+
11
+
12
+ class <entity_class>Read(BaseModel):
13
+ id: int
14
+ name: str
15
+
16
+ model_config = ConfigDict(from_attributes=True)
@@ -0,0 +1,47 @@
1
+ # --------------------------------------------------------------------------
2
+ # <new_route> service.
3
+ # --------------------------------------------------------------------------
4
+
5
+ from <domain_module>.models import <entity_class>
6
+ from <domain_module>.repository import <entity_class>Repository
7
+ from <domain_module>.schemas import <entity_class>Create
8
+
9
+ # Share the default repository between requests.
10
+ _default_repository = <entity_class>Repository()
11
+
12
+
13
+ def reset_store() -> None:
14
+ _default_repository.reset()
15
+
16
+
17
+ class <entity_class>NotFoundError(Exception):
18
+ """Raised when <entity_class> is not found."""
19
+
20
+
21
+ class <entity_class>Service:
22
+ """Business logic for <entity_class>."""
23
+
24
+ def __init__(self, repository: <entity_class>Repository | None = None) -> None:
25
+ self._repository = repository if repository is not None else _default_repository
26
+
27
+ def list_<new_route>(self) -> list[<entity_class>]:
28
+ return self._repository.list_all()
29
+
30
+ def get_<new_route>(self, entity_id: int) -> <entity_class>:
31
+ entity = self._repository.get(entity_id)
32
+ if entity is None:
33
+ raise <entity_class>NotFoundError(f"<entity_class> {entity_id} does not exist")
34
+ return entity
35
+
36
+ def create_<new_route>(self, payload: <entity_class>Create) -> <entity_class>:
37
+ return self._repository.add(name=payload.name)
38
+
39
+ def replace_<new_route>(self, entity_id: int, payload: <entity_class>Create) -> <entity_class>:
40
+ entity = self._repository.replace(entity_id=entity_id, name=payload.name)
41
+ if entity is None:
42
+ raise <entity_class>NotFoundError(f"<entity_class> {entity_id} does not exist")
43
+ return entity
44
+
45
+ def delete_<new_route>(self, entity_id: int) -> None:
46
+ if not self._repository.delete(entity_id=entity_id):
47
+ raise <entity_class>NotFoundError(f"<entity_class> {entity_id} does not exist")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: FastAPI-fastkit
3
- Version: 1.4.1
3
+ Version: 1.5.1
4
4
  Summary: Fast, easy-to-use starter kit for new users of Python and FastAPI
5
5
  Author-Email: bnbong <bbbong9@gmail.com>
6
6
  License: MIT
@@ -15,11 +15,13 @@ Requires-Dist: jinja2>=3.1
15
15
  Provides-Extra: dev
16
16
  Requires-Dist: pytest>=9.0.3; extra == "dev"
17
17
  Requires-Dist: pytest-cov>=6.2.1; extra == "dev"
18
- Requires-Dist: black>=26.3.1; extra == "dev"
18
+ Requires-Dist: black>=26.10.1; extra == "dev"
19
19
  Requires-Dist: pre-commit>=4.0.1; extra == "dev"
20
20
  Requires-Dist: mypy>=1.12.0; extra == "dev"
21
21
  Requires-Dist: isort>=5.13.2; extra == "dev"
22
22
  Requires-Dist: pygments>=2.20.0; extra == "dev"
23
+ Requires-Dist: virtualenv>=21.14.9; extra == "dev"
24
+ Requires-Dist: filelock>=4.2.1; extra == "dev"
23
25
  Requires-Dist: types-pyyaml>=6.0.12.20260408; extra == "dev"
24
26
  Description-Content-Type: text/markdown
25
27