Skip to content

Latest commit

 

History

History
96 lines (80 loc) · 3.85 KB

README.md

File metadata and controls

96 lines (80 loc) · 3.85 KB

Rox architecture

Rox is the software behind BeWelcome, a hospitality exchange network run by volunteers. It is one Symfony 8.2 application (PHP 8.5) that renders HTML pages on the server with Twig, stores its data in MariaDB through Doctrine ORM, and uses a few small JavaScript bundles on top.

This folder describes how the application is built. How the containers, servers and cron jobs are set up is covered in the sysadmins-infra repository, not here.

Contents

Document What it covers
Code structure The layers in src/ and how they depend on each other
Request lifecycle What happens between an HTTP request and its response
Data model Database, entities, legacy tables shared with main, migrations
Security Login, members' rights as roles, voters, CSRF, signed mail links
Background jobs Console commands, notification queues, mails and browser push
Search and geography Manticore indices, geonames, spatial member search
Translations Texts in the database, catalogue cache, in-place translation
Front end Webpack Encore bundles, styles, maps, service worker
Quality and delivery Tests, static checks, CI and image builds

System context

flowchart LR
    member([Member / visitor<br/>browser or installed PWA])
    volunteer([Volunteer<br/>admin tools])

    subgraph rox [Rox]
        app[Symfony application]
    end

    db[(MariaDB)]
    manticore[(Manticore Search)]
    smtp[Mail server]
    push[Browser push services<br/>Mozilla, Google, Apple ...]
    geonames[geonames.org]
    plausible[Plausible analytics]
    paypal[PayPal]
    cron[[Scheduler<br/>sysadmins-infra]]

    member -- HTTPS --> app
    volunteer -- HTTPS --> app
    app -- Doctrine / PDO --> db
    app -- forum and place search --> manticore
    app -- Symfony Mailer --> smtp
    app -- Web Push, VAPID --> push
    push -. notification .-> member
    app -- daily and full dumps --> geonames
    member -. page events .-> plausible
    paypal -- IPN --> app
    cron -- "bin/console ..." --> app
Loading

Runtime building blocks

flowchart TB
    subgraph web [Web]
        nginx[Nginx<br/>serves public/]
        fpm[PHP-FPM<br/>public/index.php]
    end

    subgraph php [Symfony kernel]
        http[HTTP: controllers, forms, Twig]
        cli[CLI: bin/console commands]
        shared[Models, services, repositories, entities]
        http --> shared
        cli --> shared
    end

    subgraph state [State]
        db[(MariaDB<br/>data, sessions, remember-me tokens,<br/>translations, notification queues)]
        files[(Filesystem<br/>data/, upload/, var/cache)]
        manticore[(Manticore<br/>forum_rt, geonames indices)]
    end

    nginx --> fpm --> http
    shared --> db
    shared --> files
    shared --> manticore
Loading

Things to know before reading further:

  • One application, two entry points. Web requests go through public/index.php; scheduled work runs as bin/console commands. Both use the same services and entities.
  • No message queue. Asynchronous work is stored in database tables (notification queues, mass mail, trip notifications) and processed in batches by commands that the scheduler calls. Browser push for a single action is sent right after the response, on kernel.terminate.
  • The database is shared with main during the transition. main is the code currently running in production; develop (this code base) adds its own tables next to main's and copies the data in migrations. See Data model.
  • Translations live in the database, not in files. See Translations.