Skip to content

Find a component

Loading the directory…

↑ ↓ to select · Enter to open · Esc to closeBrowse all →
Contributor login

smart-tags

A Convex component for smart tagging and categorization with hierarchy and analytics

Upstream source
git clone https://github.com/itsminhz/convex-smart-tags.git
cd convex-smart-tags

This upstream package has not been adapted or qualified for Bijection. Read the original documentation before adopting it.

Description

A Convex component for smart tagging and categorization with hierarchy and analytics

Explore the package README for API concepts, configuration, and examples. Check the Bijection source for adaptation-specific setup.

Available to evaluate

Review the source and its dependencies before adopting this package. Source availability does not establish npm publication or runtime qualification.

Getting started

  1. Get the source at the revision above and read its package documentation.
  2. Check the required Bijection SDK version, dependencies, and external service credentials.
  3. Follow the package setup instructions and the guide to using components.
  4. Exercise the component in your deployment according to your project’s verification rules.

Open source

Maintained source: itsminhz/convex-smart-tags. License: See repository. Consult the repository for license terms, notices, and contributor attribution.

From the upstream publisher

A Convex component for smart tagging and categorization with hierarchy and analytics

Explore the demo ↗

Upstream overview

From the upstream package documentation.

convex-smart-tags is a Convex component that adds tagging infrastructure across any table in your Convex project. It provides tag CRUD, parent-child tag hierarchies with ancestor traversal, daily usage tracking, and trending calculations through a type-safe TypeScript client wrapper. The component registers its own tables (tags, entityTags, tagHierarchy, tagAnalytics) and exposes a clean API callable from mutations and queries without any schema modifications to your existing tables.

Use cases

From the upstream package documentation.

  • Adding user-defined labels to heterogeneous entity types (posts, comments, products) from a single shared tag store without duplicating tagging logic per table
  • Building a content taxonomy where tags have parent-child relationships and you need ancestor chain lookups or subtree queries (e.g., 'technology' -> 'ai' -> 'llms')
  • Surfacing trending or popular tags over a configurable time window for a discovery or search feature
  • Auditing cross-table tag usage to understand which entity types use which tags and at what volume
  • Bootstrapping a tagging system quickly in a Convex project without writing custom schema, indexes, and query logic from scratch

How it works

From the upstream package documentation.

Register the component in convex/convex.config.ts using app.use(smartTags). This mounts the component's internal tables (tags, entityTags, tagHierarchy, tagAnalytics) into your Convex deployment under its own namespace, leaving your existing schema untouched.

Instantiate the SmartTags client with new SmartTags(components.smartTags) inside your server-side files. The client exposes methods like addTag, removeTag, getTagsForEntity, and getEntitiesByTag, each taking a tableName and entityId string so tags are scoped per entity type without requiring foreign key constraints or schema changes.

Hierarchy is managed via createTagHierarchy, getChildTags, and getTagAncestors. These operate on the tagHierarchy table, which is indexed by parent and child tag name, enabling traversal in both directions.

Analytics are tracked automatically at the daily granularity in the tagAnalytics table. getTrendingTags accepts a timeRange in milliseconds and returns tags ranked by usage velocity, while getTagStats returns per-tag aggregate counts including recent trend data.

Upstream package FAQ

How does convex-smart-tags handle tag hierarchies in the database?

The convex-smart-tags component creates parent-child relationships using Convex's document references, allowing unlimited nesting levels. It automatically maintains referential integrity and provides optimized queries for traversing tag trees up or down the hierarchy.

Can I migrate existing tags to use this component?

Yes, convex-smart-tags includes migration utilities that can import existing tag data from simple string arrays or other tagging systems. The component provides functions to batch-convert existing tags while preserving relationships and metadata.

What analytics data does this component track?

The convex-smart-tags component automatically tracks tag usage frequency, creation dates, trending patterns, and content association counts. All analytics data is stored in your Convex database and accessible through built-in query functions.

How do I query content by tags with this component?

The convex-smart-tags component provides optimized query functions that work with Convex's indexing system. You can filter content by single tags, tag combinations, or entire tag hierarchies using the provided query helpers that handle the database operations efficiently.

Use with agents and CLI

Give your coding agent the component’s source identity and setup guidance.

agent-prompt.md
Help me integrate smart-tags with Bijection.

Read: https://bijection.com/components/convex-smart-tags/SKILL.md

Check SDK compatibility and dependency availability.
Follow this project's execution and verification rules.

Upstream README.md

View repository ↗

Documentation from itsminhz/convex-smart-tags, recorded October 23, 2026. APIs and setup may differ in the Bijection adaptation.

Convex Smart Tags Component

A reusable Convex component that provides intelligent tagging and categorization capabilities with hierarchical organization and analytics. Designed for easy integration into Convex projects and to work across multiple tables and entity types.

Why use this component

  • Core tag management (add, remove, query tags) across table boundaries
  • Tag hierarchy support (parent-child relationships, ancestor/descendant lookups)
  • Tag analytics and trending (daily counts, trending calculation)
  • Type-safe TypeScript client wrapper for convenient usage in Convex functions
  • Example app and test helpers included for fast onboarding

