No description
Find a file
Jan-Henrik Bruhn 28f8224284 feat: add timeline system for multi-state constellation analysis
Implements a comprehensive timeline system that enables documents to contain
multiple constellation states with branching timelines. This allows users to
create different versions of their analysis for temporal evolution, alternative
scenarios, or what-if analysis.

Core Features:
- Timeline store managing multiple states per document with branching structure
- Visual timeline panel with React Flow-based state graph visualization
- State management: create, switch, rename, duplicate (parallel/series), delete
- Per-state undo/redo history (max 50 actions per state)
- Context menu for timeline node operations
- Collapsible timeline panel (always visible, moved toolbar to panel header)

Architecture Changes:
- Document structure: removed top-level graph field, states now only in timeline
- Global types: nodeTypes and edgeTypes are now global per document, not per state
- State graphs: only contain nodes and edges, types inherited from document
- Persistence: full timeline serialization/deserialization with all states
- History system: converted from document-level to per-state independent stacks

Timeline Components:
- TimelineView: main timeline visualization with state nodes and edges
- BottomPanel: collapsible container with timeline controls in header
- StateNode: custom node component showing state info and active indicator
- CreateStateDialog: dialog for creating new timeline states
- RenameStateDialog: dialog for renaming existing states
- Context menu: right-click operations (rename, duplicate parallel/series, delete)

Document Management:
- Documents always have timeline (initialized with root state on creation)
- Timeline persisted with document in localStorage
- Export/import includes complete timeline with all states
- Migration support for legacy single-state documents

Store Updates:
- timelineStore: manages timelines, states, and timeline operations
- historyStore: per-state history with independent undo/redo stacks
- workspaceStore: saves/loads timeline data, handles global types
- panelStore: added timeline panel visibility state
- useActiveDocument: syncs timeline state with graph editor

Context Menu Improvements:
- Smart viewport edge detection to prevent overflow
- Click-outside detection for React Flow panes
- Consistent styling across application

Files Added:
- src/types/timeline.ts - Timeline type definitions
- src/stores/timelineStore.ts - Timeline state management
- src/components/Timeline/TimelineView.tsx - Main timeline component
- src/components/Timeline/BottomPanel.tsx - Timeline panel container
- src/components/Timeline/StateNode.tsx - State node visualization
- src/components/Timeline/CreateStateDialog.tsx - State creation dialog
- src/components/Timeline/RenameStateDialog.tsx - State rename dialog

Files Removed:
- src/stores/persistence/middleware.ts - Obsolete persistence middleware

Documentation:
- Added comprehensive timeline feature documentation
- Implementation checklists and quick reference guides
- Temporal analysis concepts and UX guidelines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-11 22:00:34 +02:00
.claude/agents Initial commit 2025-10-10 11:15:51 +02:00
.github/workflows feat: add github action to deploy to github pages 2025-10-10 11:27:51 +02:00
docs feat: add document naming dialog before creation 2025-10-11 12:03:05 +02:00
public Initial commit 2025-10-10 11:15:51 +02:00
src feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
.dockerignore Initial commit 2025-10-10 11:15:51 +02:00
.eslintrc.cjs Initial commit 2025-10-10 11:15:51 +02:00
.gitignore Initial commit 2025-10-10 11:15:51 +02:00
CLAUDE.md Initial commit 2025-10-10 11:15:51 +02:00
Dockerfile Initial commit 2025-10-10 11:15:51 +02:00
IMPLEMENTATION_CHECKLIST.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
index.html fix: change folder location base path for imports to deploy 2025-10-10 12:02:09 +02:00
LICENSE.md Add license 2025-10-10 11:24:47 +02:00
package-lock.json feat: add crispy PNG/SVG graph export with tight cropping 🔥 2025-10-10 23:01:33 +02:00
package.json feat: add crispy PNG/SVG graph export with tight cropping 🔥 2025-10-10 23:01:33 +02:00
postcss.config.js Initial commit 2025-10-10 11:15:51 +02:00
QUICK_REFERENCE.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
QUICKSTART.md Initial commit 2025-10-10 11:15:51 +02:00
README.md Add vibe warning 2025-10-10 11:23:36 +02:00
tailwind.config.js feat: add toast notification system for visual feedback 2025-10-10 23:13:28 +02:00
TEMPORAL_ANALYSIS_SUMMARY.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
TEMPORAL_QUICK_START.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
TEMPORAL_SCENARIO_IMPLEMENTATION_PLAN.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
TEMPORAL_SCENARIO_UX_CONCEPT.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
tsconfig.json Initial commit 2025-10-10 11:15:51 +02:00
tsconfig.node.json Initial commit 2025-10-10 11:15:51 +02:00
UX_CONCEPT_MULTI_VERSION_GRAPH.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
VISUAL_EXAMPLES.md feat: add timeline system for multi-state constellation analysis 2025-10-11 22:00:34 +02:00
vite.config.ts fix: change folder location base path for imports to deploy 2025-10-10 12:02:09 +02:00

