Backend Architecture Deep Dive β
The YAPPA Knowledge Hub backend is built with Symfony 7.2 and follows a strictly Layered Architecture to ensure a clean separation between external interfaces, business logic, and infrastructure.
Architecture Layers β
Backend Architecture Overview β
Last Updated: 2026-03-09 Version: 2.0 (Consolidated)
The Yappa Knowledge Hub backend is a Symfony-based application designed for high performance, bidirectional synchronization with Notion, and role-based AI summarization.
ποΈ The Dual-Storage Pattern β
The core architectural decision is our Dual-Storage approach. We combine the collaborative power of Notion with the speed and reliability of a local SQLite database.
- SQLite: Serves as a high-performance cache. All reads for the Slack Bot and API come from here.
- Notion: Serves as the master "UI" and persistent cloud storage. All collaborative editing and long-term storage happen here.
- Sync Engine: A specialized service layer that ensures consistency between both worlds.
π Project Structure β
The backend follows standard Symfony structure with domain-specific concentrations:
backend/
ββ migrations/ # Database schema history
ββ src/
β ββ Command/ # Maintenance & Sync CLI tools
β ββ Controller/ # HTTP Entry points
β ββ Entity/ # Doctrine models (Knowledge, Category, Role, etc.)
β ββ Repository/ # Database query logic
β ββ Service/ # Business logic (The "Braid")
β ββ AiSummary/ # AI Orchestration
β ββ Notion/ # Notion API & Mapping
β ββ Slack/ # Slack-specific logic
ββ tests/ # Unit & Functional test suitesμΈ΅ Layers of Responsibility β
We employ a strict layered architecture to ensure maintainability:
1. The Interface Layer (Controllers/Commands) β
Handles raw input from HTTP requests or the CLI. It validates the basic request structure but delegates all business logic to the services.
- Notable:
NotionSyncController,AiSummaryController.
2. The Service Layer (Domain Logic) β
The "Braid" where our unique logic lives. Services are stateless and orchestrate interactions between entities and external APIs.
- Notable:
AiSummaryService,NotionSyncService.
3. The Entity Layer (Data Model) β
Rich domain models that encapsulate their own state and internal validation.
- Notable:
Knowledge(The source item),AiSummary(The versioned output).
4. The Infrastructure Layer (Persistence/API) β
Handles communication with the "Outside World" (SQLite, OpenAI, Notion).
- Notable:
OpenAiClient,NotionClient.
π Core Lifecycles β
Knowledge Capture β
- Slack Bot receives message β Calls
KnowledgeService. KnowledgeServicepersists to SQLite β TriggersAiSummaryService.AiSummaryServicecalls GPT-4 β PersistsAiSummary.NotionSyncServicepushed the new item + summaries to Notion.
Periodic Digest β
- Scheduled task triggers
NotionDigestService. - Service aggregates recent
Knowledge+AiSummariesfor a specificRole. - Formats content for Notion and creates a "Digest Page".
Technical Context β
- Framework: Symfony 7.2
- Runtime: PHP 8.2
- ORM: Doctrine 3.x
- Database: SQLite 3
TIP
For a deep dive into how data is mapped between Notion and SQLite, see the Notion Integration Guide.