Architecture Overview
The Concept Mapping Tool is built as a modern, real-time collaborative web application using React, InstantDB, and React Flow.
Technology Stack
- Frontend Framework: React 19 with TypeScript
- State Management: Zustand for UI state, InstantDB for data state
- Graph Rendering: React Flow
- Real-time Sync: InstantDB
- Styling: Tailwind CSS
- Build Tool: Vite
Architecture Principles
- Serverless: No backend server for application data; InstantDB handles all data persistence and sync.
- Real-time First: All data changes are synchronized instantly
- Component-Based: Modular React components with clear responsibilities
- Type-Safe: Full TypeScript coverage
- Permission-Based: Fine-grained access control via InstantDB permissions
System Architecture
┌─────────────────────────────────────────┐
│ React Application │
│ ┌─────────────┐ ┌──────────────┐ │
│ │ UI State │ │ Data State │ │
│ │ (Zustand) │ │ (InstantDB) │ │
│ └─────────────┘ └──────────────┘ │
│ │ │ │
│ └──────┬───────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ React Hooks │ │
│ │ db.useQuery() │ │
│ │ db.transact() │ │
│ └────────┬────────┘ │
└──────────────────┼─────────────────────┘
│
┌─────────▼─────────┐
│ InstantDB │
│ (Backend as a │
│ Service) │
└───────────────────┘
Key Concepts
- Maps: Top-level containers for concept maps
- Concepts: Nodes in the concept map
- Relationships: Edges connecting concepts
- Perspectives: Filtered views of maps
- Shares: Access control for maps
- Commands: Undoable operations using the Command pattern
Data Flow
- User interacts with UI component
- Component calls hook (e.g.,
useCanvasMutations) - Hook creates Command object and executes it
- Command uses
db.transact()to mutate InstantDB - Command is recorded in undo store for undo/redo
- InstantDB syncs changes to all connected clients
db.useQuery()hooks automatically update React components- UI reflects changes in real-time
Undo/Redo System
The application uses the Command pattern for comprehensive undo/redo functionality:
- Command Pattern: All mutations are encapsulated as Command objects with
execute()andreverse()methods - Operation Grouping: Related mutations are grouped into single undoable operations (e.g., entire drag sequences)
- Previous State Capture: Update commands capture previous state for accurate reversal
- Redo Support: Full redo functionality with keyboard shortcuts
See Undo/Redo System Guide for detailed documentation.