How retailguardaiproject-blip/retailguardai works
RetailGuard AI is a dashboard for turning inventory-anomaly analysis into human-reviewable cases. The documented end-to-end flow is an external n8n pipeline that fetches and analyzes inventory, then pushes a summary to the app’s authenticated receiver; the dashboard retrieves summaries and presents KPIs, investigation details, filters, and case/map views. The graph preserves those documented capabilities, but several UI and server modules were not sampled, so their internal connections are shown only where supported or omitted. The README documents the n8n and database behavior; n8n workflow implementation is outside this repository.
Main entry points: useDashboardData.ts Dashboard data hook · receive-summary.ts Webhook receiver · index.tsx KPI overview · client.server.ts Server database client
Components 23
Analysis pipeline
- Fetch inventory
- Validate and analyze
- AI explanations
- Summary sender
Summary backend
- Webhook receiver
src/routes/api/public/receive-summary.ts - Case validation rules
src/lib/case-rules.ts - Latest summary API
src/routes/api/public/latest-summary.ts - Summary access
src/lib/summary-api.ts
Data and access
- Summary table
drizzle/schema.ts - Server database client
src/integrations/supabase/client.server.ts - Browser Supabase client
src/integrations/supabase/client.ts - Session state
src/hooks/useConnection.ts
Dashboard experience
- Dashboard data hook
src/hooks/useDashboardData.ts - Summary panel
src/components/LatestSummary.tsx - KPI overview
src/routes/index.tsx - Application shell
src/components/AppShell.tsx - Global filters
src/lib/filters.tsx
Case investigation
- Case explorer
src/routes/cases.tsx - Store map
src/components/StoreMap.tsx - Workspace settings
src/components/WorkspacePreferences.tsx - Administration
src/routes/admin.tsx
Other components
- Dashboard user
- Inventory source
Connections 22
- Inventory source → Fetch inventory: provides stock data
- Fetch inventory → Validate and analyze: passes records
- Validate and analyze → AI explanations: flags anomalies
- AI explanations → Summary sender: packages summary
- Summary sender → Webhook receiver: POSTs payload
- Webhook receiver → Case validation rules: validates cases
src/routes/api/public/receive-summary.ts - Webhook receiver → Server database client: writes summary
src/routes/api/public/receive-summary.ts - Server database client → Summary table: stores payload
- Latest summary API → Summary access: retrieves summary
src/routes/api/public/latest-summary.ts - Summary access → Server database client: reads summary
- Dashboard user → Application shell: uses dashboard
- Application shell → KPI overview: hosts overview
- KPI overview → Dashboard data hook: loads KPIs
src/routes/index.tsx - KPI overview → Summary panel: renders summary
src/routes/index.tsx - Dashboard data hook → Latest summary API: requests latest data
- Dashboard data hook → Session state: checks session
src/hooks/useDashboardData.ts - Session state → Browser Supabase client: reads auth state
src/hooks/useConnection.ts - Summary panel → Dashboard data hook: uses summary data
src/components/LatestSummary.tsx - Dashboard user → Case explorer: investigates cases
- Case explorer → Store map: shows store locations
- Dashboard user → Workspace settings: configures workspace
- Dashboard user → Administration: manages access