Architecture
Detailed overview of the ASL Methods Section Generator architecture
The ASL Methods Section Generator follows a modern, modular architecture designed for scalability, maintainability, and extensibility. The system is composed of three main components that work together to provide a comprehensive ASL data processing and report generation solution.
1. Frontend Application (Next.js)
Location: apps/frontend/
Technology Stack:
- Framework: Next.js 15.3.3 with React 19
- Styling: Tailwind CSS with shadcn/ui components
- State Management: React Context API
- HTTP Client: Axios for API communication
- Build Tool: Turbopack for development
Key Components:
- File Upload Interface: Folder selection
- Report Display: Interactive report viewing with error/warning highlighting
- Navigation: Sidebar navigation with theme support
- PDF Export: Client-side PDF generation capabilities
Architecture Patterns:
- Component-based architecture with reusable UI components
- Context-based state management for global application state
- Service layer for API communication
- Utility functions for file processing and validation
2. Backend API (FastAPI)
Location: apps/backend/
Technology Stack:
- Framework: FastAPI with Python 3.11
- ASGI Server: Uvicorn with auto-reload
- File Processing: Python multipart for file uploads
- PDF Generation: WeasyPrint for HTML to PDF conversion
API Endpoints:
POST /api/report/process # Process uploaded files
POST /api/report/missing-parameters # Handle missing parameters
POST /api/report/report-pdf # Generate PDF reports
GET / # API information
Key Features:
- File Upload Handling: Multipart form data processing
- Error Handling: Comprehensive error responses with HTTP status codes
- File Storage: Temporary file storage for processing
- PDF Generation: Server-side PDF report generation
3. Core Package (pyaslreport)
Location: package/src/pyaslreport/
Technology Stack:
- Core Dependencies: NiBabel, PyDICOM
- DICOM Processing: dicom2nifti for format conversion
- Validation: Custom validation schemas and rules
- Report Generation: Template-based report creation


Architecture Components:
Modality System
This handles the report generation for modalities (ASL, DSC, ..) Whenever you are implementing a new modality you have to follow the same stucture.
modalities/
āāā asl/ # ASL-specific processing
ā āāā processor.py # Main ASL processor
ā āāā validator.py # ASL validation logic
ā āāā report_generator.py # ASL report templates
ā āāā validators/ # Specific validators
āāā testdsc/ # DSC modality (in development)
āāā registry.py # Modality registration system
Sequence Management
This Handles the extraction of BDIS metadata (e.g. asl.json) from DICOM for vendors and organization implementation of modalities
sequences/
āāā factory.py # Sequence factory pattern
āāā ge/ # GE vendor sequences
ā āāā asl/ # GE ASL sequences
ā āāā dsc/ # GE DSC sequences
āāā siemens/ # Siemens vendor sequences
āāā philips/ # Philips vendor sequences
Input/Output System
io/
āāā readers/ # File reading utilities
ā āāā file_reader.py # Generic file reader
ā āāā nifti_reader.py # NIfTI file processing
ā āāā yaml_reader.py # YAML configuration reading
āāā writers/ # Output generation
āāā json_writer.py # JSON report output
āāā report_writer.py # Formatted report generation
āāā tsv_writer.py # TSV file output
1. File Upload Process
User Upload ā Frontend Validation ā Backend API ā File Storage ā Core Processing
2. Report Generation Process
Core Processing ā Validation ā Report Generation ā API Response ā Display
2. Modular Architecture
- Independent component development
- Plugin-based modality system
- Extensible validation framework
3. Performance Optimization
- Async file processing
- Efficient memory usage
- Caching strategies (planned)
Development Workflow
- Local Development: Docker Compose with volume mounting
- Testing: Automated tests for each component
- Staging: Containerized deployment
- Production: Orchestrated container deployment
2. Advanced Features
- Share Reports
- Version control for reports
- Integration with research platforms
Architecture Decisions: The current architecture prioritizes simplicity and maintainability while providing a solid foundation for future enhancements. Each component is designed to be independently deployable and testable.



