---
title: Dependencies and Library Usage
category: dependencies
---

# Dependencies and Library Usage

## Core Dependencies

### duckdb
- **Required**: Yes
- **Fallback**: None (core functionality)
- **Usage**: SQL database for motions, embeddings, SVD vectors
- **Files**: database.py, analysis/*.py, pipeline/*.py

### streamlit
- **Required**: Yes
- **Fallback**: None
- **Usage**: Web UI framework
- **Files**: app.py, pages/*.py, explorer.py

### requests
- **Required**: Yes
- **Fallback**: None
- **Usage**: HTTP client for API calls
- **Files**: api_client.py, ai_provider.py

### plotly
- **Required**: Yes
- **Fallback**: None (raises ImportError)
- **Usage**: Interactive charts for explorer
- **Files**: explorer.py, explorer_helpers.py

## Optional Dependencies

### umap-learn
- **Required**: No
- **Fallback**: Use raw SVD vectors (first 2 dimensions)
- **Usage**: Dimensionality reduction for visualization
- **Files**: analysis/clustering.py

### matplotlib
- **Required**: No
- **Fallback**: Plotly or raw output
- **Usage**: Static charting
- **Files**: Various analysis scripts

## ML Dependencies

### sklearn
- **Required**: Yes
- **Usage**: KMeans clustering, cosine_similarity, StandardScaler
- **Files**: analysis/clustering.py, similarity/compute.py

### scipy
- **Required**: Yes
- **Usage**: SVD (scipy.linalg.svd), spatial.procrustes for alignment
- **Files**: analysis/trajectory.py, pipeline/svd_pipeline.py

### numpy
- **Required**: Yes
- **Usage**: Array operations, linear algebra
- **Files**: Throughout codebase

## Key Imports by File

### explorer.py
- `import streamlit as st`
- `from database import db`
- `from explorer_helpers import *`

### explorer_helpers.py
- `import pandas as pd`
- `import plotly.graph_objects as go`
- `from database import db` (optional, for type hints)

### database.py
- `import ibis`
- `import duckdb`
- `from config import config, PARTY_COLOURS`

### config.py
- `from dataclasses import dataclass, field`
- `import streamlit as st` (optional, for warnings)

## Singleton Instances

| Module | Instance | Type |
|--------|----------|------|
| `database.py` | `db` | `MotionDatabase` |
| `config.py` | `config` | `Config` (dataclass) |
| `config.py` | `PARTY_COLOURS` | `dict[str, str]` |
