From 1736dd021b43d7acc977895837f9b5c457303546 Mon Sep 17 00:00:00 2001 From: Indiana Date: Mon, 20 Jul 2026 14:52:53 +0000 Subject: [PATCH] chore: scaffold backend venv, health check, systemd unit --- .env.example | 4 ++++ .gitignore | 7 ++++++- backend/app/__init__.py | 0 backend/app/main.py | 8 ++++++++ backend/pytest.ini | 2 ++ backend/requirements.txt | 10 ++++++++++ backend/tests/test_health.py | 10 ++++++++++ deploy/quantumancy.service | 14 ++++++++++++++ 8 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 backend/app/__init__.py create mode 100644 backend/app/main.py create mode 100644 backend/pytest.ini create mode 100644 backend/requirements.txt create mode 100644 backend/tests/test_health.py create mode 100644 deploy/quantumancy.service diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..2e1e418 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +DATABASE_URL=postgresql+asyncpg://quantumancy:quantumancy@localhost:5432/quantumancy +OLLAMA_BASE_URL=http://10.30.20.107:11434 +SESSION_SECRET=change-me-to-a-random-64-char-string +PORT=7777 diff --git a/.gitignore b/.gitignore index e458ed5..f84621a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -.worktrees/ +backend/venv/ +__pycache__/ +*.pyc +.env +frontend/node_modules/ +frontend/dist/ diff --git a/backend/app/__init__.py b/backend/app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/app/main.py b/backend/app/main.py new file mode 100644 index 0000000..4385221 --- /dev/null +++ b/backend/app/main.py @@ -0,0 +1,8 @@ +from fastapi import FastAPI + +app = FastAPI(title="Quantumancy") + + +@app.get("/healthz") +async def healthz(): + return {"status": "ok"} diff --git a/backend/pytest.ini b/backend/pytest.ini new file mode 100644 index 0000000..2f4c80e --- /dev/null +++ b/backend/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +asyncio_mode = auto diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..32130d6 --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,10 @@ +fastapi==0.115.0 +uvicorn[standard]==0.32.0 +sqlalchemy[asyncio]==2.0.36 +asyncpg==0.30.0 +pydantic-settings==2.6.1 +argon2-cffi==23.1.0 +httpx==0.27.2 +numpy==2.1.3 +pytest==8.3.3 +pytest-asyncio==0.24.0 diff --git a/backend/tests/test_health.py b/backend/tests/test_health.py new file mode 100644 index 0000000..b272b35 --- /dev/null +++ b/backend/tests/test_health.py @@ -0,0 +1,10 @@ +from fastapi.testclient import TestClient + +from app.main import app + + +def test_healthz_returns_ok(): + client = TestClient(app) + response = client.get("/healthz") + assert response.status_code == 200 + assert response.json() == {"status": "ok"} diff --git a/deploy/quantumancy.service b/deploy/quantumancy.service new file mode 100644 index 0000000..d690606 --- /dev/null +++ b/deploy/quantumancy.service @@ -0,0 +1,14 @@ +[Unit] +Description=Quantumancy web app +After=network.target postgresql.service + +[Service] +Type=simple +WorkingDirectory=/root/quantumancy/backend +EnvironmentFile=/root/quantumancy/.env +ExecStart=/root/quantumancy/backend/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 7777 +Restart=on-failure +RestartSec=3 + +[Install] +WantedBy=multi-user.target