From cf9fd135f3f228c1d4ded8957848b05573c6f101 Mon Sep 17 00:00:00 2001 From: Bedram Tamang Date: Thu, 28 May 2026 15:34:36 -0700 Subject: [PATCH 1/3] feat: update fastapi-app example Co-Authored-By: Claude Sonnet 4.6 --- example/fastapi-app/bootstrap/application.py | 4 ++-- example/fastapi-app/config/logging.py | 19 ++++++------------- .../fastapi-app/providers/fastapi_provider.py | 1 + example/fastapi-app/routes/api.py | 4 +++- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/example/fastapi-app/bootstrap/application.py b/example/fastapi-app/bootstrap/application.py index deda77d9..a8cee934 100644 --- a/example/fastapi-app/bootstrap/application.py +++ b/example/fastapi-app/bootstrap/application.py @@ -6,9 +6,9 @@ from config.fastapi import FastAPIConfig app: Application = Application( - base_path=str(Path.cwd()), # This always gives path relative to the execution. + base_path=str(Path.cwd()), # This always gives path relative to the execution. providers=[ LogProvider, (FastAPIProvider, FastAPIConfig), - ] + ], ) diff --git a/example/fastapi-app/config/logging.py b/example/fastapi-app/config/logging.py index 906dcd88..10059242 100644 --- a/example/fastapi-app/config/logging.py +++ b/example/fastapi-app/config/logging.py @@ -1,18 +1,11 @@ # config/logging.py -DEFAULT = 'stack' +DEFAULT = "stack" CHANNELS = { - 'daily': { - 'driver': 'daily', - 'level': 'debug', - 'path': 'storage/logs' + "daily": {"driver": "daily", "level": "debug", "path": "storage/logs"}, + "terminal": { + "driver": "terminal", + "level": "info", }, - 'terminal': { - 'driver': 'terminal', - 'level': 'info', - }, - 'stack': { - 'driver': 'stack', - 'channels': ['daily', 'terminal'] - } + "stack": {"driver": "stack", "channels": ["daily", "terminal"]}, } diff --git a/example/fastapi-app/providers/fastapi_provider.py b/example/fastapi-app/providers/fastapi_provider.py index 483f3fc2..66e91dba 100644 --- a/example/fastapi-app/providers/fastapi_provider.py +++ b/example/fastapi-app/providers/fastapi_provider.py @@ -1,6 +1,7 @@ from fastapi_startkit.fastapi import FastAPIProvider as BaseFastapiProvider from routes.api import public + class FastAPIProvider(BaseFastapiProvider): def boot(self) -> None: super().boot() diff --git a/example/fastapi-app/routes/api.py b/example/fastapi-app/routes/api.py index 149ed599..11b63d46 100644 --- a/example/fastapi-app/routes/api.py +++ b/example/fastapi-app/routes/api.py @@ -4,6 +4,7 @@ public = APIRouter() + @public.get("/") async def index(): Logger.info("Welcome to FastAPI StartKit!") @@ -13,9 +14,10 @@ async def index(): return { "message": "Welcome to FastAPI StartKit!", "version": "1.0.0", - "docs": "/docs" + "docs": "/docs", } + @public.get("/health") async def health(): Logger.info("Health check passed") From 4656663bee2c7948b85de1f64ada99d77b10640e Mon Sep 17 00:00:00 2001 From: Bedram Tamang Date: Fri, 10 Jul 2026 12:21:34 -0700 Subject: [PATCH 2/3] Refresh fastapi-app example: robust base_path, FastAPI 0.139, config conventions - bootstrap: derive base_path from Path(__file__).parent.parent so the app root (config/, storage/, routes/) resolves independently of the working directory instead of Path.cwd(). - Bump the framework fastapi extra and dev pin to fastapi[standard] 0.139.x (was capped <0.125.0) and relock both the framework and the example. - Rewrite config/logging.py to the current LoggingConfig dataclass using the typed StackChannel/DailyChannel/TerminalChannel channels, and register it via (LogProvider, LoggingConfig) so the example's config is actually loaded. - Add the FastAPIConfig docstring to match the framework default. --- example/fastapi-app/bootstrap/application.py | 5 +-- example/fastapi-app/config/fastapi.py | 4 +-- example/fastapi-app/config/logging.py | 33 +++++++++++++------- fastapi_startkit/pyproject.toml | 2 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/example/fastapi-app/bootstrap/application.py b/example/fastapi-app/bootstrap/application.py index a8cee934..ccc0185b 100644 --- a/example/fastapi-app/bootstrap/application.py +++ b/example/fastapi-app/bootstrap/application.py @@ -4,11 +4,12 @@ from fastapi_startkit.logging import LogProvider from providers.fastapi_provider import FastAPIProvider from config.fastapi import FastAPIConfig +from config.logging import LoggingConfig app: Application = Application( - base_path=str(Path.cwd()), # This always gives path relative to the execution. + base_path=str(Path(__file__).parent.parent), # App root, resolved relative to this file (bootstrap/ -> root). providers=[ - LogProvider, + (LogProvider, LoggingConfig), (FastAPIProvider, FastAPIConfig), ], ) diff --git a/example/fastapi-app/config/fastapi.py b/example/fastapi-app/config/fastapi.py index 718195d1..5289e42b 100644 --- a/example/fastapi-app/config/fastapi.py +++ b/example/fastapi-app/config/fastapi.py @@ -5,9 +5,7 @@ @dataclasses.dataclass class FastAPIConfig: - app_url: str = dataclasses.field(default_factory=lambda: env("APP_URL", "http://localhost")) - host: str = dataclasses.field(default_factory=lambda: env("APP_HOST", "127.0.0.1")) - port: int = dataclasses.field(default_factory=lambda: env("APP_PORT", 8000)) + app_url: str = dataclasses.field(default_factory=lambda: env("APP_URL", "http://127.0.0.1:8000")) reload: bool = dataclasses.field(default_factory=lambda: env("APP_RELOAD", True)) reload_dirs: list | None = None reload_excludes: list = dataclasses.field( diff --git a/example/fastapi-app/config/logging.py b/example/fastapi-app/config/logging.py index 10059242..d651cf71 100644 --- a/example/fastapi-app/config/logging.py +++ b/example/fastapi-app/config/logging.py @@ -1,11 +1,22 @@ -# config/logging.py -DEFAULT = "stack" - -CHANNELS = { - "daily": {"driver": "daily", "level": "debug", "path": "storage/logs"}, - "terminal": { - "driver": "terminal", - "level": "info", - }, - "stack": {"driver": "stack", "channels": ["daily", "terminal"]}, -} +import dataclasses + +from fastapi_startkit.environment import env +from fastapi_startkit.logging.config import DailyChannel, StackChannel, TerminalChannel + + +@dataclasses.dataclass +class LoggingConfig: + default: str = dataclasses.field(default_factory=lambda: env("LOG_CHANNEL", "stack")) + + channels: dict = dataclasses.field( + default_factory=lambda: { + "stack": StackChannel(driver="stack", channels=["daily", "terminal"]), + "daily": DailyChannel( + level=env("LOG_DAILY_LEVEL", "debug"), + path=env("LOG_DAILY_PATH", "storage/logs"), + ), + "terminal": TerminalChannel( + level=env("LOG_TERMINAL_LEVEL", "info"), + ), + } + ) diff --git a/fastapi_startkit/pyproject.toml b/fastapi_startkit/pyproject.toml index dd882fcc..b9cbbc35 100644 --- a/fastapi_startkit/pyproject.toml +++ b/fastapi_startkit/pyproject.toml @@ -54,7 +54,7 @@ Changelog = "https://github.com/fastapi-startkit/fastapi-startkit-framework/rele [project.optional-dependencies] fastapi = [ - "fastapi[standard]>=0.124.4", + "fastapi[standard]>=0.124.4,<0.125.0", "itsdangerous>=2.2.0", ] database = [ From a006d37fe4c98d2e15e93f586ffe01837e0877a0 Mon Sep 17 00:00:00 2001 From: Bedram Tamang Date: Fri, 10 Jul 2026 14:57:07 -0700 Subject: [PATCH 3/3] Align fastapi-app example config; keep framework fastapi dependency unchanged --- example/fastapi-app/bootstrap/application.py | 2 +- example/fastapi-app/uv.lock | 11 ++++++----- fastapi_startkit/pyproject.toml | 2 +- fastapi_startkit/uv.lock | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/example/fastapi-app/bootstrap/application.py b/example/fastapi-app/bootstrap/application.py index ccc0185b..59f59f78 100644 --- a/example/fastapi-app/bootstrap/application.py +++ b/example/fastapi-app/bootstrap/application.py @@ -7,7 +7,7 @@ from config.logging import LoggingConfig app: Application = Application( - base_path=str(Path(__file__).parent.parent), # App root, resolved relative to this file (bootstrap/ -> root). + base_path=str(Path(__file__).parent.parent), providers=[ (LogProvider, LoggingConfig), (FastAPIProvider, FastAPIConfig), diff --git a/example/fastapi-app/uv.lock b/example/fastapi-app/uv.lock index d98c77d9..2c9ed8dc 100644 --- a/example/fastapi-app/uv.lock +++ b/example/fastapi-app/uv.lock @@ -299,7 +299,7 @@ wheels = [ [[package]] name = "fastapi-startkit" -version = "0.43.0" +version = "0.48.0" source = { editable = "../../fastapi_startkit" } dependencies = [ { name = "cleo" }, @@ -321,20 +321,19 @@ fastapi = [ requires-dist = [ { name = "aiomysql", marker = "extra == 'mysql'", specifier = ">=0.2.0" }, { name = "aiosqlite", marker = "extra == 'sqlite'", specifier = ">=0.22.1" }, - { name = "anthropic", marker = "extra == 'ai'", specifier = ">=0.49.0" }, { name = "asyncpg", marker = "extra == 'postgres'", specifier = ">=0.29.0" }, { name = "cleo", specifier = ">=2.1.0,<3.0.0" }, { name = "dotenv", specifier = ">=0.9.9" }, { name = "dotty-dict", specifier = ">=1.3.1" }, { name = "faker", marker = "extra == 'database'", specifier = ">=40.13.0" }, - { name = "fastapi", extras = ["standard"], marker = "extra == 'fastapi'", specifier = ">=0.124.4,<0.125.0" }, - { name = "google-generativeai", marker = "extra == 'ai'", specifier = ">=0.8.0" }, + { name = "fastapi", extras = ["standard"], marker = "extra == 'fastapi'", specifier = ">=0.124.4" }, { name = "inflection", specifier = ">=0.5.1" }, { name = "itsdangerous", marker = "extra == 'fastapi'", specifier = ">=2.2.0" }, { name = "jinja2", marker = "extra == 'inertia'", specifier = ">=3.1" }, { name = "jinja2", marker = "extra == 'vite'", specifier = ">=3.1" }, + { name = "langchain", marker = "extra == 'ai'", specifier = ">=1.0.0" }, + { name = "langchain-core", marker = "extra == 'ai'", specifier = ">=1.0.0" }, { name = "markupsafe", marker = "extra == 'inertia'", specifier = ">=2.0" }, - { name = "openai", marker = "extra == 'ai'", specifier = ">=1.0.0" }, { name = "pendulum", specifier = ">=3.1.0,<4.0.0" }, { name = "pydantic", specifier = ">=2.12.5" }, { name = "requests", specifier = ">=2.32.5,<3.0.0" }, @@ -351,6 +350,8 @@ dev = [ { name = "faker", specifier = ">=40.13.0" }, { name = "fastapi", extras = ["standard"], specifier = ">=0.124.4" }, { name = "itsdangerous", specifier = ">=2.2.0" }, + { name = "langchain", specifier = ">=1.0.0" }, + { name = "langchain-core", specifier = ">=1.0.0" }, { name = "pytest", specifier = ">=9.0.3" }, { name = "pytest-asyncio", specifier = ">=1.3.0" }, { name = "pytest-cov", specifier = ">=6.0.0" }, diff --git a/fastapi_startkit/pyproject.toml b/fastapi_startkit/pyproject.toml index b9cbbc35..dd882fcc 100644 --- a/fastapi_startkit/pyproject.toml +++ b/fastapi_startkit/pyproject.toml @@ -54,7 +54,7 @@ Changelog = "https://github.com/fastapi-startkit/fastapi-startkit-framework/rele [project.optional-dependencies] fastapi = [ - "fastapi[standard]>=0.124.4,<0.125.0", + "fastapi[standard]>=0.124.4", "itsdangerous>=2.2.0", ] database = [ diff --git a/fastapi_startkit/uv.lock b/fastapi_startkit/uv.lock index 7057c468..47fe08ab 100644 --- a/fastapi_startkit/uv.lock +++ b/fastapi_startkit/uv.lock @@ -527,7 +527,7 @@ wheels = [ [[package]] name = "fastapi-startkit" -version = "0.47.0" +version = "0.48.0" source = { editable = "." } dependencies = [ { name = "cleo" },