Constellation Analyzer

A React-based visual editor for creating and analyzing Constellation Analyses. Build interactive graphs to examine actors (nodes) and their relationships (edges) with a powerful drag-and-drop interface.

Vibe-Warning

This is a testing ground for Agent Based LLM Coding. It presently does not contain hand-written code. Hence, please take the whole code-base with a grain of salt.

Features

  • Interactive Graph Visualization: Built on React Flow for smooth, performant graph editing
  • Customizable Node Types: Define and configure multiple actor types with distinct visual properties
  • Flexible Edge Types: Create various relationship categories with different styles and colors
  • Drag-and-Drop Interface: Intuitive node manipulation and edge creation
  • Real-time Updates: Instant visual feedback as you build your constellation
  • Type-Safe: Full TypeScript support for robust development
  • State Management: Zustand for lightweight, efficient state handling
  • Responsive Design: Tailwind CSS for modern, adaptive UI

Technology Stack

  • React 18.2 - UI framework
  • TypeScript 5.2 - Type safety
  • Vite 5.1 - Build tool and dev server
  • React Flow 11.11 - Graph visualization library
  • Zustand 4.5 - State management
  • Tailwind CSS 3.4 - Styling framework

Getting Started

Prerequisites

  • Node.js 20.x or higher
  • npm 9.x or higher

Installation

# Install dependencies
npm install

Development

# Start development server (opens at http://localhost:3000)
npm run dev

Build

# Build for production
npm run build

# Preview production build
npm run preview

Lint

# Run ESLint
npm run lint

Project Structure

constellation-analyzer/
├── src/
│   ├── components/          # React components
│   │   ├── Editor/         # Main graph editor
│   │   │   └── GraphEditor.tsx
│   │   ├── Nodes/          # Custom node components
│   │   │   └── CustomNode.tsx
│   │   ├── Edges/          # Custom edge components
│   │   │   └── CustomEdge.tsx
│   │   └── Toolbar/        # Editor controls
│   │       └── Toolbar.tsx
│   ├── stores/             # Zustand state stores
│   │   ├── graphStore.ts   # Graph state (nodes, edges, types)
│   │   └── editorStore.ts  # Editor settings
│   ├── types/              # TypeScript definitions
│   │   └── index.ts
│   ├── utils/              # Utility functions
│   │   ├── nodeUtils.ts
│   │   └── edgeUtils.ts
│   ├── styles/             # Global styles
│   │   └── index.css
│   ├── App.tsx             # Root component
│   ├── main.tsx            # Entry point
│   └── vite-env.d.ts       # Vite types
├── public/                 # Static assets
├── index.html             # HTML template
├── package.json           # Dependencies
├── tsconfig.json          # TypeScript config
├── vite.config.ts         # Vite config
├── tailwind.config.js     # Tailwind config
└── README.md              # This file

Usage

Adding Actors (Nodes)

  1. Click any of the actor type buttons in the toolbar (Person, Organization, System, Concept)
  2. A new node will appear on the canvas
  3. Drag the node to position it

Creating Relations (Edges)

  1. Click and drag from any colored handle (circle) on a node
  2. Release over a handle on another node to create a connection
  3. The edge will automatically appear with default styling

Deleting Elements

  • Delete Node: Select a node and press Delete or Backspace
  • Delete Edge: Select an edge and press Delete or Backspace

Navigation

  • Pan: Click and drag on empty canvas space
  • Zoom: Use mouse wheel or pinch gesture
  • Fit View: Use the controls in bottom-left corner
  • MiniMap: View overview and navigate in bottom-right corner

Core Concepts

Actors (Nodes)

