UK Environmental, Health, and Safety enforcement agency activity data collection and publishing system.
Production: https://legal.sertantai.com
This Phoenix LiveView application collects and manages enforcement data from UK regulatory agencies (HSE, EA, SEPA, NRW). Built with:
Clone and install dependencies:
git clone https://github.com/shotleybuilder/ehs_enforcement.git
cd ehs_enforcement
mix deps.get
Create development environment file:
cp .env.dev.example .env.dev
# Edit .env.dev with your values (GitHub OAuth, Airtable API, etc.)
Start development environment:
# Mode 1: Fast development (recommended for daily work)
docker compose -f docker-compose.dev.yml up -d postgres redis
export $(grep -v '^#' .env.dev | xargs)
mix ecto.create
mix ecto.migrate
mix phx.server
# Mode 2: Container testing (test production builds)
docker compose -f docker-compose.dev.yml up --build app
Access application:
This project supports three development modes:
Phoenix runs on host, services in Docker
Best for: Daily development with instant code reloading
docker compose -f docker-compose.dev.yml up -d postgres redis
export $(grep -v '^#' .env.dev | xargs)
mix phx.server
Full stack in Docker (matches production)
Best for: Testing Docker builds before deployment
docker compose -f docker-compose.dev.yml up --build app
Includes Baserow for data sync testing
Best for: Testing database integrations
docker compose -f docker-compose.dev.yml --profile integration up -d
# Baserow: http://localhost:8080
See DOCKER_DEV_GUIDE.md for detailed setup instructions.
mix test # Run all tests
mix test test/path/file.exs # Run specific test file
mix test --failed # Run only failed tests
Once database is running, test in iex:
# Start IEx
iex -S mix phx.server
# Test HSE Notices
EhsEnforcement.Agencies.Hse.Notices.api_get_hse_notices([pages: "1"])
# Test HSE Cases
EhsEnforcement.Agencies.Hse.Cases.api_get_hse_cases([pages: "1"])
The application is deployed to a Digital Ocean droplet using Docker Compose.
Production URL: https://legal.sertantai.com
# 1. Build production Docker image
./scripts/deployment/build.sh
# 2. Test locally (optional but recommended)
./scripts/deployment/test-container.sh
# 3. Push to GitHub Container Registry
./scripts/deployment/push.sh
# 4. Deploy to production
./scripts/deployment/deploy-prod.sh
# With migrations
./scripts/deployment/deploy-prod.sh --migrate --logs
All deployment scripts are in scripts/deployment/:
build.sh - Build production Docker imagetest-container.sh - Test container locally before deploymentpush.sh - Push image to GitHub Container Registrydeploy-prod.sh - Deploy to production servermix testmix ash.codegen --checkmix ash.migrate./scripts/deployment/test-container.shgit status priv/resource_snapshots/See Deployment Documentation for detailed deployment procedures.
lib/ehs_enforcement/*/resources/lib/ehs_enforcement_web/live/lib/ehs_enforcement/scraping/lib/ehs_enforcement/integrations/This project uses Ash Framework for data modeling. Important:
Ash.create/2, Ash.read/2, Ash.update/2, Ash.destroy/2AshPhoenix.Form for form handlingRepo.insert/update/deleteSee CLAUDE.md for full Ash framework guidelines.
ehs_enforcement/
āāā lib/
ā āāā ehs_enforcement/ # Business logic
ā ā āāā accounts/ # User authentication (Ash)
ā ā āāā agencies/ # Agency-specific scrapers
ā ā āāā enforcement/ # Core enforcement resources (Ash)
ā ā āāā integrations/ # Airtable, external APIs
ā ā āāā scraping/ # Web scraping coordination
ā āāā ehs_enforcement_web/ # Web interface
ā āāā live/ # LiveView pages
ā āāā components/ # Reusable UI components
āāā priv/
ā āāā repo/migrations/ # Database migrations
ā āāā resource_snapshots/ # Ash resource snapshots
āāā scripts/
ā āāā deployment/ # Deployment automation
āāā docker-compose.dev.yml # Development environment
āāā Dockerfile # Production container
# Development
mix phx.server # Start server
iex -S mix phx.server # Start with IEx
# Database
mix ecto.create # Create database
mix ecto.migrate # Run Ecto migrations
mix ash.migrate # Run Ash migrations (preferred)
mix ecto.reset # Drop, create, migrate, seed
# Ash Framework
mix ash.codegen --check # Generate Ash migrations
mix ash.migrate # Apply Ash migrations
# Testing
mix test # Run tests
mix test --failed # Run failed tests only
# Docker
docker compose -f docker-compose.dev.yml up -d postgres redis
docker compose -f docker-compose.dev.yml logs -f
docker compose -f docker-compose.dev.yml down -v
# Deployment
./scripts/deployment/build.sh
./scripts/deployment/test-container.sh
./scripts/deployment/push.sh
./scripts/deployment/deploy-prod.sh
git checkout -b feature/my-feature./scripts/deployment/test-container.sh[Add license information]