Danvas
Danvas
DashboardSupportWelcome

👤 USER DOCS

User Guides

Getting Started

Getting StartedDashboard & OnboardingApp Settings

Tutorials

Tutorial: Setting Up Shift Tasks & ClosersTutorial: Managing Incidents in the InboxTutorial: Tracking Compliance & Sync StatusTutorial: Operational Workflows with the AI AssistantTutorial: Building & Deploying Custom Checklists

Daily Operations (Staff)

Shift Workspace & TasksService Day SetupDaily Line-UpStaff Service Day ReportsForms

Communication & Chat

Messages & AnnouncementsUnified Operations InboxAI Assistant

Manager & Admin Guides

Daily Line-Up SetupStaff SchedulingManaging LocationsNPS and Guest FeedbackCouponsContacts and Guest HistoryManager CloseoutsDaily Line-Up & ComplianceAnalyticsIncident ReportingWhistleblower Concerns & FeedbackAdmin Tools

⚙️ DEVELOPER DOCS

Getting Started

Getting StartedDevelopmentDeployment Guide

Architecture

Architecture OverviewExplanation: AI Integration & Tenant SecurityExplanation: Dynamic Forms Engine DesignExplanation: Compliance Ledger DesignExplanation: Live Sync & Data FreshnessData FlowArchitecture Decision Records

Core Domain

Core DomainDatabase ReferenceLocations DomainAuth & RBACScheduling DomainReports DomainIncidents DomainUnified Operations InboxLive Sync Data FreshnessToast Sync PipelineNotifications DomainCoupons and Guest NPSAudit Log & Compliance ArchitectureDesign Audit FindingsAI Chat IntegrationAnalytics & Tips Integration

Frontend

Frontend ArchitectureFormsLoading SkeletonsComponentsPWA & Offline ShellScreenshots

API Reference

API Reference

Endpoints

POS Sales APIOptimization Data APISchedule Shifts APIEmployee Export APIReports APIIncidents APIAI Chat APIPush Notifications APIWebhooks APICron API

Contributing

ContributingCode Examples

Security

Security & Compliance

Release Notes

What's New

Explanation: Live Sync & Data Freshness

Deep dive into the Toast POS / 7shifts sync pipeline, FastAPI bridging, and cacheLife performance optimizations

This document explains the technical architecture of the Danvas external synchronization pipeline, including Dagster orchestration, Next.js 16 caching layers, and the circuit-breaker status engine.


The Synchronization Pipeline

Danvas synchronizes data from Toast POS (sales, clock-ins, orders, discounts) and 7shifts (scheduling, employees, roles). Integration runs are orchestrated by Dagster assets and background data-sync packages (@repo/data-sync, @repo/toast):

┌────────────────┐      Partition-native extraction       ┌───────────────────┐
│ Toast / 7shifts├───────────────────────────────────────►│ Dagster Pipelines │
└────────────────┘                                        └─────────┬─────────┘
                                                                    │ Writes to DB
                                                                    ▼
┌────────────────┐          Reads (cacheLife)             ┌───────────────────┐
│ apps/app (RSC) ◄────────────────────────────────────────┤ Neon Database     │
└────────────────┘                                        └───────────────────┘

Ingestion & Active Writers

Orchestration is owned by Dagster assets (dagster/canvas_forge/) and database-backed sync packages:

  1. Adapter Layer: @repo/toast/client and @repo/sevenshifts handle connection pools, retries, and token management.
  2. Staging & Marts: Assets extract raw data into PostgreSQL staging tables (stg_toast_*) and transform them into analytics.f_* marts.
  3. State Tracking: Every execution updates high-watermark timestamps and circuit-breaker states in the sync_state table.

Next.js 16 cacheLife Optimization

The authenticated app uses Next.js 16 Cache Components for bounded live reads:

  • Dashboard and monitoring caches: getCachedDashboardSummary() and getCachedMonitoringSummary() use the custom live profile. The profile allows a 30-second client stale window, revalidates server results every 30 seconds, and expires entries after 60 seconds.
  • Tag-based invalidation: Dashboard mutations invalidate dashboardSummaryTag(...) with updateTag() for read-your-own-writes. Shift-task and location mutations invalidate their team-scoped tags with revalidateTag(..., "max").
  • Dynamic holes: These live reads remain request-time streamed content; their short expiration intentionally keeps them out of the static App Shell.

The client still performs non-blocking refreshes for status indicators. Cache invalidation and freshness are separate concerns: invalidation removes known stale entries, while the live profile bounds freshness when no mutation signal is available.


Circuit-Breaker Status Engine

To prevent cascading failures and continuous hammering when third-party APIs experience outages:

  • The sync manager tracks sequential execution failures in sync_state.
  • If a sync source fails 3 times consecutively, the circuit opens, marking the source as disabled and triggering an alert.
  • While the circuit is open, subsequent reads serve cached local marts directly, preventing UI requests from blocking.
  • The circuit breaker transitions to half_open after a 5-minute cooldown period to attempt a recovery sync.

Explanation: Compliance Ledger Design

Architectural explanation of the decoupled compliance ledger, service week boundaries, and dual filing obligations

Data Flow

How data moves through Danvas

On this page

The Synchronization PipelineIngestion & Active WritersNext.js 16 cacheLife OptimizationCircuit-Breaker Status Engine