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

wealth-alpha-chat-widget

v2.1.4

Published

AI chatbot React/Next.js library with chip flows, auth gate.

Downloads

3,178

Readme

wealth-alpha-chat

Drop-in React / Next.js chat widget for Wealth Alpha AI — chip-driven flows, JWT auth, 30-minute sliding session, full markdown rendering, AI free-text routing via /intent/detect + /ama/follow-up.

The library is one component (<WealthChat />) plus a backend chat router (chat_widget.py) that proxies your 20 telegram-api endpoints, persists every turn, and returns chip + message responses ready to render.


What you get

  • 8 root chips matching the Telegram bot: Stock Analysis, Stock Discovery, New Listings, Portfolio Risk, Market Forecast, Crypto, Tradable Picks, Peer Comparison
  • Multi-step flows with chip + free-text inputs (symbol → date → price → result)
  • Drill-down chips on every list result — click a stock row to dive into its analysis
  • AI free-text — typed queries get classified by /intent/detect and routed to the right chip flow, with /ama/follow-up for ambiguous queries
  • 30-minute sliding session stored in localStorage["wac_session"]
  • Auto-discovers JWT from localStorage["token"] (or access_token / auth_token / jwt) — no bridge code required in the host app
  • Auto-logout — when the host app removes its token (user signs out), the chat clears its session on next render and shows the AuthGate
  • Server-side history — every turn saved to chat_messages via the team's ChatService
  • Markdown rendering with markdown-it — bold, italic, bullets, links, code, headings

Repo layout

Wealth-alpha-chat-UI/                         ← the npm library
├── src/
│   ├── components/    WealthChat, AuthGate, ChatBody, MessageBubble, ChipRow, …
│   ├── hooks/         useAuth, useSession, useChat, useChip
│   ├── api/           chatApi.ts (fetch wrapper: timeout, retry, abort, X-Request-Id)
│   ├── utils/         session.ts (JWT auto-discover), markdown.ts (markdown-it)
│   └── styles/        chat.module.css (CSS Modules, brand color via --wac-brand)
├── dist/              tsup build output (ESM + CJS + .d.ts + .css)
├── tsup.config.ts     bundler (preserves "use client" for Next.js App Router)
├── scripts/add-use-client.mjs   post-build directive injector
└── docs/              SETUP.md · PUBLISH.md · DEPLOY.md · BACKEND_CHAT_WIDGET.md

WealthAlpha-Backend/app/api_v1/   ← team's FastAPI backend
├── chat_widget.py     chat router + chip tree + multi-step state + intent routing
├── chat_formatters.py 18 template formatters (LONG_TERM, CRYPTO_ANALYSIS, …)
├── chat.py            team's chat persistence (CRUD)
├── intent.py          team's intent classifier
└── ama.py             team's clarifying-question LLM

Quick install

npm install wealth-alpha-chat

In your app's root (e.g. src/app/layout.tsx for Next.js App Router):

import { WealthChat } from "wealth-alpha-chat";
import "wealth-alpha-chat/styles.css";

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <WealthChat
          apiBase={process.env.NEXT_PUBLIC_API_BASE ?? "http://localhost:8013/api/v1/chat-widget"}
          authCheck="/me"
          loginUrl="/login"
          sessionTTL={1800}
          brandName="Wealth Alpha AI"
          brandColor="#1a2d5a"
          position="bottom-right"
        />
      </body>
    </html>
  );
}

Your existing JWT login (stored under localStorage["token"]) is automatically picked up — no bridge component needed.

For the full integration walkthrough see docs/SETUP.md.


Documentation

| Doc | Audience | What it covers | |---|---|---| | SETUP.md | App developers integrating the widget | Install, mount, env vars, auth bridging, customization | | PUBLISH.md | Library maintainers | Version bump, build, npm pack, npm publish, pre-flight checklist | | DEPLOY.md | Ops / DevOps | Backend deploy (uvicorn + reverse proxy), frontend deploy, env config, scaling notes | | BACKEND_CHAT_WIDGET.md | Backend developers extending the chip tree | How chat_widget.py works, chip kinds, multi-step state, formatters, intent routing, drill-down chips |


Tech stack

| Layer | Tool | |---|---| | UI | React 18 + TypeScript | | Bundler | tsup (esbuild) → ESM + CJS + .d.ts + scoped CSS | | Styles | CSS Modules — no global pollution | | Markdown | markdown-it (XSS-safe, +27 KB) | | HTTP | native fetch with retry/timeout/abort wrapper | | Auth | JWT in localStorage (host app key — auto-discovered) | | Backend | FastAPI + httpx (loopback to upstream telegram-api endpoints) | | State | React Context-less — local hooks per component | | Session storage | localStorage + in-memory dict per sessionId server-side |


Development

# Library
cd Wealth-alpha-chat-UI
npm install
npm run dev          # tsup --watch (rebuilds on save)
npm run typecheck    # tsc --noEmit
npm run build        # production bundle to dist/

# Backend (separate terminal)
cd ../WealthAlpha-Backend
source venv/bin/activate
uvicorn main:app --reload --port 8013

# Frontend (separate terminal)
cd ../WealthAlpha-Frontend
npm install ../Wealth-alpha-chat-UI/wealth-alpha-chat-0.1.0.tgz --force
npm run dev          # http://localhost:3000

License

MIT