# n7consulting/incipio architecture

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

- Interactive diagram: https://gitdiagram.com/n7consulting/incipio
- Repository: https://github.com/n7consulting/incipio

## Overview

##### Project type and purpose
- Jeyser CRM is a monolithic Symfony-based ERP/CRM web application.
- It exposes a browser-based UI, backed by PHP controllers, Twig templates, Doctrine ORM, and various Symfony services.
- It’s packaged for Docker-Compose with a Traefik reverse proxy, MySQL, mailer service, and the PHP web container.

##### File structure
- Top-level “docker” and “docker-compose.yml.dist” define the deployment architecture (Traefik proxy, web, mysql, mail).
- “public/” holds the front controller (index.php), assets (CSS/JS/images), and the manifest.
- “src/” follows standard Symfony MVC:
- Controller/ – HTTP controllers by feature
- Entity/ – Doctrine entities for domain objects
- Repository/ – data access layers
- Service/ – business logic modules (comments, key-value store, project and publishing services)
- EventListener/ – domain event subscriptions
- Form/ – request validation and form building
- “templates/” contains the Twig view layer.
- “config/” has Symfony configuration, routing, bundles, security, environment-specific settings.
- “var/” holds runtime artifacts: sessions, file store, key-value JSON.

##### README for additional insights
- Confirms it’s an open-source, GDPR-compliant ERP/CRM for junior enterprises.
- Mentions features: member/customer management, project/document management, docx export.
- Deployable in 5 commands (leverages Docker).

##### Main components
a. Client: Web browser (React-free, standard HTML/CSS/JS)
b. Reverse proxy: Traefik (HTTPS, SSL, routing)
c. Web container: Nginx or Apache fronting PHP-FPM, serving Symfony
d. Application: Symfony PHP MVC
- Presentation layer: Twig templates & static assets
- Controllers: API/endpoints, form handling
- Services & Event Listeners: business rules (CommentManager, ChartManager, CsvImporter, etc.)
- Domain layer: Entities, Repositories (Doctrine ORM)
- Form layer: Symfony Form components
e. Persistence: MySQL database (Doctrine)
f. File storage:
- var/documents for .docx templates and generated files
- var/key_value_store JSON store (KeyValueStore service)
g. Mailer: Docker “mail” container (SMTP) used by SwiftMailer
h. External services: none hard-coded, but could integrate e-mail, third-party importers

##### Relationships and interactions
- Browser ↔ Traefik: HTTPS requests
- Traefik ↔ Web container: route to port 80
- Web container ↔ Symfony front controller → Controllers
- Controllers → Forms → Services → Repositories
- Services ↔ Database (via Doctrine)
- Services ↔ File system (documents, key‐value store)
- Services ↔ Mail container (SwiftMailer)
- EventListeners subscribe to domain events inside the app

##### Architectural patterns and design principles
- MVC (Presentation: Twig; Controllers; Model: Entities + Repositories)
- Dependency Injection via Symfony service container
- Layered architecture: Presentation, Application (Controllers + Forms), Domain (Entities, Business Services), Infrastructure (DB, file store, mailer)
- Modular service organization by bounded context (Comment, Project, Publish, Stat, KeyValueStore)
- Docker Compose for environment orchestration

##### Technologies, frameworks, and libraries
- Symfony 4/5 (Bundles, DI Container, HTTP Kernel)
- Doctrine ORM + Migrations + Fixtures
- Twig templating engine
- SwiftMailer for email
- Behat for acceptance tests
- Docker (Docker Compose, Traefik)
- MySQL
- PHPUnit/Behat for testing

