System Architecture
The F4E AppSheet system is built on a robust, trigger-driven architecture that ensures data consistency and automates complex business processes. This document provides a comprehensive overview of the system's technical architecture.
High-Level Architecture
Database Schema Overview
The system is built around 16 core tables that handle different aspects of kitchen operations:
Core Tables
| Table | Purpose | Key Relationships |
|---|---|---|
public.kitchen | Kitchen master data | Links to plan, projection |
public.school | School master data | Links to projection, school_bom |
meal_plan | Central meal planning | Links to plan |
plan | Kitchen-specific plans | Central table, links to all others |
projection | School-level projections | Links to plan, consumption |
consumption | Ingredient consumption | Links to projection, picking |
picking | Picking list management | Links to plan, consumption |
product_master | Product catalog | Links to consumption, picking |
ingredients | Recipe ingredients | Links to consumption |
school_bom | School BOM configuration | Links to school, ingredients |
Supporting Tables
| Table | Purpose | Key Relationships |
|---|---|---|
stock_adjustment | Inventory adjustments | Links to kitchen |
stock_count | Physical stock counts | Links to kitchen |
stock_summary | Inventory summaries | Links to kitchen |
plan_recipe_log | Recipe execution logs | Links to plan |
kitchen_mapping | Kitchen management | Links to kitchen |
meals | Meal catalog | Links to ingredients |
⚡ Trigger System Architecture
The system uses 11 critical trigger functions to maintain data consistency and automate business processes:
Plan Status Triggers
Projection Triggers
Data Sync Triggers
Data Flow Architecture
1. Meal Plan Creation Flow
2. Plan Status Change Flow
Database Design Principles
1. Normalization
- 3NF Compliance: All tables follow third normal form
- Referential Integrity: Foreign key constraints ensure data consistency
- Atomic Values: Each field contains a single, atomic value
2. Performance Optimization
- Strategic Indexing: Indexes on frequently queried columns
- Materialized Views: Pre-calculated aggregations for performance
- Trigger Optimization: Efficient trigger functions with cascade prevention
3. Data Integrity
- Audit Trails: All tables include
created_at,updated_at,created_by,updated_by - Status Validation: Business rules enforced through triggers
- Data Validation: Input validation at both application and database levels
Security Architecture
1. Access Control
- Role-Based Access: Different access levels for different user roles
- Data Partitioning: Users only see data relevant to their role
- Audit Logging: All changes tracked with user attribution
2. Data Protection
- Encryption: Sensitive data encrypted in transit and at rest
- Backup Strategy: Regular automated backups
- Recovery Procedures: Point-in-time recovery capabilities
Integration Architecture
1. External System Integration
2. Sync Processes
- Real-time Sync: Critical data synchronized immediately
- Batch Sync: Non-critical data synchronized in batches
- Conflict Resolution: Automated conflict resolution strategies
Scalability Considerations
1. Performance
- Database Optimization: Query optimization and indexing
- Caching Strategy: Materialized views for frequently accessed data
- Load Balancing: Distributed processing for high-volume operations
2. Growth
- Horizontal Scaling: Database partitioning strategies
- Vertical Scaling: Resource allocation optimization
- Monitoring: Performance monitoring and alerting
Technical Stack
| Component | Technology | Purpose |
|---|---|---|
| Mobile App | AppSheet | Cross-platform mobile application |
| Database | PostgreSQL 13+ | Primary data storage |
| Backend | AppSheet Platform | Business logic and API |
| Integration | Google Workspace | Authentication and collaboration |
| Monitoring | Built-in Analytics | Performance and usage tracking |
Deployment Architecture
1. Environment Strategy
- Development: Local development environment (Google sheets)
- Staging: Pre-production testing environment (Postgres DB)
- Production: Live system environment
2. Data Migration
- Version Control: Database schema versioning
- Migration Scripts: Automated database migrations
- Rollback Procedures: Safe rollback capabilities
This architecture ensures the F4E AppSheet system is robust, scalable, and maintainable while providing excellent performance for all user roles and business processes.