FindingModelForge is a FastAPI-based web application for creating and managing medical imaging finding models. These models define semantic labels and structured attributes for medical imaging findings.
Current Branch: feature/finding-model-draft-saving (main branch: main)
📚 See specialized guides for detailed instructions:
- Backend Development:
app/CLAUDE.md- FastAPI, async patterns, repositories - Frontend/UI Development:
templates/CLAUDE.md- Flowbite, Alpine.js, HTMX - Testing:
tests/CLAUDE.md- Testing patterns, fixtures, commands
- FastAPI (0.115.0+) - Async web framework
- Python 3.12+ - With type hints throughout
- Pydantic - Data validation and settings
- Motor - Async MongoDB driver
- Redis - Optional caching layer
- JWT + GitHub OAuth - Authentication
- Jinja2 - Server-side templating
- Tailwind CSS v4 - Utility-first CSS
- Alpine.js - Reactive JavaScript
- Flowbite - Pre-built UI components
- HTMX - Server-driven interactions
- Vite - Build system
- MongoDB - Primary data store
- Redis - Session and cache storage
- Docker - Containerization
- GitHub Actions - CI/CD
FindingModelForge/
├── app/ # Backend application (see app/CLAUDE.md)
│ ├── routers/ # API endpoints
│ ├── database.py # Repositories
│ ├── dependencies.py # DI & sessions
│ └── models.py # Data models
├── templates/ # Frontend templates (see templates/CLAUDE.md)
│ ├── components/ # Reusable UI
│ └── macros/ # Jinja2 macros
├── tests/ # Test suite (see tests/CLAUDE.md)
├── static/ # Built assets
├── src/ # Frontend source
├── docs/ # Documentation
└── .serena/ # AI context & memories
- Always use type hints
- Use
Annotatedfor FastAPI dependencies - Run
mypybefore committing
- Use
async/awaitfor all I/O operations - Never block the event loop
- Leverage Motor for MongoDB, aioredis for Redis
- ✅ ALWAYS use Flowbite components from docs
- ✅ ALWAYS use Alpine.js for interactivity
- ❌ NEVER create custom CSS classes
- ❌ NEVER write custom JavaScript
- See
templates/CLAUDE.mdfor details
- Comprehensive unit tests (70 tests, 71% router coverage achieved)
- Priority-based organization: Critical paths → State transitions → Edge cases → Access control
- Realistic test data: Valid ObjectIds, proper session mocking, comprehensive assertions
- Integration tests for full workflows with real services
- Playwright for end-to-end browser testing
- Router testing patterns: See
tests/CLAUDE.mdfor examples
- Validate all input with Pydantic
- Check resource ownership before access
- Use parameterized database queries
- Store secrets in environment variables
- Enable CORS restrictions in production
# Setup everything
task setup
# Run development server
task dev
# Run tests
task test-unit # Fast unit tests
task test # Full test suite- Format & Lint:
task lint - Type Check:
uv run mypy app - Test:
task test-unit(fast) ortask test(comprehensive) - Check UI: Ensure Flowbite patterns followed
- Verify: All router tests pass (71% coverage maintained)
- Add API endpoint: See
app/CLAUDE.md - Add UI component: See
templates/CLAUDE.md - Add tests: See
tests/CLAUDE.md
Required .env file:
# Security
SECRET_KEY="strong-random-key"
GITHUB_CLIENT_ID="your-oauth-app-id"
GITHUB_CLIENT_SECRET="your-oauth-secret"
# Database
MONGODB_URI="mongodb://localhost:27017"
MONGODB_DB="findingmodelforge"
# Redis (optional but recommended)
REDIS_ENABLED=true
REDIS_HOST="localhost"
REDIS_PORT=6379- Multi-step workflow with HTMX
- AI-powered generation and similarity detection
- Draft autosave and resume functionality
- Submit and lock mechanism
Complete lifecycle with unified approach:
- Unified endpoint pattern:
GET /drafts/{id}?mode=edit|viewfor all draft operations - Auto-save on step 4: Automatic draft creation/update during attributes editing
- Session adoption: Seamless recovery when sessions are lost via draft_id
- User isolation: One editable draft per (user_id, name) with secure ownership
- Action logging: Comprehensive audit trail for all operations
- Status management: draft → submitted (locked from further edits)
- Smart resume: Name-based lookup shows submitted models in view mode
- Check logs:
tail -f logs/app.log - Verify services:
docker-compose ps - Session issues: Check Redis connection
- UI problems: Ensure
initFlowbite()called after HTMX swaps - Type errors: Run
mypy app --show-error-codes
- Do what's asked, nothing more - Avoid over-engineering
- Prefer editing over creating - Modify existing files when possible
- Follow conventions - Match existing code style
- Document complex logic - But avoid obvious comments
- Test critical paths - Especially auth and data operations
- FastAPI Docs: https://fastapi.tiangolo.com
- Flowbite Components: https://flowbite.com/docs/components/
- Alpine.js: https://alpinejs.dev
- Tailwind CSS: https://tailwindcss.com
- Finding Model Library: Internal
findingmodelpackage
Remember: This is a medical domain application. Maintain high code quality, comprehensive testing, and proper error handling throughout.