##### Don’t overthink – decompose as much as possible
- Docker Compose containers individually
- Every external interaction: mailer, file I/O, database, browser

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients and edge
    Browser("Web Browser"):::client
    Browser -->|"HTTPS Request"| Traefik

    %% Infrastructure containers
    subgraph "Infrastructure" 
        direction TB
        Traefik["Traefik Reverse Proxy"]:::infra
        WebContainer["Web Container\n(Nginx + PHP-FPM)"]:::infra
        MySQL["MySQL Database"]:::storage
        Mailer["Mailer Service\n(SwiftMailer SMTP)"]:::infra
        Compose["Docker Compose Orchestration"]:::infra
    end

    Traefik -->|Route to port 80| WebContainer
    WebContainer -->|Doctrine SQL| MySQL
    WebContainer -->|SMTP| Mailer

    Compose --> Traefik
    Compose --> WebContainer
    Compose --> MySQL
    Compose --> Mailer

    %% Web container internal architecture
    subgraph "Web Container Internals" 
        direction TB
        FrontController["Front Controller\nindex.php"]:::app
        SymfonyKernel["Symfony Kernel"]:::app
        Controllers["Controllers"]:::app
        Forms["Forms"]:::app
        Services["Business Services"]:::app
        Repositories["Repositories"]:::app
        Entities["Entities"]:::app
        EventListeners["Event Listeners"]:::app
        Templates["Twig Templates"]:::app
        subgraph "Static Assets"
            direction TB
            CSS["CSS"]:::asset
            JS["JS"]:::asset
            IMG["Images"]:::asset
        end
        Config["Configuration"]:::config
        Migrations["Doctrine Migrations"]:::config
        KeyValueFS["Key-Value Store FS"]:::storage
        Documents["Document Storage\n(.docx files)"]:::storage
    end

    WebContainer --> FrontController
    FrontController --> SymfonyKernel
    SymfonyKernel --> Controllers
    Controllers --> Forms
    Forms --> Services
    Services --> Repositories
    Repositories --> MySQL
    Services --> Documents
    Services --> KeyValueFS
    Services --> Mailer
    SymfonyKernel -.-> EventListeners
    Controllers --> Templates
    Controllers --> CSS
    Controllers --> JS
    Controllers --> IMG
    SymfonyKernel --> Config
    SymfonyKernel --> Migrations

    %% Static asset flow
    CSS -->|"served"| Browser
    JS -->|"served"| Browser
    IMG -->|"served"| Browser

    %% Click Events
    click Traefik "https://github.com/n7consulting/incipio/tree/master/docker/traefik"
    click WebContainer "https://github.com/n7consulting/incipio/tree/master/docker/web/Dockerfile"
    click MySQL "https://github.com/n7consulting/incipio/tree/master/docker/mysql"
    click Mailer "https://github.com/n7consulting/incipio/tree/master/docker/mail/Dockerfile"
    click Compose "https://github.com/n7consulting/incipio/blob/master/docker-compose.yml.dist"
    click FrontController "https://github.com/n7consulting/incipio/blob/master/public/index.php"
    click CSS "https://github.com/n7consulting/incipio/tree/master/public/css"
    click JS "https://github.com/n7consulting/incipio/tree/master/public/js"
    click IMG "https://github.com/n7consulting/incipio/tree/master/public/img"
    click Controllers "https://github.com/n7consulting/incipio/tree/master/src/Controller/"
    click Templates "https://github.com/n7consulting/incipio/tree/master/templates/"
    click Entities "https://github.com/n7consulting/incipio/tree/master/src/Entity/"
    click Repositories "https://github.com/n7consulting/incipio/tree/master/src/Repository/"
    click Services "https://github.com/n7consulting/incipio/tree/master/src/Service/"
    click KeyValueFS "https://github.com/n7consulting/incipio/tree/master/var/key_value_store"
    click Documents "https://github.com/n7consulting/incipio/tree/master/var/documents"
    click EventListeners "https://github.com/n7consulting/incipio/tree/master/src/EventListener/"
    click Forms "https://github.com/n7consulting/incipio/tree/master/src/Form/"
    click Config "https://github.com/n7consulting/incipio/tree/master/config/"
    click Migrations "https://github.com/n7consulting/incipio/tree/master/src/Migrations/"

    %% Styles
    classDef client fill:#a2d2ff,stroke:#0066cc,color:#000;
    classDef infra fill:#99c2ff,stroke:#004080,color:#000;
    classDef app fill:#c2f0c2,stroke:#2d8a2d,color:#000;
    classDef storage fill:#fff2b2,stroke:#b38f00,color:#000;
    classDef asset fill:#ffd8cc,stroke:#cc3419,color:#000;
    classDef config fill:#e6ccff,stroke:#662e91,color:#000;
```
