# alextselegidis/easyappointments architecture

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

- Interactive diagram: https://gitdiagram.com/alextselegidis/easyappointments
- Repository: https://github.com/alextselegidis/easyappointments

## Overview

##### Project Type and Purpose
- The README makes it clear that Easy!Appointments is a self-hosted appointment scheduler. It allows customers to book appointments and supports external services such as Google Calendar, email notifications, and LDAP integration.
- The project is a full-stack application built in PHP using CodeIgniter (as evidenced by the “system” and “application” folders which follow the CodeIgniter structure). It leverages an MVC pattern for its interaction logic.

##### Analyzing the File Structure
- Major directories such as “application” (which holds controllers, models, views, configuration, helpers, and language files) indicate the core business logic in MVC format.
- “assets” holds the client-side elements: CSS stylesheets (including themes), JavaScript (both custom code and utility libraries), and images. This separates the web interface’s presentation layer clearly from the backend.
- “system” includes the CodeIgniter core libraries, showing that much of the web framework functionality is handled here.
- “libraries” and “migrations” under “application” demonstrate custom extensions (e.g., integration with Google or LDAP) and database versioning.
- The presence of Docker and configuration files (docker-compose.yml, nginx configs, PHP-FPM) highlights that containerized deployment is supported.

##### Key Components
- Client / Browser – represents the user’s browser accessing the application.
- Web Server – Apache or Nginx handling HTTP requests. Note that there is also a Dockerized PHP-FPM container for PHP execution.
- Frontend – assets (HTML, CSS, JavaScript) and view templates located in application/views and assets.
- Application Layer (Backend – MVC)
▪ Controllers – located under application/controllers (plus API controllers under application/controllers/api/v1).
▪ Models – data access and business logic in application/models.
▪ Views – the presentation layer in application/views (with separate layouts and components).
▪ Core libraries – custom PHP libraries under application/libraries, and extended core functionality under application/core.
- Database – a MySQL (or similar) database accessed via CodeIgniter’s DB abstraction; configuration is in application/config/database.php.
- External Services
▪ Google Calendar – through libraries like Google_sync.php.
▪ Email Notification – via EA_Email and email configurations.
▪ LDAP and third-party integrations – seen in controllers and libraries (e.g., Ldap_client.php).
▪ Other integrations such as Matomo analytics, CalDAV sync, and webhooks.
- Deployment Environment – represent Docker containers where applicable (for PHP-FPM, Nginx) as well as configuration files guiding deployment.

##### Relationship and Data Flow
- The web server (Apache/Nginx, potentially running inside Docker containers) passes the request to the PHP runtime which then loads CodeIgniter core from the “system” folder.
- CodeIgniter routes the request to the appropriate Controller in the “application/controllers” folder. These controllers then interact with Models (business logic/data access within “application/models”) and eventually load Views (located in “application/views”) to be sent as HTTP responses.
- The Controllers and Models use helpers, libraries, and migrations – making clear how configuration files in “application/config” and custom classes in “application/libraries” (for example, for Google, LDAP or calendar sync) contribute to the business logic.
- Data storage is managed via a database (configured through application/config/database.php) – illustrate the read/write flows from the application to the database.
- External service integrations (such as Google Calendar sync, email notifications, etc.) are initiated by controllers or libraries, so include directional lines showing outbound communication to these services.

##### Architectural Patterns and Technologies
- MVC Pattern – separation of controllers, models, and views.
- REST API Support – the “api/v1” controllers indicate a RESTful interaction (these should be highlighted as separate API endpoints).
- Containerization – Docker configuration for isolating the web server and PHP environments.
- Use of CodeIgniter framework – core system provided under “system” and custom modifications in “application/core”.
- Frontend frameworks and themes – assets include multiple SCSS/CSS themes to tailor the UI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    A["Client (Browser)"]:::frontend

    %% Deployment Environment Subgraph
    subgraph "Deployment Environment"
        DA["Docker Compose"]:::depl
        DB["Nginx Server"]:::depl
        DC["PHP-FPM Container"]:::depl
        DA --> DB
        DB --> DC
    end

    %% Application Layer (MVC)
    subgraph "Application Layer (MVC)"
        BA["Controllers"]:::backend
        BB["Models"]:::backend
        BC["MVC Views"]:::backend
        BD["Core Libraries"]:::backend
        BA --> BB
        BA --> BC
        BA --> BD
    end

    %% Database
    C["Database"]:::database

    %% External Services Subgraph
    subgraph "External Services"
        EA["Google Calendar Integration"]:::external
        EB["Email Notification"]:::external
        EC["LDAP Integration"]:::external
    end

    %% Flow Connections
    A --> DA
    DC --> BA
    BB --> C
    C -- "read/write" --> BB
    BA --> EA
    BA --> EB
    BA --> EC
    BC --> A

    %% Click Events
    click A "https://github.com/alextselegidis/easyappointments/tree/main/assets/"
    click A "https://github.com/alextselegidis/easyappointments/tree/main/application/views/"

    click DA "https://github.com/alextselegidis/easyappointments/blob/main/docker-compose.yml"
    click DB "https://github.com/alextselegidis/easyappointments/blob/main/docker/nginx/nginx.conf"
    click DC "https://github.com/alextselegidis/easyappointments/tree/main/docker/php-fpm/Dockerfile"

    click BA "https://github.com/alextselegidis/easyappointments/tree/main/application/controllers/"
    click BA "https://github.com/alextselegidis/easyappointments/tree/main/application/controllers/api/v1/"

    click BB "https://github.com/alextselegidis/easyappointments/tree/main/application/models/"

    click BC "https://github.com/alextselegidis/easyappointments/tree/main/application/views/"

    click BD "https://github.com/alextselegidis/easyappointments/tree/main/application/core/"
    click BD "https://github.com/alextselegidis/easyappointments/tree/main/application/libraries/"

    click C "https://github.com/alextselegidis/easyappointments/blob/main/application/config/database.php"
    click C "https://github.com/alextselegidis/easyappointments/tree/main/application/migrations/"

    click EA "https://github.com/alextselegidis/easyappointments/blob/main/application/config/google.php"
    click EA "https://github.com/alextselegidis/easyappointments/blob/main/application/libraries/Google_sync.php"

    click EB "https://github.com/alextselegidis/easyappointments/blob/main/application/config/email.php"
    click EB "https://github.com/alextselegidis/easyappointments/blob/main/application/core/EA_Email.php"

    click EC "https://github.com/alextselegidis/easyappointments/blob/main/application/controllers/Ldap_settings.php"
    click EC "https://github.com/alextselegidis/easyappointments/blob/main/application/libraries/Ldap_client.php"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef depl fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#818182,stroke-width:2px;
```
