This guide is for contributors working on SupoClip locally.
Current repository structure:
backend/- FastAPI app
- ARQ worker
- services, repositories, route modules, and media-processing code
frontend/- Next.js app
- App Router pages, API routes, auth, Prisma schema, UI components
- Root files
docker-compose.ymlinit.sql.env.examplestart.sh
docker-compose up -d --build
docker-compose logs -f
docker-compose downcd frontend
pnpm install --frozen-lockfile
pnpm run dev
pnpm run build
pnpm run start
pnpm run lintInstall ffmpeg and Tesseract with English language data (tesseract-ocr, tesseract-ocr-eng on Debian/Ubuntu). The Docker image includes both. Tesseract checks on-screen interruption notices locally; it does not call an AI service.
cd backend
uv venv .venv
source .venv/bin/activate
uv sync
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000Run the worker separately:
cd backend
source .venv/bin/activate
python -m src.workers.run_workersImportant locations:
frontend/src/app- App pages and API routes
frontend/src/components- Reusable UI and product components
frontend/src/lib- Auth, API helpers, backend proxy helpers, Stripe wiring
frontend/prisma- Prisma schema and migrations, if present in your branch
frontend/src/generated/prisma- Generated Prisma client output
The frontend build runs:
prisma generate && next buildpostinstall also runs Prisma generation.
- App Router
- Mostly client-side product pages
- Better Auth sessions
- No dedicated global state library
Important locations:
backend/src/main.py- Active entry point
backend/src/api/routes- Route modules
backend/src/services- Business logic
backend/src/repositories- Data access
backend/src/workers- Queue processing
backend/src/video_utils.py- Clip rendering pipeline
backend/src/ai.py- LLM prompt and validation logic
When possible:
- keep HTTP concerns in route modules
- keep orchestration in services
- keep SQL and persistence in repositories
The primary database bootstrap file is:
init.sql
It defines:
- users
- sessions
- auth support tables
- tasks
- sources
- generated clips
- processing cache
- Stripe webhook tracking
The frontend also uses Prisma for auth and admin-related access patterns.
Primary files:
backend/src/ai.pybackend/src/services/video_service.py
Use this area when changing:
- segment selection rules
- LLM prompts
- output validation
- clip count heuristics
Primary files:
backend/src/video_utils.pybackend/src/caption_templates.pybackend/src/clip_editor.py
Use this area when changing:
- subtitle layout
- font rendering
- cropping
- export presets
- clip edits after generation
Primary files:
backend/src/api/routes/tasks.pybackend/src/services/task_service.pybackend/src/workers/tasks.pybackend/src/workers/job_queue.py
Use this area when changing:
- status transitions
- background job behavior
- cancellation and resume logic
- progress reporting
Primary files:
backend/src/api/routes/media.pybackend/src/font_registry.pybackend/fonts/backend/transitions/
Primary files:
frontend/src/lib/auth.tsfrontend/src/app/api/auth/[...all]/route.tsinit.sql
Primary files:
frontend/src/app/api/billing/*frontend/src/lib/stripe.tsbackend/src/api/routes/billing.pybackend/src/services/billing_service.pybackend/src/services/subscription_email_service.py
Primary files:
frontend/src/app/admin/page.tsxbackend/src/api/routes/admin.py
The repository now uses a three-layer automated test setup:
- backend
pytestfor unit and integration coverage - frontend
Vitestplus Testing Library for route handlers and client UI - frontend
Playwrightfor seeded browser smoke tests against real frontend and backend processes
Primary repo-level commands:
make test
make test-backend
make test-frontend
make test-e2e
make test-ciDirect app-level commands:
cd backend && uv sync --all-groups && .venv/bin/pytest
cd frontend && pnpm install --frozen-lockfile && pnpm run test:coverage
cd frontend && pnpm run test:e2e- Start PostgreSQL and Redis locally before running integration or e2e flows.
docker-compose up -d postgres redisis enough for backend and frontend test runs.docker-compose up -dis the simplest full-stack option when you also want manual smoke testing.
Useful backend test env vars:
DATABASE_URL=postgresql+asyncpg://localhost:5432/supoclip
TEST_DATABASE_URL=postgresql+asyncpg://localhost:5432/supoclip
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
BACKEND_AUTH_SECRET=supoclip_test_secret
BETTER_AUTH_SECRET=supoclip_better_auth_test_secret- Backend coverage thresholds are enforced during
pytest. - Frontend coverage thresholds are enforced during
pnpm run test:coverage. - GitHub Actions runs separate
backend,frontend, ande2ejobs with Postgres and Redis service containers. - Playwright failures retain traces, screenshots, and videos for debugging.
Automated tests cover the main seams, but manual smoke testing is still useful for high-risk media flows:
- Start the stack.
- Sign in.
- Create a task from a YouTube URL.
- Confirm progress updates arrive.
- Confirm clips are generated.
- Confirm clip editing and export actions still work.
docker-compose logs -f backend
docker-compose logs -f worker
docker-compose logs -f frontend
docker-compose logs -f postgres
docker-compose logs -f redis- Python 3.11+
- 4-space indentation
- Prefer type hints where practical
snake_casenaming
- TypeScript and React
- 2-space indentation
PascalCasecomponentscamelCasevariables and functions- Use
@/*imports where practical
- Use
backend/src/main.py;main_refactored.pyis a compatibility import - Keep auth-sensitive browser requests behind frontend API routes
- Preserve async behavior by keeping blocking work out of FastAPI request handlers
- Use the worker for long-running media processing
Run cd frontend && pnpm exec playwright install chromium && pnpm run test:polish
for browser checks with mocked API responses. These cover failed caption saves,
editor navigation, narrow layouts, and generation-list updates without a database.
Run make check before submitting changes. Full database-backed smoke tests still
use make test-e2e.
See Testing with local YouTube downloads for the opt-in
pnpm run test:local suite and real API/worker checks. These exercise yt-dlp,
Whisper, Ollama, PostgreSQL, Redis and FFmpeg without Apify or mocked processing.