App factory, data model, initial migration and HTTP metrics
CI / lint (push) Successful in 9s
CI / test (push) Failing after 22s
CI / notify (push) Successful in 5s

- Flask app factory with env-driven config (.env loaded at import)
- SQLAlchemy models: users, API apps, UI tokens, Last.fm auth tokens,
  sessions, scrobbles (deduplicated) and now-playing
- Initial Alembic migration; CI checks migrations match the models
- Prometheus metric definitions, per-endpoint RED hooks with bounded
  labels, and a standalone metrics server
- docker compose Postgres with a test database; CI test job runs
  against a Postgres service container

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 13:55:04 +01:00
1 parent 606348800b
commit 98c8f2e824
21 files changed
+1777 -6

No files matched your search

+29
View File
@@ -1,3 +1,32 @@
"""Self-hosted, Last.fm-compatible music scrobbling service."""
__version__ = "0.1.0"
def create_app(config_object=None):
from flask import Flask
from scrobbler import models # noqa: F401 (register models with SQLAlchemy)
from scrobbler.config import Config
from scrobbler.extensions import db, migrate
from scrobbler.metrics import http as http_metrics
app = Flask(__name__)
app.config.from_object(config_object or Config)
db.init_app(app)
migrate.init_app(app, db, directory=_migrations_dir())
http_metrics.init_app(app)
if app.config["START_METRICS_SERVER"]:
from scrobbler.metrics.server import start_metrics_server
start_metrics_server(app.config["METRICS_PORT"])
return app
def _migrations_dir() -> str:
from pathlib import Path
return str(Path(__file__).resolve().parent / "migrations")