Skip to content

Latest commit

 

History

History
244 lines (161 loc) · 4.79 KB

File metadata and controls

244 lines (161 loc) · 4.79 KB

Compose Runbook

This runbook verifies the local EX3 stack: FastAPI API, Redis, worker, AI sidecar, SQLite persistence, tests, Schemathesis, and the Streamlit dashboard.

What Compose Covers

docker compose up starts:

  • FastAPI API at http://127.0.0.1:8000
  • Redis at localhost:6379
  • one-shot seed service that initializes the demo account and sample watchlist
  • background worker using the same SQLite volume as the API
  • AI sidecar at http://localhost:8010
  • Streamlit UI at http://localhost:8501

Fresh Clone Setup

Install dependencies:

uv sync --extra dev

Validate the local source tree:

uv run scripts/local_ci.sh

The local CI script runs Python syntax checks, pytest, compose config validation, and Schemathesis when an API is already running. If the API is not running, it skips Schemathesis and prints the exact command to run later.

Launch The Stack

Start API, Redis, seed, worker, AI, and UI:

docker compose up --build

The seed service runs automatically after the API is healthy. It exits successfully after creating the demo account and sample stocks. It is idempotent, so repeated compose starts do not duplicate data.

Open the app:

  • Streamlit UI: http://localhost:8501
  • API docs: http://127.0.0.1:8000/docs
  • AI health: http://127.0.0.1:8010/health

Demo login:

demo@alphawatch.local / password123

Stop the stack:

docker compose down

Remove the local compose database volume:

docker compose down -v

Verify API Health

Check OpenAPI:

curl -fsS http://127.0.0.1:8000/openapi.json >/dev/null

Check docs in a browser:

http://127.0.0.1:8000/docs

Show response headers:

curl -i http://127.0.0.1:8000/openapi.json | sed -n '1,20p'

AlphaWatch does not currently implement request rate limiting, so no X-RateLimit-* headers are expected. If rate limiting is added later, this header check is where those headers should be verified.

Verify AI Service

curl -fsS http://127.0.0.1:8010/health

Expected output:

{"status":"ok"}

The base demo does not require AI secrets. The AI service returns deterministic mock stock briefs.

Verify Redis

docker compose exec redis redis-cli ping

Expected output:

PONG

Verify Worker Behavior

Watch logs:

docker compose logs -f worker

You should see a cycle summary like:

refresh cycle complete: symbols=3 refreshed=3 skipped=0 errors=0

If no stocks exist yet, run:

docker compose run --rm seed

You can also run one manual refresh and then watch the worker continue on its interval:

uv run python scripts/refresh.py AAPL MSFT --concurrency 2 --retries 2

Verify Streamlit UI

Open:

http://localhost:8501

Use the demo login after seeding:

demo@alphawatch.local / password123

On Stock Details, verify:

  • the chart range selector changes between 1D, 5D, 1M, YTD, and 1Y
  • the AI Brief section shows summary, sentiment, takeaways, and risks

Run Pytest

uv run pytest

The tests mock Yahoo Finance and fake Redis where needed. They do not require real market network calls.

Run Schemathesis

Schemathesis is included in the dev dependencies. It checks the live OpenAPI schema against the running API.

Start the compose stack first:

docker compose up --build

Then run:

uv run scripts/schemathesis.sh

The script runs a small GET-focused Schemathesis smoke test against http://127.0.0.1:8000/openapi.json with an intentionally invalid bearer token. This keeps the check local and stable: protected routes should reject the request before Yahoo-backed endpoint logic runs, and Schemathesis verifies that those requests do not produce server errors.

Local CI Equivalent

For a local CI-style check:

uv run scripts/local_ci.sh

Recommended full verification flow:

uv sync --extra dev
docker compose up --build
uv run scripts/local_ci.sh

In hosted CI, the equivalent steps would be:

uv sync --extra dev
uv run python -m compileall app scripts tests
uv run pytest
docker compose config
docker compose up -d --build
uv run scripts/schemathesis.sh
docker compose down

Run Manual Refresh

Refresh all saved stocks:

uv run python scripts/refresh.py

Refresh selected symbols:

uv run python scripts/refresh.py AAPL MSFT --concurrency 2 --retries 2

When running against compose Redis from the host, the default REDIS_URL=redis://localhost:6379/0 works.

View The Weekly Report

Log in:

curl -X POST \
  -d "username=demo@alphawatch.local&password=password123" \
  http://127.0.0.1:8000/auth/login

Use the returned token:

curl -H "Authorization: Bearer TOKEN_HERE" \
  http://127.0.0.1:8000/reports/weekly