How deeplegend/voicelink works
1. This is a Next.js App Router application organized around two product areas: text-to-speech generation and voice management. The app shell lives under src/app, with dashboard pages in src/app/(dashboard) and dedicated auth/org-selection routes outside that shell.
2. The UI is split by feature, not by generic component type. src/features/text-to-speech, src/features/voices, and src/features/dashboard each contain their own views, components, data, and hooks. Shared primitives live in src/components/ui, which is a large design-system layer used across the app.
3. The main user flow is: sign in → select org → open dashboard → create or manage voices / generate speech. The dashboard entry points are src/app/(dashboard)/page.tsx, voices/page.tsx, and text-to-speech/page.tsx, each delegating to feature-specific view components.
4. Text-to-speech generation is the core subsystem. The TTS feature includes input forms, prompt suggestions, voice selection, settings/history panels, and audio playback visualization. Generation detail pages exist at src/app/(dashboard)/text-to-speech/[generationId], indicating the app stores and reopens prior generations.
5. There is a backend API layer in src/app/api that mediates client actions. Key endpoints are /api/create for starting generation, /api/audio/[generationId] for retrieving generated audio, /api/voices/[VoiceId] for voice-specific operations, and /api/trpc/[trpc] for tRPC-based application queries and mutations.
6. Persistent application state is backed by Prisma. The schema and migrations under prisma/ indicate a relational database is the source of truth for entities such as voices, generations, and related metadata. src/lib/db.ts is the DB access boundary.
7. Generated audio is stored separately from relational data. The presence of src/lib/r2.ts strongly suggests object storage, likely Cloudflare R2, is used for audio assets, while the DB stores references/metadata. This splits small metadata reads from large binary audio delivery.
8. Voice assets are treated as first-class data. The repository includes many bundled system voice WAV files in scripts/system-voices/ plus a seeding script, which suggests there are built-in voices loaded into the database or storage at deploy/setup time. The voices feature also includes create dialogs, recording, category/scoping helpers, and list/card UI.
9. There is a distinct integration boundary around the speech engine itself. src/lib/chatterbox-client.ts, src/types/chatterbox-api.d.ts, and the top-level chatterbox_tts.py point to an external or separately runnable TTS service/client contract. The Next.js app appears to orchestrate generation requests rather than perform model inference directly in the browser.
10. Client-server state management is handled with tRPC for typed application data and route handlers for media transfer. src/trpc/routers/generations.ts and voices.ts expose domain operations, while src/trpc/client.tsx, server.tsx, and query-client.ts wire the React app to those routers. This keeps interactive data fetching separate from binary audio delivery.
11. The src/features/text-to-speech/hooks/use-wavesurfer.ts and src/hooks/use-audio-playback.ts indicate browser-side playback and waveform visualization happen in the client, consuming audio retrieved from the backend rather than embedding audio processing into the server.
12. Deployment/runtime-wise, this is a TypeScript-heavy Next.js app with Prisma migrations, custom scripts, and API routes. The architecture centers on a web frontend, a relational database, object storage for audio, and a TTS service boundary, with auth/session and org context layered around the dashboard experience.
Main entry points: route.ts API routes · (dashboard)/layout.tsx Dashboard shell · app/layout.tsx App layout · text-to-speech-view.tsx TTS view
Components 23
App shell
Next.js routes, layout, and access entrypoints
- App layout · Root application shell and global providers
src/app/layout.tsx - Dashboard shell · Authenticated dashboard layout wrapper
src/app/(dashboard)/layout.tsx - Dashboard home · Main dashboard entry page
src/app/(dashboard)/page.tsx - TTS page · Text-to-speech entry page
src/app/(dashboard)/text-to-speech/page.tsx - TTS detail · Reopens a prior generation by id
src/app/(dashboard)/text-to-speech/[generationId]/page.tsx - Voices page · Voice management entry page
src/app/(dashboard)/voices/page.tsx - Sign in · Authentication entry route
src/app/sign-in/[[...sign-in]]/page.tsx - Org select · Organization selection flow after auth
src/app/org-selection/page.tsx
Features
Product-area modules with their own views and UI
- Dashboard view · Dashboard landing experience and quick actions
src/features/dashboard/views/dashboard-view.tsx - TTS view · Primary speech generation workspace
src/features/text-to-speech/views/text-to-speech-view.tsx - TTS detail view · Generation playback and detail workspace
src/features/text-to-speech/views/text-to-speech-detail-view.tsx - Voices view · Voice catalog and management workspace
src/features/voices/views/voices-view.tsx - TTS controls · Forms, settings, voice preview, history, and generation controls
src/features/text-to-speech/components/text-to-speech-form.tsx - Voice tools · Voice cards, creation, recorder, and toolbar UI
src/features/voices/components/voices-list.tsx - TTS state · Voice context and playback waveform hook
src/features/text-to-speech/contexts/tts-voices-context.tsx - Voice audio · Audio recording and playback helpers for voice assets
src/features/voices/hooks/use-audio-recorder.ts
Backend
API, database, storage, and external engine boundaries
- API routes · Create, audio delivery, voice operations, and tRPC transport
src/app/api/create/route.ts - tRPC layer · Typed client/server wiring and domain routers
src/trpc/routers/_app.ts - Database · Relational persistence for voices, generations, and metadata
src/lib/db.ts - Audio storage · Binary audio asset storage boundary
src/lib/r2.ts - Speech engine · External or separately runnable TTS client/service contract
chatterbox_tts.py
Shared
Reusable UI and cross-cutting client helpers
- UI kit · Shared reusable primitives across the app
src/components/ui/button.tsx - tRPC client · React client, server helpers, and query client setup
src/trpc/client.tsx
Connections 27
- App layout → Dashboard shell: wraps · Root shell contains authenticated dashboard routes
- App layout → Sign in: routes · Root app also exposes auth entrypoints
- App layout → Org select: routes · Root app also exposes org selection
- Dashboard shell → Dashboard home: shows · Dashboard shell renders the home entry page
- Dashboard shell → TTS page: contains · Dashboard shell contains TTS routes
- Dashboard shell → Voices page: contains · Dashboard shell contains voice routes
- TTS page → TTS view: delegates · Route page delegates to feature view
- TTS detail → TTS detail view: delegates · Generation detail route delegates to feature view
- Voices page → Voices view: delegates · Route page delegates to voice management view
- Dashboard home → Dashboard view: delegates · Dashboard page renders feature view
- TTS view → TTS controls: composes · Primary workspace is assembled from TTS controls
- TTS view → TTS state: uses · View depends on shared TTS state and playback
- TTS detail view → TTS state: uses · Detail playback relies on the same voice/playback state
- Voices view → Voice tools: composes · Voice management view is assembled from voice tools
- Voices view → Voice audio: uses · Voice workflows use recording/playback helpers
- TTS controls → UI kit: builds on · Feature UI is built from shared primitives
- Voice tools → UI kit: builds on · Voice UI is built from shared primitives
- Dashboard view → UI kit: builds on · Dashboard UI is built from shared primitives
- TTS controls → API routes: starts generation · Generation form submits to create/audio endpoints
- Voice tools → API routes: manages voices · Voice tooling talks to voice API routes
- API routes → Database: reads/writes · Route handlers persist and query relational state
- API routes → Audio storage: streams audio · Binary audio is fetched from object storage
- API routes → Speech engine: orchestrates · Creation requests are forwarded to the external speech engine
- tRPC layer → Database: queries · Routers expose typed domain access over Prisma
- tRPC layer → tRPC client: served by · Routers are consumed by the React client wiring
- TTS state → tRPC client: fetches data · Client hooks use typed queries and mutations
- Voice audio → API routes: uploads/records · Recorder flows ultimately hand off through backend routes