Mission-critical, high-concurrency School Food Logistics, Waste Prevention, and Academic Cafeteria ERP.
Engineered for private school networks and enterprise education hubs with rigorous LGPD compliance.
In enterprise educational environments, thousands of students enter the cafeteria during synchronized 20-minute break windows. Traditional web systems collapse under the sudden surge of concurrent traffic or suffer data corruption from concurrent file access. Concurrently, kitchen managers face critical operational bottlenecks:
- Catastrophic Concurrency Spikes: Turnstile counters, teachers taking attendance, kitchen displays, and interactive public displays hammering the API simultaneously.
- Clinical Dietary Restrictions & LGPD Compliance: Managing life-critical allergies and religious restrictions without exposing underage student identities or medical records.
- Menu Breakdown & Nutritional Waste Management: Decomposing multi-component dishes into individual nutritional items, tracking edible leftovers vs. plate scrapings, and deriving predictive purchasing insights.
- Approval Bottlenecks: Real-time counter-turn requests requiring immediate sign-off by academic coordinators.
SESI Alimenta solves this with an architectural defense-in-depth model, sub-millisecond SQLite WAL data pipelining, and automated nutritional analytics.
- WAL (Write-Ahead Logging) Mode: Multiple parallel readers do not block writers. Readers query snapshots while write locks complete in microsecond bursts.
- Busy Timeout (5,000ms): Thread queuing eliminates
SQLITE_BUSYcontention errors during school interval rushes. - Synchronous = NORMAL & B-Tree Indexes: Dedicated B-Tree indexes on
calendario(data),presenca_geral(data),auditoria_lixo(data),aluno_turmas(turma_id)eliminate full table scans.
-
Hierarchical Dish Separation: Clean decomposition between morning snack (
LM), formal lunch (A), and afternoon snack (LT). Enforces structural separation rules (e.g. lunch never contains beverages; side dishes are strictly bound to lunch). -
Predictive BI Analytics: Real-time computation of per-capita plate waste (attention threshold
$\le 25\text{g}$ , critical$\ge 45\text{g}$ ), clean pan leftovers, and multi-category historical acceptance series. - Teacher Feedback Hub: Anonymized teacher review aggregates and bidirectional synchronization.
- JWT & Mandatory TOTP 2FA: Cryptographically signed session tokens combined with RFC 6238 TOTP authentication and backup recovery codes.
- Strict Role-Based Access Control (RBAC): Hierarchical permissions isolating
admin,cozinha,professor, andcoordenacaoscopes. - Cryptographic Device Trust: Short-lived HMAC signed tokens protecting remembered workstation instances.
- Asynchronous Silent Audit Trail: Global middleware tapping
res.on('finish')to log mutation events asynchronously with automatic masking of sensitive keys (token,senha,preAuthToken,two_factor_secret). - Zero Insecure Fallbacks: Fail-fast boot sequence requiring 32+ character entropy for secrets.
- Sentinel Reverse Proxy: Single entry point (:3000) with TCP socket tunneling, health checks, and process lifecycle supervision.
- Zero-Drift WebSockets: Heartbeat ping/pong (15s interval) with real-time UI synchronization for kitchen displays and attendance boards.
- Intelligent Maintenance Mode: Centralized 503 maintenance page with auto-polling and authorized IP bypass.
- Production deployment via
node-windowsruns the application as a native Windows Background Service with auto-recovery and crash resilience.
flowchart TD
subgraph ClientLayer["Frontend Client (React 19 + Vite + TailwindCSS)"]
UI["Web Interface (Teacher, Kitchen, Admin, Coordination, TV Totem)"]
RT["useLiveClock & useRealtime (Zero-Drift WebSockets)"]
end
subgraph GatewayLayer["Sentinel Gateway & Reverse Proxy (:3000)"]
GW["HTTP Reverse Proxy & TCP Tunneling"]
SP["Process Supervisor & Auto-Restart"]
MO["Intelligent Maintenance Mode Guard"]
end
subgraph MiddlewareLayer["Defense-in-Depth Middleware Pipeline"]
HL["Helmet Security Headers"]
RL["Per-Machine Adaptive Rate Limiter"]
AUTH["JWT Validation & TOTP 2FA Verification"]
RBAC["Strict Role-Based Access Control"]
AUDIT["Async Audit Trail (res.on 'finish' + Masking)"]
end
subgraph ServiceLayer["Core Domain Services (:3001)"]
NUTR["Nutrition & Menu Decomposition Service"]
BI["Multidimensional BI Analytics Engine"]
MEAL["Meal Dispatching & Counter Flow Controller"]
CLASS["Academic Class Scheduling & Special Diets"]
end
subgraph DataLayer["Persistence & Storage Layer"]
ORM["Drizzle ORM Engine"]
SQLITE["SQLite Database (WAL Mode + B-Tree Indexes)"]
BACKUP["Automated Monthly Backup Retention Engine"]
end
UI -->|HTTP / REST| GW
RT -->|WebSocket WSS| GW
GW --> SP
SP --> MO
MO --> HL
HL --> RL
RL --> AUTH
AUTH --> RBAC
RBAC --> AUDIT
AUDIT --> NUTR
AUDIT --> BI
AUDIT --> MEAL
AUDIT --> CLASS
NUTR --> ORM
BI --> ORM
MEAL --> ORM
CLASS --> ORM
ORM --> SQLITE
SQLITE -.->|VACUUM INTO| BACKUP
| Institutional Login | 2FA TOTP Authentication |
|---|---|
| Adaptive auth portal with consent terms & public dashboard access | Mandatory RFC 6238 TOTP verification with hardware trust tokens |
![]() |
![]() |
| Kitchen Production Board | Menu Planning & Decomposition |
|---|---|
| Real-time batch dispatching, attendance tracking & allergy alerts | Calendar-based menu scheduling with nutritional separation rules |
![]() |
![]() |
Multidimensional BI Analytics & Waste Auditing
Real-time plate waste analysis (kg), pan leftovers, and historical menu approval trends
- Node.js:
20.xor22.xLTS - npm:
v10+
git clone https://github.com/marcosbinder/SESI-Alimenta.git
cd SESI-Alimenta
# Copy environment configuration template
cp .env.example .envEdit .env and provide a secure 64-character secret:
# Generate key in terminal:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"# Install backend dependencies
npm install
# Build frontend application
cd site
npm install
npm run build
cd ..# Synchronize SQLite schema and provision initial administrator
node src/scripts/inicializador.js
# Seed default school grade classes and B-Tree indexes
node src/scripts/seedTurmas.js
node src/scripts/criaIndices.jsnpm test# Start Gateway Sentinel and supervised backend
npm startThe application will be accessible at http://localhost:3000.
The project includes an automated test matrix covering security, cryptographic invariants, backend integrations, and frontend resilience:
npm testtests/test_security.mjs: Tests payload size limits, exception leakage prevention, bcrypt configuration, cookie security flags, and LGPD anonymization.tests/test_backend_api.mjs: Validates 2FA cryptographic signatures, session revocation, database constraints, password hashing, and HTML escaping.tests/test_frontend_integrity.mjs: Tests BI analytical transformations, zero-division guards, typography consistency, and chart caching.tests/test_challenger_m1_1.mjs&stress.mjs: Adversarial stress tests with dirty inputs, NaN resilience, and 10,000+ simulated concurrency records.
This project is open-source under the GNU Affero General Public License v3.0 (GNU AGPLv3).
Copyright (c) 2026 Marcos Binder.
Under the AGPLv3, any modified version or derivative work deployed as a network service or cloud instance must provide its complete source code to the community under the same license terms. Proprietary or closed-source redistribution is strictly prohibited.



