# rosengate/exedra architecture

> Architecture diagram of the GitHub repository rosengate/exedra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rosengate/exedra
- Repository: https://github.com/rosengate/exedra

## Overview

##### Project Overview
- Type: PHP microframework.
- Purpose: To provide a minimal, flexible and container-based routing system with support for PSR-7/PSR-15 HTTP messages, explicit dependency injection, and middleware.
- Key features include nestable routes, annotated controller actions, middleware-enforced routing groups and minimal, highly modular design.

##### Identifying Main Components
- Application Core
- The Application class (Exedra/Application.php) is the entry point that bootstraps the framework.
- Configuration
- Config.php (Exedra/Config.php) holds configuration settings.
- Routing System
- Routing: Files under Exedra/Routing (e.g., Route.php, Group.php, CallStack.php, etc.) showcase how routes and groups are defined and linked.
- Routeller: A set of tools and attributes address route annotations and metadata (e.g., Exedra/Routeller/Attributes, RoutellerProvider.php).
- HTTP Layer
- HTTP messages: Exedra/Http includes Request, Response, ServerRequest, Stream, Uri and UploadedFile.
- This layer ensures conformity with PSR-7 and supports middlewares.
- Dependency Injection (Container)
- Container and Registry classes (Exedra/Container) manage services and dependencies.
- Middleware & Runtime
- Runtime: Module (Exedra/Runtime) that includes CallHandler, Context, Redirect.
- Middleware is supported both directly and via the Routes (see the sample code in the README where middleware is applied to route groups).
- Development & Console Utilities
- Console commands (e.g., ServeCommand.php, RouteListCommand.php in Exedra/Console/Commands) for CLI operations.
- Utility & Support Modules
- Supporting classes like Autoloader (Exedra/Support/Autoloader.php), file handling, and wireman for dependency resolution.
- Additional Components:
- Form handling (Exedra/Form), Session management (Exedra/Session), View rendering (Exedra/View) and URL generation (Exedra/Url).

##### Relationships and Data Flow
- The Application core initializes configuration, loads the dependency injection container, and registers all providers (including routing, session, view, etc.).
- HTTP Requests enter through the HTTP layer where the Request and Response objects are managed.
- The Routing System intercepts the request – matching it to the correct route (or nested group) and then resolving the controller or action. Middleware may wrap the execution flow.
- The container supplies dependencies to controllers, middleware, and other components, ensuring explicit dependency injection.
- Console utilities provide command-based interactions, e.g., serving the application or listing all available routes.

##### Architectural Patterns and Design Principles
- Modular Architecture: Core responsibilities (routing, HTTP handoff, dependency injection, etc.) are encapsulated in separate directories.
- Nested/Group Routing: Emphasis on nestable route definitions and middleware grouping.
- Interface Contracts: The use of “Contracts” (e.g., Routing, Runtime) promotes a clear separation of interfaces and implementations.
- Explicit Dependency Injection: Dependencies are injected via container-based resolution (no autowiring).
- PSR Compliance: Supports PSR-7/PSR-15 standards for HTTP message handling and middleware.

- Application Core: Starting point for the framework.
- Configuration & Container: Indicate how configuration is linked to dependency injection.
- HTTP Layer: Show a Request entering the system, interacting with the Router.
- Routing & Routing Annotation (Routeller): Show layered routing handling – starting from a Route List, then middleware attachment, and lastly, execution handling.
- Console Tools: Illustrate the alternative command-line interactions (e.g., serving the application, route listing).
- Utility Modules: Optionally showcase support for forms, sessions, URL generation, and views to round out the helper functionalities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Exédra Microframework Architecture"
        A["Application Core"]:::app
        B["Configuration"]:::config
        C["Dependency Injection"]:::container
        D["HTTP Layer"]:::http
        G["Console Utilities"]:::console
        H["Utility & Support Modules"]:::support
        subgraph "Routing System"
            E1["Core Routing"]:::routing
            E2["Routeller"]:::routing
        end
        F["Middleware & Runtime"]:::middleware
        subgraph "Additional Components"
            I1["Form Handling"]:::additional
            I2["Session Management"]:::additional
            I3["View Rendering"]:::additional
            I4["URL Generation"]:::additional
        end
    end

    %% Relationships
    A -->|"init"| B
    A -->|"load"| C
    A -->|"dispatch"| D
    D -->|"route"| E1
    D -->|"route"| E2
    E1 -->|"invoke"| F
    E2 -->|"invoke"| F
    F -->|"respond"| D
    A -->|"CLI"| G
    F -->|"utilize"| H
    G -->|"support"| H
    H -->|"contains"| I1
    H -->|"contains"| I2
    H -->|"contains"| I3
    H -->|"contains"| I4

    %% Click Events
    click A "https://github.com/rosengate/exedra/blob/master/Exedra/Application.php"
    click B "https://github.com/rosengate/exedra/blob/master/Exedra/Config.php"
    click C "https://github.com/rosengate/exedra/tree/master/Exedra/Container"
    click D "https://github.com/rosengate/exedra/tree/master/Exedra/Http"
    click E1 "https://github.com/rosengate/exedra/tree/master/Exedra/Routing"
    click E2 "https://github.com/rosengate/exedra/tree/master/Exedra/Routeller"
    click F "https://github.com/rosengate/exedra/tree/master/Exedra/Runtime"
    click G "https://github.com/rosengate/exedra/tree/master/Exedra/Console/Commands"
    click H "https://github.com/rosengate/exedra/blob/master/Exedra/Support/Autoloader.php"
    click I1 "https://github.com/rosengate/exedra/tree/master/Exedra/Form"
    click I2 "https://github.com/rosengate/exedra/tree/master/Exedra/Session"
    click I3 "https://github.com/rosengate/exedra/tree/master/Exedra/View"
    click I4 "https://github.com/rosengate/exedra/tree/master/Exedra/Url"

    %% Styles
    classDef app fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef config fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef container fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef http fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef routing fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef middleware fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef console fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef support fill:#F0E68C,stroke:#333,stroke-width:2px;
    classDef additional fill:#AFEEEE,stroke:#333,stroke-width:2px;
```
