We value your privacy

We use cookies and analytics tools to improve your experience.

Privacy Policy · GDPR

InsightPro - System Architecture

Complete technical documentation of the refactored system

Data Flow Architecture
Single Source of Truth (SSOT) implementation with centralized state management

Core Principle: SSOT in RequestInsights

The RequestInsights page maintains the single source of truth (projectData state) throughout the entire multi-step creation process. All child components receive this data as props and update it through callbacks.

Step 1: User Input

User interacts with step components (QuickStep1_Materials, etc.)

Step 2: Local State Collection

Component collects all form data in local state, validates it

Step 3: Submit to Hook

Component calls onNext(stepData) which triggers useProjectFormSteps.handleStepComplete()

Step 4: Backend Persistence

Hook calls saveProjectStep() function to persist data in database

Step 5: State Update

Backend returns complete project object, hook updates projectData state via setProjectData()

Step 6: Navigation

Hook advances to next step, new component receives updated projectData

Custom Hook: useProjectFormSteps
Centralized logic for multi-step form management

Location: components/request/hooks/useProjectFormSteps.js

Responsibilities:
  • Manage current step state
  • Handle backend communication via saveProjectStep()
  • Update projectData state after successful saves
  • Manage loading and error states
  • Provide navigation between steps
  • Prevent duplicate project creation
Key Features:
  • Auto-save: Every step completion saves to database
  • Resume capability: Users can leave and return without losing progress
  • URL synchronization: Project ID in URL updates automatically
  • Error recovery: Failed saves can be retried without data loss
Backend Functions
Serverless functions handling business logic
saveProjectStep
Core Function

Handles project creation and updates with step-by-step validation

POST /functions/saveProjectStep

Body: { projectId?, stepNumber, stepData }

Features:

  • Step-specific validation logic
  • Automatic create vs update detection
  • Permission checking for organizations
  • current_step tracking for resume capability
signNDA
Expert Function

Handles NDA signature with legal binding and audit trail

POST /functions/signNDA

Body: { projectId, fullName, ndaType }

Security Features:

  • IP address tracking
  • User agent logging
  • Timestamp with timezone
  • Duplicate signature prevention
submitFeedback
Expert Function

Processes expert feedback submission with validation

POST /functions/submitFeedback

Body: { projectId, feedbackData }

Validation:

  • NDA signature verification
  • Required comments checking
  • Survey response validation
  • Automatic project status updates
Expert Workflow: Zero Page Reloads
Seamless state transitions without browser refreshes
State Machine Pattern

The expert workflow uses a finite state machine with these states:

• LOADING → Fetching initial data

• INITIAL_LANDING → Not authenticated

• ACCEPT_PENDING → Needs to accept project

• NDA_PENDING → Needs to sign NDA

• FEEDBACK_PENDING → Ready to submit feedback

• FEEDBACK_SUBMITTED → Complete

State Transition Flow
  1. User performs action (accept, sign NDA, submit feedback)
  2. Backend function processes action and updates database
  3. Success callback triggers initializeWorkflow()
  4. initializeWorkflow() re-evaluates state based on fresh data
  5. Component re-renders with new state - NO RELOAD
Component Architecture
Organized component structure with clear separation of concerns
Shared Components

• components/request/shared/NdaStep.js

• components/request/shared/SessionSetupStep.js

→ Reused across both Quick & In-Depth paths

Path-Specific Components

Quick Path:

• components/request/quick/QuickStep1_Materials.js

• components/request/quick/QuickStep4_Payment.js

• components/request/quick/QuickStep5_ExpertSelection.js

Prototype Path:

• components/request/prototype/PrototypeStep1_Materials.js

• components/request/prototype/PrototypeStep4_Payment.js

• components/request/prototype/PrototypeStep5_ExpertSelection.js

Expert Workflow Components

• components/expert/workflow/ExpertProgressTracker.js

• components/expert/workflow/ProjectDetailsCard.js

• components/expert/workflow/ExpertAcceptanceFlow.js

• components/expert/workflow/ExpertFeedbackSubmission.js

Key Improvements from Refactor
✅ Before Issues
  • • Duplicate project creation
  • • Data inconsistencies
  • • Lost progress on refresh
  • • window.location.reload() everywhere
  • • No validation consistency
✨ After Solutions
  • • Single source of truth
  • • Centralized state management
  • • Auto-save with resume
  • • Zero page reloads
  • • Backend validation layer
Testing Checklist
Critical paths to test before production deployment
Creator Flow
Expert Flow
Edge Cases