github.com/michfioravera/fusion-chat

Fusion Chat

A real-time chat application with intelligent NLP-driven word clustering and interactive D3.js force-directed graph visualization. Perfect for simulating multi-user conversations and exploring message patterns through dynamic graph interactions.

Features

Tech Stack

How It Works

1. Message Input

Send messages as different users to build a multi-user conversation

2. NLP Pipeline

3. Graph Visualization

4. Interaction

Getting Started

Prerequisites

Installation

# Install dependencies
pnpm install

# Start development server
pnpm run dev

The app will be available at http://localhost:5173

Build

# Build for production
pnpm run build:client

# Build server (if needed)
pnpm run build:server

Usage

Creating Users

  1. Click Users (n) dropdown in the header
  2. Click + New User to create a new user persona
  3. Start sending messages as that user

Switching Users

  1. Click Users (n) dropdown
  2. Click any existing user to switch to them
  3. All previous messages are preserved

Interacting with the Graph

Managing Messages

Project Structure

client/
├── components/
│   ├── InMemoryGraphVisualizer.tsx    # D3.js graph visualization
│   ├── InMemoryChatInput.tsx          # Message input component
│   ├── InMemoryChatWindow.tsx         # Message display
│   └── ui/                             # Radix UI components
├── context/
│   └── InMemoryDataProvider.tsx       # React Context for shared state
├── pages/
│   ├── Index.tsx                      # Landing page
│   ├── InMemoryChat.tsx               # Main chat page
│   └── NotFound.tsx                   # 404 page
├── utils/
│   └── nlpInMemory.ts                 # NLP pipeline (TF-IDF, K-means)
└── App.tsx                            # Main app component

NLP Implementation Details

Tokenization

TF-IDF Scoring

K-Means Clustering

Customization

Change Number of Clusters

Edit client/context/InMemoryDataProvider.tsx:

const graph = computeClusterGraph(messages, 3); // Change 3 to desired cluster count

Adjust Graph Forces

Edit client/components/InMemoryGraphVisualizer.tsx:

.force("charge", d3.forceManyBody().strength(-300))  // Repulsion strength
.force("collision", d3.forceCollide().radius(40))    // Node collision radius

Modify Stopwords

Edit client/utils/nlpInMemory.ts:

const stopwords = new Set([
  "the",
  "a",
  "an",
  "is",
  "are",
  "be",
  // Add more stopwords here
]);

Deployment

Netlify

# Build will be automatically run on deploy
# Configure in netlify.toml for production

The app is configured to deploy to Netlify with:

🔧 Available Scripts

pnpm run dev              # Start development server
pnpm run build            # Build for production
pnpm run build:client     # Build client only
pnpm run build:server     # Build server only
pnpm run start            # Start production server
pnpm run test             # Run tests
pnpm run typecheck        # Check TypeScript types
pnpm run format.fix       # Format code with Prettier

📝 Notes

Contributing

Feel free to extend this project:

License

This project is open source and available under the MIT License.

Learning Resources

NLP Concepts

Technologies