Initial MobilityOps build pack (docs, contracts, scaffold)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
FROM python:3.12-slim
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml ./
|
||||
COPY app ./app
|
||||
RUN pip install --no-cache-dir .
|
||||
EXPOSE 8000
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
@@ -0,0 +1,22 @@
|
||||
from functools import lru_cache
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
||||
|
||||
mobilityops_env: str = "development"
|
||||
mobilityops_demo_mode: bool = True
|
||||
database_url: str = "postgresql+psycopg://mobilityops:mobilityops@db:5432/mobilityops"
|
||||
knowledge_provider: str = "demo"
|
||||
ragcore_base_url: str = "http://ragcore-api:8000"
|
||||
ragcore_tenant: str = "northstar-mobility-demo"
|
||||
ragcore_workspace: str = "mobilityops"
|
||||
ragcore_collection: str = "internal-procedures"
|
||||
n8n_webhook_url: str = "http://n8n:5678/webhook/mobilityops-return"
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return Settings()
|
||||
@@ -0,0 +1,22 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.core.config import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
app = FastAPI(title="MobilityOps API", version="0.0.1")
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health() -> dict[str, str]:
|
||||
return {"status": "ok", "service": "mobilityops-api"}
|
||||
|
||||
|
||||
@app.get("/api/v1/system/status")
|
||||
def system_status() -> dict[str, object]:
|
||||
return {
|
||||
"service": "mobilityops-api",
|
||||
"environment": settings.mobilityops_env,
|
||||
"demo_mode": settings.mobilityops_demo_mode,
|
||||
"knowledge_provider": settings.knowledge_provider,
|
||||
"scaffold": True,
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "mobilityops-api"
|
||||
version = "0.0.1"
|
||||
description = "MobilityOps API scaffold"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"fastapi>=0.115,<1",
|
||||
"uvicorn[standard]>=0.30,<1",
|
||||
"pydantic-settings>=2.5,<3",
|
||||
"sqlalchemy>=2.0,<3",
|
||||
"psycopg[binary]>=3.2,<4",
|
||||
"alembic>=1.13,<2",
|
||||
"httpx>=0.27,<1"
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"pytest>=8,<9",
|
||||
"pytest-asyncio>=0.24,<1",
|
||||
"ruff>=0.8,<1",
|
||||
"mypy>=1.13,<2"
|
||||
]
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["app"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
asyncio_mode = "auto"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I", "B", "UP"]
|
||||
@@ -0,0 +1,9 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
|
||||
def test_health() -> None:
|
||||
response = TestClient(app).get("/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"status": "ok", "service": "mobilityops-api"}
|
||||
Reference in New Issue
Block a user