How muranyigyorgy/laravel-nayra works
Main Components
• Laravel Application Layer – This is the host application that will use the package. It includes web routes, controllers (or route closures), and blade templates for process interaction.
• Nayra BPMN Engine – The core engine implementation located in the src/Nayra directory. This includes the Engine, JobManager, CallActivity, FormalExpression, and ScriptTask components.
• Facade – The Nayra facade defined in src/Facades/Nayra, which provides a clean interface for starting processes, completing tasks, etc.
• Job Layer – Located in src/Jobs, there are timer-related and script-related jobs (CycleTimerJob, ScriptTaskJob, TimerJob) that facilitate asynchronous BPMN process handling via Laravel’s queue.
• Repositories – Implementations (in src/Repositories) of data access components including InstanceRepository, RequestRepository, and TokenRepository. Additionally, a Contract interface (in src/Contracts) defines the expected behavior.
• Models & Database – The Request model in src/Models along with the migrations in the database directory (e.g., create_requests_table.php) are responsible for persistent storage.
Relationships and Interactions
• The Laravel application (via defined web routes) invokes the Nayra facade.
• The facade routes the calls to the underlying BPMN engine (the Nayra classes and JobManager) to start, manage, and complete BPMN processes.
• When a process is started or a task is completed, the engine interacts with the Repositories to read/write process state to the database.
• The Job layer enqueues background processing tasks (like timer or script tasks) to the Laravel queue service.
• The BPMN process file (example.bpmn) acts as an external configuration that defines process flows, which the engine parses and executes.
Architectural Patterns and Design Principles
• Separation of Concerns – Splitting between the engine, data repositories, job processing, and Laravel integration.
• Facade Pattern – The Nayra facade abstracts away internal complexity, offering simple methods such as startProcess and completeTask.
• Dependency Injection – The ServiceProvider (src/Providers/PackageServiceProvider.php) likely binds implementations (Repositories, Engine, etc.) into the Laravel container.
• Asynchronous Processing – Use of Laravel’s queue system (handled by TimerJob, ScriptTaskJob, etc.) for process handling in the background.
Relevant Technologies, Frameworks, and Libraries
• Laravel framework (including its routing, service container, and queue features)
• Composer for package management (as indicated by composer.json)
• BPMN processing principles, with custom implementations in the package’s “Nayra” namespace.
• Laravel Web Routes/Controllers (the UI layer)
• Nayra Facade (a mediator between the web layer and engine)
• BPMN Engine (including core classes like Engine, JobManager)
• Job Processing Unit (depicting timer and script jobs)
• Data Access Layer (Repositories and Models)
• Database (which stores the process states via migrations)
• External BPMN File (e.g., the BPMN definition file)
• From the Web layer to the Facade (initiating actions such as starting a process)
• From the Facade to the Engine (executing process logic)
• From the Engine to the Job Processing Unit (enqueueing background jobs)
• From the Engine to the Repositories (interaction with the database storage)
• Control logic (e.g., engine and facade)
• Supporting infrastructure (e.g., jobs and repositories)
• External dependencies (e.g., the BPMN file and Laravel framework)
• Provide annotations where necessary to highlight:
• The dependency injection process (through the ServiceProvider)
• The asynchronous nature of jobs in the background queue service
• How the engine interprets BPMN definitions to manage process flows
• Every component is clearly labeled with its function.
• Double-check that each major layer (web, engine, data, jobs) is personal to this package’s integration within a Laravel project.