Skip to main content
OpenEyes is built on a modular, event-based architecture using the Yii 1.x PHP framework. This page covers the technical architecture and core design patterns.

Technology Stack

Core Framework

OpenEyes is built on Yii Framework 1.1.28, a high-performance PHP framework based on the Model-View-Controller (MVC) pattern.
protected/composer.json

Dependencies

Key dependencies include:
  • PHP 7.4+ with support for PHP 8.0 and 8.1
  • MySQL/MariaDB for data storage
  • PHPUnit 9.6.5 for testing
  • Faker for test data generation
  • PHPStan for static analysis

Architecture Overview

MVC Pattern

OpenEyes follows the classic Model-View-Controller pattern:

Core Models

The system is built around several key models:

Patient Model

The Patient model is central to the system:
protected/models/Patient.php

Event Model

Events represent clinical encounters:
protected/models/Event.php

Event-Based Architecture

BaseEventTypeController

All event modules extend BaseEventTypeController, which provides standardized CRUD operations:
protected/controllers/BaseEventTypeController.php
The controller is stateful and provides hooks for customization:
  • setElementDefaultOptions() - Set defaults on elements
  • setElementComplexAttributesFromData() - Set complex attributes
  • saveElementComplexAttributesFromData() - Save complex data

Event Type Modules

Each clinical event type is implemented as a module. Example from OphCiExamination:
protected/modules/OphCiExamination/OphCiExaminationModule.php

Module System

OpenEyes uses a modular architecture where functionality is organized into modules:

Module Structure

Module Naming Conventions

Modules follow specific prefixes based on type:
  • OphCi - Clinical Investigation (e.g., OphCiExamination)
  • OphDr - Drug/Prescription (e.g., OphDrPrescription)
  • OphTr - Treatment (e.g., OphTrOperationnote)
  • OphCo - Correspondence/Communication (e.g., OphCoCorrespondence)

Database Architecture

Migrations

Database schema changes are managed through migrations:
Each module can have its own migrations:

Versioned Models

Core models extend BaseActiveRecordVersioned to track changes:

Autoloading

Composer autoloading is configured for modern PHP namespaces:
composer.json

Component Architecture

Behaviors

Yii behaviors provide reusable functionality:

Widgets

Reusable UI components:

Helpers

Utility functions and helper classes:

Configuration

Main Configuration

Configuration is loaded through OEConfig:
protected/config/main.php
Local overrides can be placed in:

Event System

OpenEyes uses Yii’s event system for extensibility:
  • Event listeners in protected/listeners/
  • Components can raise and listen for events
  • Modules can hook into application-wide events

Services Layer

Business logic is organized into services:

Security

Access Control

Access control is managed through:
  • Role-based access control (RBAC)
  • Controller-level access rules
  • Action-type based permissions

Data Validation

All models implement validation rules:

Performance Considerations

Caching

Yii provides caching mechanisms:
  • Database query caching
  • Fragment caching
  • Full page caching

Asset Management

Assets are organized per module:

Next Steps

Module Development

Learn how to create custom modules

Testing

Understanding the testing approach