Development Setup
Set up a local development environment for Mydia.
Prerequisites
- Docker and Docker Compose
- Git
Quick Start with Docker
The recommended development approach uses Docker Compose with the ./dev helper script.
Clone the Repository
Start Development Environment
# Start all services
./dev up -d
# Run database migrations
./dev mix ecto.migrate
# View logs for admin password
./dev logs | grep "DEFAULT ADMIN USER CREATED" -A 10
Access the application at http://localhost:4000.
The ./dev Script
The ./dev script provides convenient wrappers for common commands:
Service Management
./dev up -d # Start services in background
./dev down # Stop services
./dev restart # Restart services
./dev logs -f # Follow application logs
Interactive Shells
Mix Commands
./dev mix <args> # Run any mix command
./dev mix ecto.migrate # Run migrations
./dev mix deps.get # Fetch dependencies
./dev mix test # Run tests
./dev mix format # Format code
Shortcuts
./dev test # Run tests
./dev format # Format code
./dev deps.get # Fetch dependencies
./dev ecto.migrate # Run migrations
Run ./dev without arguments to see all available commands.
Local Setup (Without Docker)
For development without Docker:
Prerequisites
- Elixir 1.16+
- Erlang 26+
- Node.js 18+
- SQLite 3
Setup
Access at http://localhost:4000.
Nix Development Environment
For users with Nix installed:
# Enter development shell
nix develop
# First-time setup
mix deps.get
mix ecto.setup
# Start server
mix phx.server
The Nix development shell provides:
- Elixir and Erlang
- Node.js
- SQLite
- FFmpeg
- All required build tools
See docs/nix.md for full Nix development and NixOS deployment documentation.
Configuration
Custom Docker Compose
Create compose.override.yml for custom configurations:
Add services like Transmission, Prowlarr, or Jackett as needed.
Environment Variables
For development, most defaults work fine. See Environment Variables for options.
Code Quality
Pre-commit Checks
Run all quality checks before committing:
This runs:
- Code compilation (warnings as errors)
- Code formatting check
- Credo static analysis
- Full test suite
Install Git Hooks
Automatic pre-commit hooks:
The hook runs mix format --check-formatted before each commit.
Manual Checks
# Format code
./dev mix format
# Run Credo
./dev mix credo
# Compile with warnings
./dev mix compile --warnings-as-errors
# Run tests
./dev mix test
Project Structure
mydia/
├── assets/ # Frontend assets (JS, CSS)
├── config/ # Configuration files
├── lib/
│ ├── mydia/ # Business logic
│ └── mydia_web/ # Web layer (LiveViews, controllers)
├── priv/
│ ├── repo/ # Database migrations
│ └── static/ # Static assets
└── test/ # Test files
Useful Commands
Database
./dev mix ecto.create # Create database
./dev mix ecto.migrate # Run migrations
./dev mix ecto.rollback # Rollback last migration
./dev mix ecto.reset # Drop, create, and migrate
Testing
./dev mix test # Run all tests
./dev mix test test/path/to/test.exs # Run specific test
./dev mix test --failed # Re-run failed tests
Debugging
Next Steps
- Testing - Unit and integration testing
- E2E Testing - Browser-based testing
- Architecture - System design overview