Node.js demo app for Deepgram Text Intelligence.
- Backend: Node.js (JavaScript) on port 8081
- Frontend: Vite + vanilla JS on port 8080 (git submodule:
text-intelligence-html) - API type: REST —
POST /api/text-intelligence - Deepgram API: Text Intelligence / Read API (
/v1/read) - Auth: JWT session tokens via
/api/session(WebSocket auth usesaccess_token.<jwt>subprotocol)
| File | Purpose |
|---|---|
server.js |
Main backend — API endpoints and request handlers |
deepgram.toml |
Metadata, lifecycle commands, tags |
Makefile |
Standardized build/run targets |
sample.env |
Environment variable template |
frontend/main.js |
Frontend logic — UI controls, API calls, result rendering |
frontend/index.html |
HTML structure and UI layout |
deploy/Dockerfile |
Production container (Caddy + backend) |
deploy/Caddyfile |
Reverse proxy, rate limiting, static serving |
# Initialize (clone submodules + install deps)
make init
# Set up environment
test -f .env || cp sample.env .env # then set DEEPGRAM_API_KEY
# Start both servers
make start
# Backend: http://localhost:8081
# Frontend: http://localhost:8080Start (recommended):
make startStart separately:
# Terminal 1 — Backend
node server.js
# Terminal 2 — Frontend
cd frontend && corepack pnpm run dev -- --port 8080 --no-openStop all:
lsof -ti:8080,8081 | xargs kill -9 2>/dev/nullClean rebuild:
rm -rf node_modules frontend/node_modules frontend/.vite
make init- Backend:
package.json— Usescorepack pnpm— Node's built-in package manager version pinning. - Frontend:
frontend/package.json— Vite dev server - Submodules:
frontend/(text-intelligence-html),contracts/(starter-contracts)
Install: corepack pnpm install
Frontend: cd frontend && corepack pnpm install
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/api/session |
GET | None | Issue JWT session token |
/api/metadata |
GET | None | Return app metadata (useCase, framework, language) |
/api/text-intelligence |
POST | JWT | Analyzes text for summaries, topics, sentiment, and intents. |
The API supports four analysis features, each enabled independently via query parameters:
| Feature | Parameter | Values | Effect |
|---|---|---|---|
| Summarize | summarize |
true, v2 |
Generate text summary |
| Topics | topics |
true |
Detect discussed topics |
| Sentiment | sentiment |
true |
Analyze sentiment (positive/neutral/negative) |
| Intents | intents |
true |
Detect user intents |
Backend: These are passed as query parameters to the Deepgram Read API. Enable/disable them in the backend handler or let the frontend control them.
Frontend: The frontend has checkboxes for each feature. Users select which analyses to run. To change defaults (e.g., always enable sentiment), edit frontend/main.js.
Add language=<code> as a query parameter. Default is en. Supported languages depend on the feature — check Deepgram docs.
The app supports two input modes:
- Text — User pastes text directly
- URL — User provides a URL; the backend fetches and analyzes the text content
The full Deepgram response includes:
results.summary.text— Summary textresults.topics.segments[].topics[].topic— Detected topics with confidenceresults.sentiments.average— Overall sentiment with scoreresults.sentiments.segments[]— Per-segment sentimentresults.intents.segments[].intents[].intent— Detected intents with confidence
You can modify the backend response formatter to include/exclude specific fields or add post-processing.
The frontend is a git submodule from deepgram-starters/text-intelligence-html. To modify:
- Edit files in
frontend/— this is the working copy - Test locally — changes reflect immediately via Vite HMR
- Commit in the submodule:
cd frontend && git add . && git commit -m "feat: description" - Push the frontend repo:
cd frontend && git push origin main - Update the submodule ref:
cd .. && git add frontend && git commit -m "chore(deps): update frontend submodule"
IMPORTANT: Always edit frontend/ inside THIS starter directory. The standalone text-intelligence-html/ directory at the monorepo root is a separate checkout.
- Add the HTML element in
frontend/index.html(input, checkbox, dropdown, etc.) - Read the value in
frontend/main.jswhen making the API call or opening the WebSocket - Pass it as a query parameter or request body field
- Handle it in the backend
server.js— read the param and pass it to the Deepgram API
| Variable | Required | Default | Purpose |
|---|---|---|---|
DEEPGRAM_API_KEY |
Yes | — | Deepgram API key |
PORT |
No | 8081 |
Backend server port |
HOST |
No | 0.0.0.0 |
Backend bind address |
SESSION_SECRET |
No | — | JWT signing secret (production) |
All commits must follow conventional commits format. Never include Co-Authored-By lines for Claude.
feat(node-text-intelligence): add diarization support
fix(node-text-intelligence): resolve WebSocket close handling
refactor(node-text-intelligence): simplify session endpoint
chore(deps): update frontend submodule
# Run conformance tests (requires app to be running)
make test
# Manual endpoint check
curl -sf http://localhost:8081/api/metadata | python3 -m json.tool
curl -sf http://localhost:8081/api/session | python3 -m json.tool