refactor(demo): split UI service package

This commit is contained in:
2026-07-14 10:22:49 +03:30
parent d43eb54e2d
commit 59f22320ae
13 changed files with 32 additions and 31 deletions

View File

@@ -21,6 +21,6 @@ DEMO_ENABLE_DEBUG_OTP=true
DEMO_DEBUG_SMS_TTL_SECONDS=300 DEMO_DEBUG_SMS_TTL_SECONDS=300
DEMO_HOST=0.0.0.0 DEMO_HOST=0.0.0.0
DEMO_PORT=8080 DEMO_PORT=8080
ADMIN_MOBILE=989120000000 ADMIN_MOBILE=09120000000
GRPC_HOST=0.0.0.0 GRPC_HOST=0.0.0.0
GRPC_PORT=50051 GRPC_PORT=50051

View File

@@ -35,7 +35,7 @@ Supported values:
## Demo UI ## Demo UI
`demo-app` is a small FastAPI backend-for-frontend that calls `auth-service` over gRPC. It demonstrates how another microservice consumes the auth service. `demo-app` is a small FastAPI backend-for-frontend, implemented as the sibling package `gapido_demo`, that calls `auth-service` over gRPC. It demonstrates how another microservice consumes the auth service.
Available browser actions: Available browser actions:

View File

@@ -47,7 +47,7 @@ services:
demo-app: demo-app:
build: . build: .
command: uvicorn gapido_auth.demo.app:app --host 0.0.0.0 --port 8080 command: uvicorn gapido_demo.app:app --host 0.0.0.0 --port 8080
environment: environment:
AUTH_GRPC_TARGET: auth-service:50051 AUTH_GRPC_TARGET: auth-service:50051
REDIS_URL: redis://redis:6379/0 REDIS_URL: redis://redis:6379/0

View File

@@ -35,6 +35,9 @@ build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["src"] where = ["src"]
[tool.setuptools.package-data]
gapido_demo = ["static/*"]
[tool.pytest.ini_options] [tool.pytest.ini_options]
asyncio_mode = "auto" asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function" asyncio_default_fixture_loop_scope = "function"
@@ -52,7 +55,7 @@ select = ["E", "F", "I", "B", "UP", "ASYNC"]
[tool.mypy] [tool.mypy]
python_version = "3.12" python_version = "3.12"
strict = true strict = true
packages = ["gapido_auth"] packages = ["gapido_auth", "gapido_demo"]
exclude = ["src/gapido_auth/generated"] exclude = ["src/gapido_auth/generated"]
[[tool.mypy.overrides]] [[tool.mypy.overrides]]

View File

@@ -1,2 +0,0 @@
"""Demo browser client for the auth service."""

View File

@@ -0,0 +1 @@
"""Demo browser client service for Gapido Auth."""

View File

@@ -12,8 +12,8 @@ from pydantic import BaseModel, Field
from redis.asyncio import Redis from redis.asyncio import Redis
from gapido_auth.config import Settings, get_settings from gapido_auth.config import Settings, get_settings
from gapido_auth.demo.grpc_client import AuthGrpcClient, DemoTokenResponse
from gapido_auth.infrastructure.debug_sms_client import debug_sms_key from gapido_auth.infrastructure.debug_sms_client import debug_sms_key
from gapido_demo.grpc_client import AuthGrpcClient, DemoTokenResponse
STATIC_DIR = Path(__file__).resolve().parent / "static" STATIC_DIR = Path(__file__).resolve().parent / "static"
T = TypeVar("T") T = TypeVar("T")

1
src/gapido_demo/py.typed Normal file
View File

@@ -0,0 +1 @@

View File

@@ -136,4 +136,3 @@ $("admin").addEventListener("click", async () => {
}); });
render(); render();

View File

@@ -62,4 +62,3 @@
<script src="/static/app.js"></script> <script src="/static/app.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,9 +1,9 @@
:root { :root {
color-scheme: light; color-scheme: dark;
font-family: font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: #f5f7fb; background: #0c111d;
color: #1d2433; color: #e6edf7;
} }
* { * {
@@ -27,11 +27,11 @@ input {
} }
.panel { .panel {
background: #ffffff; background: #121a2a;
border: 1px solid #dbe3ef; border: 1px solid #243149;
border-radius: 8px; border-radius: 8px;
padding: 20px; padding: 20px;
box-shadow: 0 16px 45px rgb(29 36 51 / 8%); box-shadow: 0 18px 55px rgb(0 0 0 / 28%);
} }
.identity { .identity {
@@ -44,7 +44,7 @@ input {
.eyebrow { .eyebrow {
margin: 0 0 4px; margin: 0 0 4px;
font-size: 13px; font-size: 13px;
color: #5f6f89; color: #8fa3c1;
font-weight: 700; font-weight: 700;
} }
@@ -63,11 +63,11 @@ h2 {
} }
.status { .status {
border: 1px solid #c4d3ea; border: 1px solid #2e7d72;
border-radius: 999px; border-radius: 999px;
padding: 8px 12px; padding: 8px 12px;
color: #315477; color: #8ff0d2;
background: #eef5ff; background: #0f2a28;
font-weight: 700; font-weight: 700;
} }
@@ -85,32 +85,32 @@ h2 {
label { label {
display: grid; display: grid;
gap: 6px; gap: 6px;
color: #40516b; color: #b7c6dd;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
} }
input { input {
width: 100%; width: 100%;
border: 1px solid #cfd9e8; border: 1px solid #2b3a55;
border-radius: 6px; border-radius: 6px;
padding: 11px 12px; padding: 11px 12px;
color: #1d2433; color: #e6edf7;
background: #fbfdff; background: #0b1220;
} }
button { button {
border: 0; border: 0;
border-radius: 6px; border-radius: 6px;
padding: 11px 14px; padding: 11px 14px;
background: #206a5d; background: #2d8f7e;
color: #ffffff; color: #ffffff;
font-weight: 800; font-weight: 800;
cursor: pointer; cursor: pointer;
} }
button:hover { button:hover {
background: #18544a; background: #247669;
} }
.actions { .actions {
@@ -132,7 +132,7 @@ button:hover {
} }
dt { dt {
color: #6b7b92; color: #93a4bc;
} }
dd { dd {
@@ -146,8 +146,9 @@ pre {
padding: 14px; padding: 14px;
border-radius: 6px; border-radius: 6px;
overflow: auto; overflow: auto;
background: #111827; border: 1px solid #243149;
color: #d1fae5; background: #080d16;
color: #a7f3d0;
} }
@media (max-width: 760px) { @media (max-width: 760px) {
@@ -161,4 +162,3 @@ pre {
font-size: 26px; font-size: 26px;
} }
} }

View File

@@ -3,8 +3,8 @@ from dataclasses import dataclass
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from gapido_auth.config import Settings from gapido_auth.config import Settings
from gapido_auth.demo.app import app, get_app_settings, get_auth_client, get_debug_redis from gapido_demo.app import app, get_app_settings, get_auth_client, get_debug_redis
from gapido_auth.demo.grpc_client import DemoTokenResponse from gapido_demo.grpc_client import DemoTokenResponse
@dataclass(slots=True) @dataclass(slots=True)