Actors represent entities in your analysis. Each actor has:

  • Type: Category (person, organization, system, concept)
  • Label: Display name
  • Description: Optional details
  • Position: X/Y coordinates on canvas
  • Metadata: Custom properties

Relations (Edges)

Relations connect actors to show relationships. Each relation has:

  • Type: Category (collaborates, reports-to, depends-on, influences)
  • Label: Optional description
  • Style: Visual representation (solid, dashed, dotted)
  • Source/Target: Connected actors

Node Types

Pre-configured actor categories:

  • Person: Individual (Blue)
  • Organization: Company/group (Green)
  • System: Technical system (Orange)
  • Concept: Abstract idea (Purple)

Edge Types

Pre-configured relationship categories:

  • Collaborates: Working together (Blue, solid)
  • Reports To: Hierarchical (Green, solid)
  • Depends On: Dependency (Orange, dashed)
  • Influences: Impact (Purple, dotted)

Customization

Adding New Node Types

Edit /src/stores/graphStore.ts:

const defaultNodeTypes: NodeTypeConfig[] = [
  // Add your custom type
  {
    id: 'custom-type',
    label: 'Custom Type',
    color: '#ff6b6b',
    description: 'My custom actor type'
  },
];

Adding New Edge Types

Edit /src/stores/graphStore.ts:

const defaultEdgeTypes: EdgeTypeConfig[] = [
  // Add your custom type
  {
    id: 'custom-relation',
    label: 'Custom Relation',
    color: '#ff6b6b',
    style: 'solid'
  },
];

Architecture Decisions

Why React Flow?

  • React-native components for seamless integration
  • Excellent performance with large graphs
  • Rich API for customization
  • Active community and maintenance

Why Zustand?

  • Lightweight (< 1KB)
  • Simple, hook-based API
  • No boilerplate compared to Redux
  • Perfect for graph state management

Why Vite?

  • Lightning-fast HMR (Hot Module Replacement)
  • Modern build tool with ES modules
  • Optimized production builds
  • Better DX than Create React App

Why Tailwind CSS?

  • Rapid UI development
  • Consistent design system
  • Small production bundle (unused classes purged)
  • Easy responsive design

Development Guidelines

⚠️ Important: Always Use History-Tracked Operations

When modifying graph state in components, always use useGraphWithHistory() instead of useGraphStore() directly:

// ✅ CORRECT: Uses history tracking (enables undo/redo)
import { useGraphWithHistory } from '../../hooks/useGraphWithHistory';

function MyComponent() {
  const { addNode, updateNode, deleteNode } = useGraphWithHistory();

  const handleAddNode = () => {
    addNode(newNode);  // Automatically tracked in history
  };
}
// ❌ WRONG: Bypasses history (undo/redo won't work)
import { useGraphStore } from '../../stores/graphStore';

function MyComponent() {
  const graphStore = useGraphStore();

  const handleAddNode = () => {
    graphStore.addNode(newNode);  // History not tracked!
  };
}

Exception: Read-only access in presentation components (CustomNode, CustomEdge) is acceptable since it doesn't modify state.

History-Tracked Operations

All these operations automatically create undo/redo history entries:

  • Node operations: addNode, updateNode, deleteNode
  • Edge operations: addEdge, updateEdge, deleteEdge
  • Type operations: addNodeType, updateNodeType, deleteNodeType, addEdgeType, updateEdgeType, deleteEdgeType
  • Utility: clearGraph

See src/hooks/useGraphWithHistory.ts for complete documentation.

Next Steps

Suggested Enhancements

  1. Data Persistence

    • Save/load graphs to/from JSON
    • Local storage integration
    • Export to PNG/SVG
  2. Advanced Editing

    • Multi-select nodes
    • Copy/paste functionality
    • Undo/redo history (implemented - per-document with 50 action limit)
  3. Node/Edge Properties Panel

    • Edit labels and descriptions
    • Change types dynamically
    • Add custom metadata
  4. Layout Algorithms

    • Auto-arrange nodes
    • Hierarchical layout
    • Force-directed layout
  5. Analysis Tools

    • Calculate graph metrics
    • Find shortest paths
    • Identify clusters
  6. Collaboration

    • Real-time multi-user editing
    • Version control
    • Comments and annotations

Contributing

This is a new project. Contributions are welcome!

License

MIT

Support

For issues and questions, please open an issue on the repository.