feat: initialize zhixing-web with React, React Router, and Tailwind CSS

- Set up the main application structure with App component and routing.
- Implemented global state management for UI theme using Zustand.
- Created API utilities for fetching system status.
- Developed system status page with responsive design and theme toggle.
- Added testing setup with Vitest and initial tests for system status page.
- Configured TypeScript with appropriate settings for the application.
- Integrated Tailwind CSS for styling and responsive design.
- Established Vite configuration for development and testing environments.
This commit is contained in:
yuxuanhui
2026-08-03 13:47:24 +08:00
commit 844d8416bd
61 changed files with 4694 additions and 0 deletions
@@ -0,0 +1 @@
"""Zhixing Server application package."""
@@ -0,0 +1 @@
"""Application composition and startup boundaries."""
@@ -0,0 +1,19 @@
"""FastAPI application factory."""
from fastapi import FastAPI
from zhixing_server.bootstrap.config import get_settings
from zhixing_server.interfaces.http.router import api_v1_router, operational_router
def create_app() -> FastAPI:
"""Compose the HTTP application without leaking FastAPI into domain modules.
Returns:
A configured FastAPI application instance.
"""
settings = get_settings()
application = FastAPI(title=settings.app_name)
application.include_router(operational_router)
application.include_router(api_v1_router)
return application
@@ -0,0 +1,30 @@
"""Environment-backed application configuration."""
from functools import lru_cache
from typing import Literal
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""Validated process configuration at the application boundary."""
app_name: str = "Zhixing Server"
app_env: Literal["development", "test", "production"] = "development"
log_level: str = "INFO"
model_config = SettingsConfigDict(
env_file=".env",
env_prefix="ZHIXING_",
extra="ignore",
)
@lru_cache
def get_settings() -> Settings:
"""Return one immutable-by-convention configuration object per process.
Returns:
Settings populated from defaults, `.env`, and process environment variables.
"""
return Settings()
@@ -0,0 +1 @@
"""Inbound and outbound system interfaces outside domain contexts."""
@@ -0,0 +1 @@
"""HTTP interface composition."""
@@ -0,0 +1,10 @@
"""Top-level HTTP route catalogs."""
from fastapi import APIRouter
from zhixing_server.interfaces.http.system import operational_router, system_router
api_v1_router = APIRouter(prefix="/api/v1")
api_v1_router.include_router(system_router, prefix="/system", tags=["system"])
__all__ = ["api_v1_router", "operational_router"]
@@ -0,0 +1,51 @@
"""Operational endpoints that do not belong to a business context."""
from typing import Annotated, Literal
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from zhixing_server.bootstrap.config import Settings, get_settings
operational_router = APIRouter()
system_router = APIRouter()
class HealthResponse(BaseModel):
"""Minimal response used by container health probes."""
status: Literal["ok"]
class SystemStatusResponse(HealthResponse):
"""Non-domain runtime metadata displayed by the frontend smoke slice."""
service: str
environment: str
@operational_router.get("/healthz", response_model=HealthResponse, include_in_schema=False)
def health() -> HealthResponse:
"""Report whether the HTTP process can serve requests.
Returns:
A stable response suitable for container health checks.
"""
return HealthResponse(status="ok")
@system_router.get("/status", response_model=SystemStatusResponse)
def system_status(settings: Annotated[Settings, Depends(get_settings)]) -> SystemStatusResponse:
"""Expose safe runtime metadata for end-to-end connectivity checks.
Args:
settings: Validated process settings injected by FastAPI.
Returns:
The service name, environment, and current availability state.
"""
return SystemStatusResponse(
status="ok",
service=settings.app_name,
environment=settings.app_env,
)
@@ -0,0 +1,5 @@
"""ASGI entry point for Zhixing Server."""
from zhixing_server.bootstrap.app import create_app
app = create_app()
@@ -0,0 +1,14 @@
# Bounded contexts
Create a module here only after its domain language and ownership boundary are understood:
```text
<bounded_context>/
├── domain/ # Entities, value objects, domain services, ports
├── application/ # Use cases and orchestration
├── infrastructure/ # Adapters for storage and external systems
└── presentation/ # HTTP or message-driven delivery adapters
```
The domain layer must not import FastAPI, persistence clients, or infrastructure adapters.
@@ -0,0 +1 @@
"""Business bounded contexts live below this package."""
@@ -0,0 +1 @@
"""Small cross-context primitives with no specific business ownership."""