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:
Steffen Schuhmann
2026-03-28 21:53:03 +01:00
commit f7be1b994d
139 changed files with 12743 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
import { api } from "./client";
export interface RangeAnalysis {
id: string;
start_ms: number;
end_ms: number;
bpm: number | null;
bpm_confidence: number | null;
key: string | null;
scale: string | null;
avg_loudness_lufs: number | null;
energy: number | null;
chroma_vector: number[] | null;
mfcc_mean: number[] | null;
}
export interface Reaction {
id: string;
member_id: string;
emoji: string;
created_at: string;
}
export interface Annotation {
id: string;
version_id: string;
author_id: string;
type: "point" | "range";
timestamp_ms: number;
range_end_ms: number | null;
body: string | null;
label: string | null;
tags: string[];
parent_id: string | null;
resolved: boolean;
created_at: string;
updated_at: string;
range_analysis: RangeAnalysis | null;
reactions: Reaction[];
}
export const listAnnotations = (versionId: string) =>
api.get<Annotation[]>(`/versions/${versionId}/annotations`);
export const createAnnotation = (
versionId: string,
data: {
type: "point" | "range";
timestamp_ms: number;
range_end_ms?: number;
body?: string;
label?: string;
tags?: string[];
parent_id?: string;
}
) => api.post<Annotation>(`/versions/${versionId}/annotations`, data);
export const updateAnnotation = (
annotationId: string,
data: { body?: string; label?: string; tags?: string[]; resolved?: boolean }
) => api.patch<Annotation>(`/annotations/${annotationId}`, data);
export const deleteAnnotation = (annotationId: string) =>
api.delete(`/annotations/${annotationId}`);
export const addReaction = (annotationId: string, emoji: string) =>
api.post<Reaction>(`/annotations/${annotationId}/reactions`, { emoji });
export const searchRanges = (
bandId: string,
params: { bpm_min?: number; bpm_max?: number; key?: string; tag?: string; min_duration_ms?: number }
) => {
const qs = new URLSearchParams(
Object.fromEntries(
Object.entries(params)
.filter(([, v]) => v !== undefined)
.map(([k, v]) => [k, String(v)])
)
);
return api.get<Annotation[]>(`/bands/${bandId}/search/ranges?${qs}`);
};

33
web/src/api/auth.ts Normal file
View File

@@ -0,0 +1,33 @@
import { api, setToken } from "./client";
export interface LoginRequest {
email: string;
password: string;
}
export interface TokenResponse {
access_token: string;
token_type: string;
}
export interface MemberRead {
id: string;
email: string;
display_name: string;
avatar_url: string | null;
created_at: string;
}
export async function login(req: LoginRequest): Promise<TokenResponse> {
const resp = await api.post<TokenResponse>("/auth/login", req);
setToken(resp.access_token);
return resp;
}
export async function register(req: {
email: string;
password: string;
display_name: string;
}): Promise<MemberRead> {
return api.post<MemberRead>("/auth/register", req);
}

29
web/src/api/bands.ts Normal file
View File

@@ -0,0 +1,29 @@
import { api } from "./client";
export interface Band {
id: string;
name: string;
slug: string;
genre_tags: string[];
nc_folder_path: string | null;
created_at: string;
updated_at: string;
memberships?: BandMembership[];
}
export interface BandMembership {
member: { id: string; email: string; display_name: string };
role: string;
instrument: string | null;
joined_at: string;
}
export const listBands = () => api.get<Band[]>("/bands");
export const getBand = (bandId: string) => api.get<Band>(`/bands/${bandId}`);
export const createBand = (data: {
name: string;
slug: string;
genre_tags?: string[];
nc_base_path?: string;
}) => api.post<Band>("/bands", data);

43
web/src/api/client.ts Normal file
View File

@@ -0,0 +1,43 @@
const BASE = "/api/v1";
function getToken(): string | null {
return localStorage.getItem("rh_token");
}
export function setToken(token: string): void {
localStorage.setItem("rh_token", token);
}
export function clearToken(): void {
localStorage.removeItem("rh_token");
}
async function request<T>(
path: string,
options: RequestInit = {}
): Promise<T> {
const token = getToken();
const headers: Record<string, string> = {
"Content-Type": "application/json",
...(options.headers as Record<string, string>),
};
if (token) {
headers["Authorization"] = `Bearer ${token}`;
}
const resp = await fetch(`${BASE}${path}`, { ...options, headers });
if (!resp.ok) {
const error = await resp.json().catch(() => ({ detail: resp.statusText }));
throw new Error(error.detail ?? resp.statusText);
}
if (resp.status === 204) return undefined as T;
return resp.json();
}
export const api = {
get: <T>(path: string) => request<T>(path),
post: <T>(path: string, body: unknown) =>
request<T>(path, { method: "POST", body: JSON.stringify(body) }),
patch: <T>(path: string, body: unknown) =>
request<T>(path, { method: "PATCH", body: JSON.stringify(body) }),
delete: (path: string) => request<void>(path, { method: "DELETE" }),
};