Features

  • Add and remove tags from any entity
  • Query tags for an entity and entities by tag
  • Create and query parent-child tag relationships
  • Track daily tag usage and compute trending tags
  • Cross-table tag usage statistics
  • Full TypeScript types for client and server integration

Installation

Install from npm:

npm install convex-smart-tags
# or
yarn add convex-smart-tags

Quick start

  1. Add the component to your Convex app configuration:
// convex/convex.config.ts
import { defineApp } from "convex/server";
import smartTags from "convex-smart-tags/convex.config";

const app = defineApp();
app.use(smartTags);

export default app;
  1. Use the client wrapper inside Convex functions:
// functions.ts (Convex server-side code)
import { SmartTags } from "convex-smart-tags";
import { components } from "./_generated/api";
import { mutation, query } from "./_generated/server";

const smartTags = new SmartTags(components.smartTags);

export const tagPost = mutation({
  handler: async (ctx) => {
    const postId = "post123";
    await smartTags.addTag(ctx, {
      tagName: "urgent",
      tableName: "posts",
      entityId: postId,
    });
  },
});

export const getPostTags = query({
  args: { postId: v.id("posts") },
  handler: async (ctx, args) => {
    return smartTags.getTagsForEntity(ctx, {
      tableName: "posts",
      entityId: args.postId,
    });
  },
});

See the example/ directory for a complete working example application.

API overview

The component exposes a client wrapper SmartTags with a type-safe surface. Primary methods include:

  • addTag(ctx, args: { tagName, tableName, entityId }): Promise
  • removeTag(ctx, args: { tagName, tableName, entityId }): Promise
  • getTagsForEntity(ctx, args: { tableName, entityId }): Promise<Array>
  • getEntitiesByTag(ctx, args: { tagName, tableName?, limit? }): Promise<Array<{ tableName, entityId }>>
  • createTagHierarchy(ctx, args: { parentTag, childTag }): Promise
  • getChildTags(ctx, args: { parentTag, limit? }): Promise<Array<{ tagName, level }>>
  • getTagAncestors(ctx, args: { tagName }): Promise<Array<{ tagName, level }>>
  • getTrendingTags(ctx, args: { timeRange, limit? }): Promise<Array<{ tagName, usageCount, trend }>>
  • getTagStats(ctx, args: { tagName }): Promise<{ totalUsage, entityCount, createdAt, recentTrend }>
  • getTagsAcrossTables(ctx, args?: { limit? }): Promise<Array<{ tableName, tagName, entityCount }>>

Each method is implemented in a type-safe manner; consult the generated types under src/_generated in your project for full signatures.

Schema

The component registers the following tables in your Convex schema:

  • tags

    • name: string
    • createdAt: number
    • usageCount: number
    • indexed by: by_name
  • entityTags

    • tagName: string
    • tableName: string
    • entityId: string
    • createdAt: number
    • indexes: by_tag, by_entity, by_tag_and_entity
  • tagHierarchy

    • parentTag: string
    • childTag: string
    • createdAt: number
    • indexes: by_parent, by_child, by_parent_and_child
  • tagAnalytics

    • tagName: string
    • usageDate: number
    • dailyCount: number

The full schema definition is in src/component/schema.ts.

Examples

Basic tag management:

// Add a tag to an entity
await smartTags.addTag(ctx, {
  tagName: "important",
  tableName: "posts",
  entityId: "post123",
});

// Get tags for an entity
const tags = await smartTags.getTagsForEntity(ctx, {
  tableName: "posts",
  entityId: "post123",
});

Tag hierarchy:

// Create a parent-child relationship
await smartTags.createTagHierarchy(ctx, {
  parentTag: "technology",
  childTag: "ai",
});

// Get child tags
const children = await smartTags.getChildTags(ctx, { parentTag: "technology" });

// Get ancestor chain
const ancestors = await smartTags.getTagAncestors(ctx, { tagName: "ai" });

Analytics and trending:

// Get trending tags for the last 7 days
const sevenDays = 7 * 24 * 60 * 60 * 1000;
const trending = await smartTags.getTrendingTags(ctx, {
  timeRange: sevenDays,
  limit: 10,
});

// Get comprehensive statistics for a single tag
const stats = await smartTags.getTagStats(ctx, { tagName: "ai" });

Example Convex component registration (from example/convex/convex.config.ts):

import { defineApp } from "convex/server";
import smartTags from "convex-smart-tags/convex.config";

const app = defineApp();
app.use(smartTags);

export default app;

Testing

The package includes test helper registration for the Convex test environment.

// src/test.ts — usage inside tests
import { convextTest } from "convex-test";
import smartTagsTest from "convex-smart-tags/src/test";

const t = convextTest();
smartTagsTest.register(t, "smartTags");

Run the project's test and typecheck commands as configured (see vitest.config.js and package.json scripts).

Development

To develop locally:

  1. Install dependencies
npm install
  1. Build and run example
npm run build
cd example
npm install
npx convex dev
npm run dev
  1. Typecheck and run tests
npm run typecheck
npm run test

License

Apache-2.0 — see the LICENSE file for details.