npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@medha-analytics/datachat-ai

v1.0.0

Published

DataChat AI components library for Angular applications

Readme

@medha-analytics/datachat-ai

An Angular library providing AI-powered data chat components with interactive visualizations, session management, and automatic dark mode support.

Features

  • AI-Powered Chat Interface: Interactive chat component for data analysis conversations
  • Rich Visualizations: Support for charts (ECharts), tables (Tabulator), and data displays
  • Session Management: Create, manage, and switch between multiple chat sessions
  • Automatic Dark Mode: Portable theme system that automatically syncs with parent app's theme
  • Execution Timeline: Visual representation of query execution steps
  • Insights Panel: AI-generated insights and recommendations
  • Dimension Clarification: Interactive clarification dialogs for ambiguous queries
  • Responsive Design: Mobile-friendly components with adaptive layouts

Installation

npm install @medha-analytics/datachat-ai

Peer Dependencies

This library requires the following peer dependencies:

npm install @angular/common @angular/core @angular/material @angular/cdk @angular/forms @angular/router rxjs ngx-echarts echarts tabulator-tables

Usage

1. Configure the Library

In your app.config.ts:

import { ApplicationConfig } from '@angular/core';
import { provideDataChatAI } from '@medha-analytics/datachat-ai';

export const appConfig: ApplicationConfig = {
  providers: [
    provideDataChatAI({
      backendUrl: 'https://your-api-url.com',
      websocketUrl: 'wss://your-websocket-url.com',
      userId: 'optional-user-id'
    })
  ]
};

2. Dynamic User ID (Optional)

If you need to set the userId dynamically (e.g., after authentication), use APP_INITIALIZER:

import { ApplicationConfig, APP_INITIALIZER } from '@angular/core';
import { provideDataChatAI, EnvironmentService } from '@medha-analytics/datachat-ai';

function initializeUserId(envService: EnvironmentService) {
  return () => {
    // Get userId from your auth service or storage
    const userId = localStorage.getItem('userId') || 'default-user';
    envService.userId = userId;
  };
}

export const appConfig: ApplicationConfig = {
  providers: [
    provideDataChatAI({
      backendUrl: 'https://your-api-url.com',
      websocketUrl: 'wss://your-websocket-url.com',
      userId: '' // Will be set by initializer
    }),
    {
      provide: APP_INITIALIZER,
      useFactory: initializeUserId,
      deps: [EnvironmentService],
      multi: true
    }
  ]
};

3. Add Routes

In your app.routes.ts:

import { Routes } from '@angular/router';
import { HomeComponent } from '@medha-analytics/datachat-ai';

export const routes: Routes = [
  {
    path: 'datachat-ai',
    component: HomeComponent
  }
];

4. Import Styles

Add the library styles to your angular.json:

{
  "styles": [
    "node_modules/@medha-analytics/datachat-ai/styles/themes.css",
    "src/styles.scss"
  ]
}

Configuration Options

DataChatAIConfig

| Property | Type | Required | Description | |----------|------|----------|-------------| | backendUrl | string | Yes | Backend API URL for data processing | | websocketUrl | string | No | WebSocket URL for real-time updates (defaults to backendUrl) | | userId | string | No | User identifier for session management |

Theme System

The library includes a portable dark mode system that automatically detects and syncs with your parent application's theme.

How It Works

The library checks for a data-theme attribute on the <html> element:

<!-- Parent app sets theme -->
<html data-theme="dark">
  • Auto-Detection: On initialization, detects existing parent theme
  • Real-Time Sync: Monitors theme changes and updates automatically
  • Fallback: Uses system preference if no parent theme is detected
  • Independent: Can manage its own theme if needed

Console Logs

The library provides helpful console logs for theme detection:

=� DataChat AI Library: Detected parent app theme: dark
=� DataChat AI Library: Watching for parent app theme changes
=� DataChat AI Library: Parent app theme changed to: light

Manual Theme Control (Optional)

If you need to manually control the theme from your parent app:

// Set theme attribute on html element
document.documentElement.setAttribute('data-theme', 'dark');

The library will automatically detect and sync to this change.

Components

HomeComponent

Main entry point component that includes all features:

  • Chat interface
  • Session sidebar
  • Execution timeline
  • Insights panel
  • Results display
import { HomeComponent } from '@medha-analytics/datachat-ai';

Individual Components

You can also import and use individual components:

import {
  ChatInputComponent,
  ChatMessageComponent,
  SessionSidebarComponent,
  ExecutionTimelineComponent,
  InsightsComponent,
  DataTableComponent,
  DashboardResultsComponent
} from '@medha-analytics/datachat-ai';

Services

EnvironmentService

Access configuration values:

import { EnvironmentService } from '@medha-analytics/datachat-ai';

constructor(private envService: EnvironmentService) {
  console.log(this.envService.backendUrl);
  console.log(this.envService.userId);
}

ThemeService

Access theme state:

import { ThemeService } from '@medha-analytics/datachat-ai';

constructor(private themeService: ThemeService) {
  this.themeService.currentTheme$.subscribe(theme => {
    console.log('Current theme:', theme); // 'dark' | 'light'
  });
}

Example Integration

// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideDataChatAI } from '@medha-analytics/datachat-ai';
import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideDataChatAI({
      backendUrl: 'https://api.example.com',
      websocketUrl: 'wss://api.example.com/ws',
      userId: 'user-123'
    })
  ]
};
// app.routes.ts
import { Routes } from '@angular/router';
import { HomeComponent } from '@medha-analytics/datachat-ai';

export const routes: Routes = [
  {
    path: '',
    redirectTo: '/datachat-ai',
    pathMatch: 'full'
  },
  {
    path: 'datachat-ai',
    component: HomeComponent
  }
];

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Requirements

  • Angular >= 15.0.0
  • Node.js >= 16.0.0

License

ISC

Author

Medha Analytics

Support

For issues, questions, or contributions, please contact the Medha Analytics team.

Changelog

1.0.0 (2025-10-30)

  • Initial release
  • AI-powered chat interface
  • Interactive visualizations (ECharts, Tabulator)
  • Session management
  • Portable dark mode system with auto-sync
  • Execution timeline
  • Insights panel
  • Dimension clarification dialogs