Farfalla
Farfalla is the core multi-tenant monolithic application that orchestrates the entire Publica.la platform. It powers both the Control Panel for our customers and the end-user storefront, managing tenant creation, catalog management, payment processing, and user access across the platform.
Why It Exists
Farfalla was the first project we implemented when we re-architected Publica.la's initial MVP to be multi-tenant. It serves as the central orchestration hub that allows publishers to configure their storefronts, upload publications, manage access rights, and enables end-users to sign up, subscribe, and access content—all under a scalable multi-tenant SaaS model. As the platform's foundational monolith, it coordinates interactions between all other services and maintains the core business logic that drives Publica.la.
Overview
Farfalla provides:
- Tenant provisioning and configuration
- Catalog and asset management for digital content
- Plan, coupon, and subscription management
- Integrated payment processing via multiple gateway providers
- User authentication, access control, and single sign-on
- Multi-tenant SaaS administration dashboard
- Observability, auditing, and activity logging
Stack and Tooling
| Layer | Technology |
|---|---|
| Backend | Laravel 10 (PHP 8.3) |
| Frontend - Storefront | Livewire + Alpine.js + Vue.js (legacy) + jQuery (legacy) |
| Customer's Control Panel | Livewire + Alpine.js + Vue.js (legacy) + jQuery (legacy) |
| Internal Control Panel | Laravel Nova 4 (with selective embedding in Customer's Control Panel) |
| Styling | Tailwind CSS |
| Data | SingleStore, Redis, S3 |
| Auth & Security | Socialite, JWT, SAML2, Geo-IP, CSP, and other integrations |
| Observability | Sentry, Clockwork, Telescope, Horizon |
| Testing | Pest, Faker, Larastan/PHPStan, Pint, php-cs-fixer |
| Dev Experience | Docker helpers (zex, zet, zar), GitLab CI, Laravel Vapor |
Architectural Highlights
- Multi-Tenant Context:
Tenantmodel is resolved from request domains via a service provider on every request. - Domain-Driven Design: New code follows domain-driven design patterns, with legacy parts of the codebase actively being migrated to this architecture.
- Caching & Performance: ResponseCache, Fast-Paginate, SQL commenter, and Spatie activity log keep the app fast and observable.
- Legacy Stack Migration: We have an ongoing migration from jQuery+Bootstrap+Vue2 to Livewire+Alpine+Tailwind.
Local Workflow (Docker)
zex composer install # Install PHP dependencies
zex yarn install # Install JS dependencies
zex php artisan migrate:fresh --seed
zex yarn dev | zex yarn watch # Live-reload assets
zet # Run all tests
Deployment Pipeline
- GitLab CI builds the image, runs tests and static analysis, and pushes artifacts.
vapor.production.yml/vapor.staging.ymldefine Laravel Vapor environments.production.Dockerfileandstaging.Dockerfileenable on-prem or staging containers.
Integration Capabilities
Farfalla integrates with numerous external services and internal platform components:
- Internal Services: Medusa (automated content publishing), Castoro (PDF processing), Fenice (multi-platform reading applications), Volpe (content reader/player)
- Payment Gateways: Stripe, MercadoPago, PayPal, and other payment providers
- Third-Party Services: Extensive integrations with various APIs for currency exchange, geolocation, analytics, and other business functions
Development
For detailed development information, API documentation, and implementation guides, refer to the additional documentation sections in this project area.