Contributing to Neural MRI Scanner
Thanks for your interest in contributing! This document covers the development workflow and guidelines.
Development Setup
See INSTALL.md for detailed setup instructions including prerequisites, GPU configuration, and environment variables.
Quick start:
# Backend
cd backend
uv sync --extra dev
uv run uvicorn neural_mri.main:app --reload --port 8000
# Frontend
cd frontend
pnpm install
pnpm dev
Code Style
Backend (Python)
We use ruff for linting and formatting:
cd backend
uv run ruff check . # lint
uv run ruff format --check . # format check
uv run ruff format . # auto-format
Configuration is in pyproject.toml:
- Target: Python 3.11
- Line length: 100
- Rules: E, F, I, UP (pyflakes, pycodestyle, isort, pyupgrade)
Frontend (TypeScript)
- TypeScript strict mode (
tsc --noEmitmust pass) - React 18 functional components with hooks
- Zustand for state management — one store per feature domain
Branch & PR Workflow
- Fork the repository
- Create a branch from
main:git checkout -b feat/your-feature # or: fix/description, docs/description, refactor/description - Make your changes with clear, focused commits
- Run checks before pushing:
# Backend cd backend uv run ruff check . uv run ruff format --check . uv run pytest tests/ -v # Frontend cd frontend pnpm tsc --noEmit pnpm build - Push and open a Pull Request against
main - Fill out the PR template
Commit Messages
Use conventional-style prefixes:
feat:new featurefix:bug fixdocs:documentation onlyrefactor:code change that neither fixes a bug nor adds a featuretest:adding or updating testschore:build process, CI, dependencies
Issues
Reporting Bugs
Use the bug report template. Include:
- Steps to reproduce
- Expected vs actual behavior
- Environment details (OS, Python/Node version, GPU)
Requesting Features
Use the feature request template. Describe:
- The problem you're trying to solve
- Your proposed solution
- Alternatives you've considered
Running Tests
Backend
cd backend
uv sync --extra dev
uv run pytest tests/ -v # all tests
uv run pytest tests/ -v -k t1 # filter by name
Frontend
cd frontend
pnpm tsc --noEmit # type check
pnpm build # full build (includes tsc)
Project Structure
Neural-MRI/
├── backend/
│ └── neural_mri/
│ ├── main.py # FastAPI app
│ ├── core/ # Model manager, registry, cache
│ ├── scanners/ # T1, T2, fMRI, DTI, FLAIR
│ └── api/ # Route handlers
├── frontend/
│ └── src/
│ ├── App.tsx # Main app component
│ ├── components/ # UI components
│ ├── store/ # Zustand stores
│ ├── types/ # TypeScript types
│ ├── utils/ # Export, rendering utilities
│ └── i18n/ # Translations
├── docker-compose.yml
└── docs/
└── SPEC.md
License
By contributing, you agree that your contributions will be licensed under the MIT License.