How aces/loris works
1. LORIS is a self-hosted PHP web platform for longitudinal research data management, centered on a MySQL database and a large module/plugin architecture. It serves clinical, behavioural, imaging, genetic, and electrophysiology workflows from the same codebase.
2. The runtime entry points live under htdocs/. Requests begin in front-controller PHP files such as index.php, router.php, survey.php, and module-specific AJAX endpoints. Static assets, legacy JS/CSS, and some direct-download handlers are also served from this web root.
3. The core application framework is in src/. This layer provides the common request/response stack: routing, middleware, HTTP abstractions, authentication, MFA, CSP/compression/ETag handling, language selection, page decoration, and error handling. It is the main boundary between the web server and feature modules.
4. Application features are primarily packaged as modules under modules/. Each module has its own PHP, JSX/TSX front end, templates, localization files, help docs, tests, and sometimes AJAX handlers or REST endpoints. This is a modular monolith rather than a microservice system.
5. The frontend is mixed-generation: older pages use Smarty templates and jQuery-era assets, while newer module UIs use React/TypeScript in jsx/. Shared UI primitives live in the repo root jsx/ and API/client helpers in jslib/. Webpack/Babel/TS tooling builds these assets.
6. Data access is database-first. The application model is encoded in the SQL/ directory, with release upgrade scripts, cleanup patches, and archived migrations, plus raisinbread/RB_files which mirrors the schema as table-definition SQL. Most module behavior ultimately reads/writes these relational tables.
7. Core domain boundaries are visible in the modules:
- study structure and identity: candidate_*, configuration, create_timepoint, timepoint_list, project/site/cohort logic
- data capture: instruments, instrument_builder, instrument_manager, media, publication, document_repository
- quality and review: imaging_qc, imaging_browser, mri_violations, conflict_resolver, issue_tracker
- specialized domains: electrophysiology_*, genomic_browser, biobank, data_release, dqt, redcap, oidc
- admin/security: login, user_accounts, my_preferences, module_manager, policy_tracker
8. The API surface is split into dedicated back-end packages such as modules/api and modules/dataquery, plus shared HTTP/query infrastructure in src/Http and src/Data/Query. These modules expose structured endpoints and schemas for programmatic access and internal UI data fetching.
9. File handling is a major architectural concern. Imaging, media, electrophysiology, publication uploads, and data-release files are uploaded through module-specific handlers, then tracked in database tables and sometimes transformed into downstream formats or indexed metadata. Several utility classes in php/libraries/ and src/Data/Models support these flows.
10. Authentication and authorization are cross-cutting and data-driven. Permissions, menu visibility, site/project scoping, MFA, and OIDC are enforced through core middleware plus database-backed permission tables. Modules typically declare their own permissions and menu items, which the core menu/router layer resolves at runtime.
11. Background and operational workflows live in tools/ and Procfile/Docker assets. This includes importers, exporters, data-integrity repair scripts, SQL generation, notification and digest jobs, module management, and deployment helpers. These scripts are part of the system architecture because many data flows are batch-oriented rather than interactive.
12. Testing and environment definition are first-class. The repo includes PHPUnit/unit/integration tests under test/ and per-module test plans, Docker test images, shell runners, and CI workflows in .github/workflows. Documentation under docs/ and readthedocs/ describes installation, schema conventions, module development, and operational setup.
13. Overall, the architectural diagram should show: browser/UI clients hitting PHP entry points; core src/ middleware/router/auth layers; feature modules with their own UI and endpoint logic; shared MySQL schema/migrations; and supporting background scripts, tests, and documentation around the edges.
Main entry points: SQL Schema · modules Modules · Data Data layer · src Core
Components 23
Clients & entry
Browser-facing entry points and web-root assets.
- htdocs · Front controllers, static assets, and direct handlers served from the document root.
htdocs
Core framework
Shared request handling, routing, security, and data primitives.
- Core · Shared application framework that connects web entrypoints to modules and data.
src - HTTP stack · HTTP abstractions, response types, endpoints, streams, and file passthrough.
src/Http - Routing · Base routers and module routing/auth dispatch.
src/Router - Middleware · Auth, MFA, CSP, compression, ETag, language, page decoration, and error handling.
src/Middleware - Data layer · Query, filtering, provisioning, DTOs, and model adapters over relational data.
src/Data - Security · Core security primitives including one-time-password support.
src/Security - Shared UI · Common React/TSX components and form primitives reused across modules.
jsx - Client libs · Shared HTTP client and error handling helpers for module UIs.
jslib
Feature modules
Major modular application areas.
- Modules · Module packaging convention for PHP endpoints, JSX UIs, templates, locales, and tests.
modules - Study setup · Candidate, project, site, cohort, and timepoint management.
modules/configuration - Data capture · Instruments, media, publication, and document workflows.
modules/instruments - Imaging · Imaging upload, browsing, QC, violations, and archive workflows.
modules/imaging_uploader - Electrophysiology · Electrophysiology upload and browser with chunked series visualization.
modules/electrophysiology_uploader - Genomics · Genomic browser and file/sample upload workflows.
modules/genomic_browser - Admin & access · Login, user accounts, preferences, module management, policy tracking, and OIDC.
modules/login - Query & API · REST/API endpoints and data query builder/execution surface.
modules/api - Quality & review · Conflict resolution, issue tracking, behavioural QC, and summary dashboards.
modules/conflict_resolver
Data & operations
Database schema, migrations, batch jobs, tests, and docs.
- Schema · Database schema, release migrations, cleanup patches, and generated table definitions.
SQL - Schema mirror · Table-definition SQL and legacy schema mirror used to validate the database model.
raisinbread/RB_files - Batch tools · Importers, exporters, repair jobs, module management, and deployment helpers.
tools - Tests · PHPUnit, integration, fixture, and module-specific test plans.
test - Docs · Installation, coding standards, module development, API, and operational documentation.
docs
Connections 27
- htdocs → Core: boots · Front controllers enter the shared application framework.
- Core → Routing: routes · Core framework dispatches requests through routing.
- Core → Middleware: wraps · Core framework applies middleware for auth, language, decoration, and errors.
- Routing → Modules: loads modules · Routes into module-specific PHP entry points and file routers.
- Middleware → HTTP stack: wraps · Middleware shapes HTTP requests and responses.
- Routing → HTTP stack: produces · Routing resolves endpoints and HTTP responses.
- Modules → Shared UI: renders · Modules compose shared React components and form primitives.
- Modules → Client libs: calls · Module front ends use shared HTTP/query helpers.
- Modules → Data layer: reads/writes · Modules persist and query domain data through the shared data layer.
- Data layer → Schema: maps to · Data abstractions correspond to the MySQL schema.
- Schema → Schema mirror: mirrors · Generated and archived table definitions track the live schema.
- Study setup → Schema: defines · Study identity and scoping tables anchor the domain model.
- Data capture → Schema: stores · Instruments, media, publication, and documents persist in relational tables.
- Imaging → Schema: stores · Imaging upload, archive, and QC state are database-backed.
- Electrophysiology → Schema: stores · Electrophysiology uploads and annotations are database-backed.
- Genomics → Schema: stores · Genomic files, samples, and analysis metadata persist in tables.
- Admin & access → Middleware: enforced by · Authentication, MFA, permissions, and OIDC are enforced centrally.
- Quality & review → Data layer: queries · Review and conflict workflows consume shared data/query infrastructure.
- Query & API → HTTP stack: serves · API and query endpoints are exposed over HTTP.
- Query & API → Data layer: executes · Structured queries are built and run against shared data models.
- Batch tools → Schema: maintains · Batch jobs and repair scripts manipulate schema and data directly.
- Batch tools → Data layer: imports/exports · Operational scripts reuse core data conventions and extractors.
- Tests → Modules: covers · Tests exercise module behavior and integration paths.
- Tests → Core: covers · Tests validate the core framework behavior.
- Docs → Modules: describes · Documentation explains module conventions and workflows.
- Docs → Schema: documents · Docs capture SQL modeling and deployment conventions.
- Docs → Batch tools: documents · Operational docs cover scripts and maintenance flows.