A Django-based framework for building FAIR research data portals with minimal code
FairDM makes it trivial for research teams to define domain-specific sample and measurement models and run a fully functional data portal without writing views, URL routing, or frontend code.
FairDM is an opinionated Django framework (not a library) designed specifically for research data management. It enables researchers with basic Python skills to:
- Define custom domain models for samples and measurements
- Get a fully functional web portal without writing views or templates
- Ensure data follows FAIR principles (Findable, Accessible, Interoperable, Reusable)
- Manage research projects, datasets, and contributors out of the box
- Import/export data in multiple formats with zero configuration
- Control access with fine-grained object-level permissions
- Configuration over code β Declarative model registration with sensible defaults
- Domain-first modeling β Focus on accurate scientific data representation
- Progressive complexity β Simple defaults, powerful extension points for advanced users
- Frontend-free for users β No template/JS knowledge required for basic portals
- FAIR by design β Metadata, stable identifiers, and APIs built-in
- Python 3.13+
- Poetry for dependency management
- PostgreSQL (recommended) or SQLite for development
# Clone the repository
git clone https://github.com/FAIR-DM/fairdm.git
cd fairdm
# Install dependencies with Poetry
poetry install
# Activate the virtual environment
poetry shell
# Run database migrations
poetry run python manage.py migrate
# Create a superuser
poetry run python manage.py createsuperuser
# Run the development server
poetry run python manage.py runserverVisit http://localhost:8000 to see your portal!
FairDM organizes research data using a hierarchical structure:
Project
βββ Dataset
βββ Sample (your custom types)
β βββ Measurement (your custom types)
βββ Sample
βββ Measurement
- Project: Top-level container for research initiatives
- Dataset: Collection of related samples with shared metadata
- Sample: Domain-specific sample types (e.g., RockSample, WaterSample)
- Measurement: Domain-specific measurements on samples (e.g., XRFMeasurement)
The heart of FairDM is its registry system. Define your models, register them, and get automatic:
- β Create/Read/Update/Delete views
- β List tables with sorting and filtering
- β Forms with Bootstrap 5 styling
- β REST API endpoints (optional)
- β Import/Export functionality
- β Admin integration
# myapp/models.py
from fairdm.core import Sample
from django.db import models
class RockSample(Sample):
"""Custom sample type for geological specimens."""
rock_type = models.CharField(max_length=100)
collection_date = models.DateField()
weight_grams = models.DecimalField(max_digits=10, decimal_places=2)
location = models.CharField(max_length=200)
# myapp/config.py
from fairdm.registry import register
from fairdm.registry.config import ModelConfiguration
from .models import RockSample
@register
class RockSampleConfig(ModelConfiguration):
model = RockSample
fields = ["name", "rock_type", "collection_date", "weight_grams", "location"]
display_name = "Rock Sample"
description = "Geological rock samples with basic metadata"That's it! You now have:
- A working web interface for managing rock samples
- Sortable/filterable tables
- Create/edit/delete forms
- Import/export to CSV/Excel
- REST API endpoints (if enabled)
For every registered model, FairDM automatically generates:
| Component | Library | Purpose |
|---|---|---|
| Forms | Django Forms + Crispy Forms | Create/edit with Bootstrap 5 styling |
| Tables | django-tables2 | Sortable, paginated lists |
| Filters | django-filter | Advanced filtering UI |
| Serializers | Django REST Framework | JSON API responses |
| Resources | django-import-export | CSV/Excel import/export |
| Admin | Django Admin | Optional admin interface |
- Object-level permissions via django-guardian
- Role-based access (viewer, editor, manager) at Project/Dataset level
- Public/private dataset visibility controls
- Team collaboration with user invitations
- Formats: CSV, Excel (XLSX), JSON, ODS
- Background processing: Large imports via Celery tasks
- Validation: Automatic field validation and error reporting
- Templates: Export sample templates for data collection
Extend FairDM with custom functionality:
- Add analysis panels to detail views
- Create custom visualizations
- Integrate third-party tools
- Build domain-specific workflows
- Bootstrap 5 β Responsive, accessible UI components
- HTMX β Dynamic interactions without writing JavaScript
- Alpine.js β Lightweight reactivity for complex interactions
- Django Cotton β Reusable component-based templates
Full documentation is available at: https://fairdm.github.io/fairdm/
- User Guide β For portal users and contributors
- Developer Guide β Build your own research portal
- Admin Guide β Portal administration and maintenance
- Contributing β Contribute to FairDM framework development
Explore a working example in the fairdm_demo/ directory:
# The demo app showcases:
# - Custom Sample and Measurement models
# - Model registration and configuration
# - Custom forms, tables, and filters
# - Plugin development examplesThe demo app serves as executable documentation and demonstrates best practices for building portals with FairDM.
# Run the full test suite
poetry run pytest
# Run with coverage
poetry run pytest --cov=fairdm --cov-report=html
# Run specific test file
poetry run pytest tests/test_registry.py
# Run with verbose output
poetry run pytest -vFairDM uses Ruff for linting and formatting:
# Lint the codebase
poetry run ruff check .
# Format code
poetry run ruff format .
# Check type hints with mypy
poetry run mypy fairdmUseful Invoke tasks (see tasks.py):
# Show available tasks
poetry run invoke -l
# Run database migrations
poetry run invoke migrate
# Create test data
poetry run invoke create-test-data
# Build documentation
poetry run invoke docs- Django 5.1+ β Web framework
- Python 3.13+ β Programming language
- PostgreSQL β Database (recommended)
- Redis β Caching and task queue
- django-polymorphic β Polymorphic model inheritance
- django-guardian β Object-level permissions
- django-tables2 β Table rendering
- django-filter β Filtering system
- django-import-export β Data import/export
- django-htmx β HTMX integration
- django-cotton β Component-based templates
- celery β Background task processing
See pyproject.toml for the complete dependency list.
This project is licensed under the MIT License β see the LICENSE file for details.
We welcome contributions! See our Contributing Guide for:
- Quick setup: Run
bash scripts/dev-setup.shto get started - Development workflow: Install git hooks to prevent CI failures
- Code style and conventions: Ruff formatting (120 char lines)
- Testing requirements: pytest with >80% coverage goal
- Pull request process: Pre-push validation ensures CI passes
Before your first push, install git hooks to run CI checks locally:
poetry run invoke install-hooksThis prevents CI failures by running the same linting and formatting checks locally.
FairDM is under active development. Current focus areas:
- β Core framework and registry system
- β Model registration and auto-generation
- β Permissions and access control
- π§ Plugin system expansion
- π§ REST API enhancements
- π§ Advanced data visualization
- π Cloud deployment guides
- π Extended documentation
- Documentation: https://fairdm.github.io/fairdm/
- Issues: https://github.com/FAIR-DM/fairdm/issues
- Discussions: https://github.com/FAIR-DM/fairdm/discussions
- GitHub: https://github.com/FAIR-DM/fairdm
Made with β€οΈ for the research community