# mfortea/siteme architecture

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

- Interactive diagram: https://gitdiagram.com/mfortea/siteme
- Repository: https://github.com/mfortea/siteme

## Overview

##### Project Type and Purpose
- SiteMe is a full-stack web application built with PHP’s Symfony 5 framework. Its main purpose is to allow users to discover nearby establishments and places based on a search criterion and to save these locations in their personal account.
- It relies on external services such as Google Maps API and OpenStreetMaps (with Leaflet) for map integrations, along with Bootstrap for responsive design and additional JavaScript libraries like Micromodal.js for modals.

##### Analyzing the File Structure
- Notice the separation between server-side code and frontend assets:
- The Symfony-specific directories include folders such as /config, /src, /templates, and several environment and dependency files (composer.json, composer.lock).
- The /src directory is broken down into logical modules: API integration (src/API), controllers (src/Controller), data fixtures, entities, forms, security, and services. This indicates layered architecture (Controller, Service/Business Logic, Data Access).
- The /public directory houses client-side assets (CSS, JavaScript, images) as well as the entry point (public/index.php) for web requests.
- Additional configuration directories like /config/packages and /config/routes suggest that environment-specific details (dev, prod, test etc.) are managed separately.

##### Key Components
a. Frontend Client (Browser)
- Responsible for presenting the UI rendered via Twig templates (located in /templates) and static assets (JS, CSS from /public).
- The browser interacts with the web server, consumes data from APIs, and leverages libraries such as Leaflet, Micromodal.js, and Bootstrap 4.

b. Backend Server (Symfony Application)
- Controllers: Manage HTTP requests and responses (in /src/Controller).
- Business Logic: Incorporated in Services (e.g., src/Service/SitiosService.php) that handle the core application logic.
- Database & Persistence: Uses Doctrine ORM (configured in /config/packages/doctrine.yaml) with Entities and Repositories (e.g., /src/Entity and /src/Repository) for data management.
- Forms & User Authentication: Managed via Form classes and Authentication classes (e.g., src/Security/LoginFormAuthenticator.php, form classes in /src/Form).
- API Integration Layer: Includes integration with Google Maps and (presumably) OpenStreetMaps via classes such as src/API/GMapsApiSitios.php and the mocking alternative in MockApiSitios.php.

c. External Services
- Google Maps API and OpenStreetMaps: For fetching location data.
- Notifier (and the mention of web push notifications) suggesting integration with an external notifications server.

d. Configuration and Environment Management
- /config: Holds environment-specific configurations (dev, prod, test) that define behavior and integrations.
- Deployment Scripts: Including Procfile and environment files (.env) indicate deployment and runtime settings.

##### Relationships and Interactions
- The browser (frontend) sends HTTP requests to the Symfony backend.
- Symfony controllers receive requests, validate user inputs (via form models), and execute business logic using the service layer.
- Controller actions may trigger database operations using Doctrine, facilitated through corresponding Repositories.
- The application’s business logic uses API services to retrieve data from external APIs (Google Maps API and OpenStreetMaps) and might interact with external notification services.
- The rendered responses (using Twig templates) include dynamic content as well as static assets.

##### Architectural Patterns and Design Principles
- Layered/MVC Architecture: Clear separation between the presentation (templates, public assets), business logic (services, controllers), and data access (entities, repositories).
- Environment Separation: Different configurations for production, development, and testing defined in distinct config directories.
- API Integration Abstraction: The presence of both a concrete API class and a mock (MockApiSitios.php) suggests that dependency inversion and testing are considered.

##### Essential Elements
- Each component should have a clear label (e.g., "Frontend Client", "Symfony Controller", "Service Layer", "Database", "Google Maps API", etc.).
- Optionally, include deployment artifacts like environment configurations if relevant (displaying separate settings for dev, prod, and testing).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Browser (User Client)"]:::client
        Assets["Static Assets (/public)"]:::assets
        Templates["HTML Templates (/templates)"]:::templates
    end

    %% Backend Layer: Symfony Application
    subgraph "Symfony Application (Backend)"
        subgraph "Controllers Layer"
            Controllers["Controllers (/src/Controller)"]:::controller
        end

        subgraph "Business Logic Layer"
            Service["Service Layer (/src/Service)"]:::service
        end

        subgraph "API Integration Layer"
            API["API Integration (/src/API)"]:::api
        end

        subgraph "Persistence Layer"
            Entities["Entities (/src/Entity)"]:::entity
            Repositories["Repositories (/src/Repository)"]:::repo
            DBConfig["DB Configuration (config/packages/doctrine.yaml)"]:::config
        end

        subgraph "Auth & Forms"
            Auth["User Authentication (/src/Security)"]:::auth
            Forms["Forms (/src/Form)"]:::form
        end

        subgraph "Environment & Configuration"
            Config["Configuration Files (config & .env)"]:::config
        end
    end

    %% External Services
    subgraph "External Services"
        Maps["Google Maps API"]:::external
        OSM["OpenStreetMaps API (Leaflet)"]:::external
        Notifier["Notifications Service"]:::external
    end

    %% Connections between Frontend and Backend
    Browser -->|"HTTP_Request"| Controllers
    Browser -->|"Loads"| Assets
    Browser -->|"Renders"| Templates

    %% Internal Backend Interactions
    Controllers -->|"Executes_Logic"| Service
    Controllers -->|"Handles_Auth"| Auth

    Service -->|"Calls_API"| API
    Service -->|"DB_Query"| Repositories
    Service -->|"Uses_Entities"| Entities
    Service -->|"Sends_Notification"| Notifier

    API -->|"Fetches_Data"| Maps
    API -->|"Fetches_Data"| OSM

    Controllers -->|"Renders_View_with"| Templates

    Auth -->|"Validates"| Forms

    %% Configuration Dependencies
    Service ---|"Config_Dependency"| Config
    Controllers ---|"Config_Dependency"| Config
    API ---|"Config_Dependency"| Config
    Repositories ---|"DB_Config"| DBConfig

    %% Click Events
    click Assets "https://github.com/mfortea/siteme/tree/master/public"
    click Templates "https://github.com/mfortea/siteme/tree/master/templates"
    click Controllers "https://github.com/mfortea/siteme/tree/master/src/Controller"
    click Service "https://github.com/mfortea/siteme/blob/master/src/Service/SitiosService.php"
    click API "https://github.com/mfortea/siteme/blob/master/src/API/GMapsApiSitios.php"
    click Entities "https://github.com/mfortea/siteme/tree/master/src/Entity"
    click Repositories "https://github.com/mfortea/siteme/tree/master/src/Repository"
    click DBConfig "https://github.com/mfortea/siteme/blob/master/config/packages/doctrine.yaml"
    click Auth "https://github.com/mfortea/siteme/blob/master/src/Security/LoginFormAuthenticator.php"
    click Forms "https://github.com/mfortea/siteme/tree/master/src/Form"
    click Config "https://github.com/mfortea/siteme/tree/master/config"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef assets fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef templates fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef controller fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef service fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef api fill:#d6d8d9,stroke:#1b1e21,stroke-width:2px;
    classDef entity fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
    classDef repo fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef config fill:#fefefe,stroke:#6c757d,stroke-width:2px;
    classDef auth fill:#e8daef,stroke:#8a2be2,stroke-width:2px;
    classDef form fill:#dff9fb,stroke:#130f40,stroke-width:2px;
    classDef external fill:#e9ecef,stroke:#007bff,stroke-width:2px,stroke-dasharray: 5 5;
```
