How praveenyt872/labflow-ai works
Purpose and Entry Points
This is a Vite React single-page application for engineering-lab experiment workflows: students select a subject and experiment, enter/inspect observations, calculate formulas, visualize results, and receive AI-assisted validation. It also includes teacher authentication and access-code administration.
Browser startup is src/main.jsx, which mounts src/App.jsx. Primary page-level navigation is represented by src/pages/LandingPage.jsx, src/pages/SubjectSelectPage.jsx, src/pages/ExperimentSelectPage.jsx, and src/pages/WorkspacePage.jsx.
Client Application State and Access Control
Global client state is split between authentication and active experiment/workspace state:
• src/store/authStore.js
• src/store/experimentStore.js
The authentication UI supports role selection, Google sign-in, student gating, teacher login, and teacher dashboard flows through src/components/auth/RoleSelector.jsx, src/components/auth/GoogleSignIn.jsx, and src/components/auth/TeacherDashboard.jsx. Workspace access is therefore a boundary between public experiment discovery and authenticated/student-authorized use.
Experiment Definition Pipeline
Experiments are data-driven JSON definitions under src/data/experiments/, including src/data/experiments/venturi.json, src/data/experiments/rtd_cstr.json, and src/data/experiments/process_control_first_order.json. Subject grouping is supplied by src/data/subjects.js.
Selected definitions feed the workspace rather than requiring a separate implementation per experiment. This makes experiment schema/content a central extensibility boundary: adding an experiment likely requires data and associated formulas/assets rather than new routing architecture.
Calculation, Validation, and AI Boundary
The client-side computation layer is concentrated in:
• src/engine/formulaEngine.js
• src/engine/validationEngine.js
• src/engine/aiService.js
formulaEngine derives engineering results from observations and experiment definitions; validationEngine evaluates inputs/results and supports detailed feedback. aiService is an external/remote-service boundary consumed by workspace AI components, notably src/components/workspace/AIChatWidget.jsx and src/components/workspace/AIValidationPanel.jsx. Offline-aware UI exists in src/components/pwa/OfflineAIMessage.jsx, implying AI functionality may degrade independently from local calculations.
Workspace Presentation and Results Flow
src/pages/WorkspacePage.jsx assembles the active lab workflow. Data moves from observation/input interfaces into calculated, validated, tabular, graphical, and interpretive outputs:
• Inputs/tables: src/components/workspace/ObservationTable.jsx, src/components/workspace/StandardizationTables.jsx
• Derived results: src/components/workspace/LiveResultsPanel.jsx, src/components/workspace/SampleCalculationPanel.jsx
• Visualization: src/components/workspace/GraphPanel.jsx, src/components/graph/MatlabStyledPlot.jsx
• Student narrative: src/components/workspace/StudentInterpretationPanel.jsx
Supporting modals provide derivations, validation details, code reference, reports, onboarding, and reset confirmation under src/components/modals/.
Backend and External Services
A Node server provides authorization/access-code APIs through server/index.js, database initialization/access in server/db.js, and route modules server/routes/auth.js, server/routes/accessCode.js, server/routes/teacherAuth.js, and server/routes/verifyCode.js. A serverless teacher status endpoint also exists at api/teacher/check-status.js.
Supabase is a material external service: browser integration is src/utils/supabaseClient.js, while provisioning/schema setup is scripts/supabase_setup.sql. The architecture therefore separates browser-facing Supabase access from server-owned teacher/access-code route handling.
Offline, Persistence, and Deployment Shape
The frontend is PWA-oriented, with manifest/static deployment assets in public/manifest.json and public/.nojekyll, plus installation/connectivity components in src/components/pwa/InstallBanner.jsx and src/components/pwa/OfflineBadge.jsx. Local persistence is handled through src/utils/indexedDbStore.js, allowing workspace-related data to survive browser sessions or connectivity loss.
The repository combines a Vite-built static React client (vite.config.js) with a Node API server and an api/ serverless-compatible endpoint, so deployment must provide both static hosting and runtime support for backend/auth routes.
Main entry points: LandingPage.jsx Lab navigation · RoleSelector.jsx Auth and teacher UI · WorkspacePage.jsx Lab workspace · formulaEngine.js Formula engine
Components 22
React client
- Browser startup
src/main.jsx - Application shell
src/App.jsx - Lab navigation · Landing, subject selection, experiment selection, and workspace pages.
src/pages/LandingPage.jsx - Authentication state
src/store/authStore.js - Auth and teacher UI · Role selection, Google sign-in, and teacher dashboard flows.
src/components/auth/RoleSelector.jsx
Lab workspace
- Active experiment state
src/store/experimentStore.js - Lab workspace · Assembles the active experiment workflow.
src/pages/WorkspacePage.jsx - Observation tables · Observation and standardization input tables.
src/components/workspace/ObservationTable.jsx - Results and interpretation · Live results, sample calculations, and student interpretation.
src/components/workspace/LiveResultsPanel.jsx - Engineering graphs · Workspace graph panel and MATLAB-styled plot.
src/components/workspace/GraphPanel.jsx - AI assistance UI · Chat, validation feedback, and offline AI messaging.
src/components/workspace/AIChatWidget.jsx - Formula engine
src/engine/formulaEngine.js - Validation engine
src/engine/validationEngine.js
Backend services
- Remote AI service
src/engine/aiService.js - Node API server · Owns authorization and access-code APIs.
server/index.js - Auth and access routes · Authentication, teacher login, code creation, and code verification.
server/routes/auth.js - Server database access
server/db.js - Teacher status endpoint
api/teacher/check-status.js
Data and persistence
- Experiment definitions · Data-driven experiment schemas and content.
- Subject catalog
src/data/subjects.js - Offline local storage
src/utils/indexedDbStore.js - Supabase browser client
src/utils/supabaseClient.js
Connections 24
- Browser startup → Application shell: mounts
- Application shell → Lab navigation: renders
- Lab navigation → Subject catalog: lists
- Lab navigation → Experiment definitions: selects
- Lab navigation → Auth and teacher UI: gates access
- Auth and teacher UI → Authentication state: updates
- Auth and teacher UI → Node API server: auth and codes
- Auth and teacher UI → Teacher status endpoint: checks status
- Lab navigation → Active experiment state: sets selection
- Active experiment state → Lab workspace: drives
- Experiment definitions → Lab workspace: configures
- Lab workspace → Observation tables: collects inputs
- Observation tables → Formula engine: observations
- Experiment definitions → Formula engine: formulas and schema
- Formula engine → Validation engine: derived results
- Formula engine → Results and interpretation: calculations
- Validation engine → Results and interpretation: feedback
- Formula engine → Engineering graphs: plot data
- Lab workspace → AI assistance UI: hosts
- AI assistance UI → Remote AI service: AI requests
- Lab workspace → Offline local storage: persists work
- Node API server → Auth and access routes: serves
- Auth and access routes → Server database access: reads and writes
- Auth and teacher UI → Supabase browser client: browser integration