This file provides context for AI assistants working with this codebase.
BioPortal Web UI is a Ruby on Rails application for browsing and interacting with biological ontologies. It is the frontend for the BioPortal/OntoPortal platform and communicates with an independent REST API for almost all data.
- Live site: https://bioportal.bioontology.org/
- Repository: https://github.com/ncbo/bioportal_web_ui
- Development guide: See
developer/directory and setup instructions below
- Framework: Rails 8.0.3
- Ruby: 3.2.9 (see
.ruby-version) - Database: MySQL 8.0 (MariaDB compatible for dev)
- Cache: Memcached
- JavaScript: ES modules via esbuild, Hotwire (Turbo + Stimulus)
- CSS: Bootstrap 5.2, Dart Sass
- Template Engine: Haml
- View Components: ViewComponent + Lookbook
Uses the bioportal-dev Docker image built from the developer/ directory in this repo.
- Access to a BioPortal/OntoPortal API server (contact a current developer)
- Your API key from the API server's account page
From the bioportal_web_ui directory:
docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) \
-t bioportal-dev -f developer/Dockerfile.developer-environment developer/From the bioportal_web_ui directory:
docker run --name bpd --network host -it --rm \
-e BIOPORTAL_API_KEY=your_api_key_here \
-e BIOPORTAL_API_URL=https://your-api-server \
-e BIOPORTAL_PROXY_URL=http://your-annotator-proxy \
-e DB_PASSWORD=choose_any_password \
-v $(pwd):/home/developer/bioportal_web_ui \
bioportal-devThe container automatically:
- Starts memcached and mariadb
- Configures database with your password
- Generates config files (
database.yml,bioportal_config_development.rb) - Installs dependencies (yarn, bundler)
- Sets up the database
- Launches the dev server at http://localhost:3000
First run takes a few minutes. Subsequent runs are faster.
Press Ctrl+C to stop the dev server and exit the container.
- The database resets each time the container is removed
- Most JS, SCSS, and Ruby file changes hot-reload; config files require container restart
- The staging server could be reset at any time
- Some pages require admin access (admin protected)
- Dev uses Ruby 3.2.3 in container vs 3.2.9 in production - no issues so far
- MariaDB in dev is compatible with MySQL 5.7.44 target
The repository also includes a docker-compose.yml for an alternative setup:
cp .env.sample .env
# Edit .env with API_URL and API_KEY
docker compose up devServices: dev (Rails), node (JS/CSS watcher), db (MySQL 8.0), cache (Memcached)
Both Minitest and RSpec are used. Tests must run inside the Docker container
with sudo (because the entrypoint configures services as root).
Important: Most tests make live HTTP calls to the configured API server
($REST_URL), which can be slow (5-30s per call). Tests will appear to hang
after # Running: — this is normal; wait 1-2 minutes for the first dots to
appear. Use -v for verbose output showing test names as they start.
# Enter a running container
docker exec -it bpd bash
# Minitest (test/ directory)
sudo RAILS_ENV=test bin/rails test
sudo RAILS_ENV=test bin/rails test test/controllers/ontologies_controller_test.rb
# RSpec (spec/ directory)
sudo RAILS_ENV=test bundle exec rspec
sudo RAILS_ENV=test bundle exec rspec spec/models/
# System tests (headless Chrome, installed in dev container)
sudo RAILS_ENV=test bin/rails test:systemThe docker-compose.yml includes a chrome-server service for running system
tests via a standalone Selenium container. To use it instead of the dev
container's local Chrome, set SELENIUM_URL in the test service's environment:
test:
environment:
SELENIUM_URL: "http://localhost:4444"Then run:
docker compose run test bin/rails test:systemONTOLOGIES_TO_TEST=STY— limits ontologies controller tests to a single ontology instead of fetching the entire catalog from the API (recommended)TEST_TIMEOUT=300— per-test timeout in seconds (default: 180); tests that exceed this are reported as skips, not failuresSELENIUM_URL— when set, system tests use a remote Selenium server at this URL instead of local headless Chrome (e.g.http://localhost:4444)
- The session store uses
CacheStore(memcached), so the test environment needsconfig.cache_store = :memory_store(not:null_store) for flash and session data to persist across redirects IssueCreatorServicespecs require a GitHub token in Rails credentials (kgcl:github_access_token); they skip gracefully when absentsudostripsPATH; if you need yarn under sudo, install it globally first:sudo npm install -g yarn
app/
├── components/ # ViewComponent classes
├── controllers/ # Rails controllers
├── helpers/ # View helpers
├── javascript/ # Stimulus controllers, ES modules
├── models/ # ActiveRecord models, API wrappers
├── views/ # Haml templates
config/
├── bioportal_config_*.rb # Environment-specific BioPortal settings
├── database.yml # Database configuration
├── routes.rb # URL routing
developer/ # Dockerfile, entrypoint, and config templates for dev container
public/browse/ # Legacy Angular browse application
spec/ # RSpec tests
test/ # Minitest tests
config/bioportal_config_development.rb- Portal settings, API key, feature flagsconfig/database.yml- Database connection settings
$API_KEY- BioPortal API authentication key$REST_URL- BioPortal REST API URL (set viaBIOPORTAL_API_URLenv var)$UI_URL- This application's URL$SITE/$ORG- Site name and organization
- Ruby: RuboCop (
bundle exec rubocop) - JavaScript: ESLint + Prettier (
yarn lint,yarn lint:fix) - Security: Brakeman (
bundle exec brakeman)