Initial commit: RehearsalHub POC
Full-stack self-hosted band rehearsal platform: Backend (FastAPI + SQLAlchemy 2.0 async): - Auth with JWT (register, login, /me, settings) - Band management with Nextcloud folder integration - Song management with audio version tracking - Nextcloud scan to auto-import audio files - Band membership with link-based invite system - Song comments - Audio analysis worker (BPM, key, loudness, waveform) - Nextcloud activity watcher for auto-import - WebSocket support for real-time annotation updates - Alembic migrations (0001–0003) - Repository pattern, Ruff + mypy configured Frontend (React 18 + Vite + TypeScript strict): - Login/register page with post-login redirect - Home page with band list and creation form - Band page with member panel, invite link, song list, NC scan - Song page with waveform player, annotations, comment thread - Settings page for per-user Nextcloud credentials - Invite acceptance page (/invite/:token) - ESLint v9 flat config + TypeScript strict mode Infrastructure: - Docker Compose: PostgreSQL, Redis, API, worker, watcher, nginx - nginx reverse proxy for static files + /api/ proxy - make check runs all linters before docker compose build Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
53
api/src/rehearsalhub/repositories/base.py
Normal file
53
api/src/rehearsalhub/repositories/base.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Generic async repository. All concrete repos extend BaseRepository[T]."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from typing import Any, Generic, Sequence, TypeVar
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from rehearsalhub.db.models import Base
|
||||
|
||||
ModelT = TypeVar("ModelT", bound=Base)
|
||||
|
||||
|
||||
class BaseRepository(Generic[ModelT]):
|
||||
model: type[ModelT]
|
||||
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self.session = session
|
||||
|
||||
async def get_by_id(self, id: uuid.UUID) -> ModelT | None:
|
||||
return await self.session.get(self.model, id)
|
||||
|
||||
async def list(self, **filters: Any) -> Sequence[ModelT]:
|
||||
stmt = select(self.model).filter_by(**filters)
|
||||
result = await self.session.execute(stmt)
|
||||
return result.scalars().all()
|
||||
|
||||
async def create(self, **kwargs: Any) -> ModelT:
|
||||
obj = self.model(**kwargs)
|
||||
self.session.add(obj)
|
||||
await self.session.flush()
|
||||
await self.session.refresh(obj)
|
||||
return obj
|
||||
|
||||
async def update(self, obj: ModelT, **kwargs: Any) -> ModelT:
|
||||
for key, value in kwargs.items():
|
||||
setattr(obj, key, value)
|
||||
await self.session.flush()
|
||||
await self.session.refresh(obj)
|
||||
return obj
|
||||
|
||||
async def delete(self, obj: ModelT) -> None:
|
||||
await self.session.delete(obj)
|
||||
await self.session.flush()
|
||||
|
||||
async def count(self, **filters: Any) -> int:
|
||||
from sqlalchemy import func, select
|
||||
|
||||
stmt = select(func.count()).select_from(self.model).filter_by(**filters)
|
||||
result = await self.session.execute(stmt)
|
||||
return result.scalar_one()
|
||||
Reference in New Issue
Block a user