Afzan Khan
afzanlearns
Back to Projects
PythonFastAPIReactLLMSQLite

TagGenie

Not Yet Deployed
View Source

About the Project

An AI-powered hashtag scoring and content strategy system that ranks tags by real competitive signals — reach, saturation, semantic diversity, and platform behavior — instead of frequency counts, and gets sharper over time by learning from actual post engagement.

Overview

Most hashtag tools are frequency counters: pull the most common terms for a topic and call it a recommendation. TagGenie takes a fundamentally different approach — it estimates real-world reach, measures competitive saturation against an industry-specific corpus, weights results by platform-specific behavioral differences, and actively enforces semantic diversity so recommendations span multiple marketing angles instead of clustering on one. On top of ranking, it extracts structured product intelligence from any URL, surfaces high-reach/low-competition "blue ocean" terms, simulates platform-styled posts, compares competitors, and generates full AI content briefs — all backed by an adaptive learning loop that updates weights from real engagement data rather than staying static.

System Architecture

A React + Vite frontend talks to a FastAPI backend over a set of purpose-built endpoints (/api/score, /api/analyze-url, /api/compare, /api/content-brief, /api/simulate-content), each backed by its own module — scoring.py and ranking.py for the core ranking pipeline, url_intelligence.py for the URL analysis pipeline, competitor.py and content_brief.py for higher-level strategy features. Supporting modules handle embeddings, taxonomy matching, feedback logging, scheduling, auth, and caching, with three separate SQLite databases (auth.db, user_data.db, feedback.db) partitioning users, history/settings, and engagement data.

Core Scoring Pipeline

Given a topic, product, and platform, the pipeline extracts candidate tags from a niche-specific corpus, enriches them with taxonomy-derived concept terms, then ranks them through a stack of signals: embedding-based semantic relevance, a Beta-distribution trend score, log-frequency competition scoring, niche-specific platform fit, and historical feedback confidence. Tags are further scored across 8 marketing dimensions with a diversity penalty for dimension overlap, a platform-specific dimension bonus, and a final MMR (λ=0.6) rerank to eliminate lexical duplicates — so the output set spans genuinely different angles rather than nine variations of the same idea. Results are cached, saved to history for authenticated users, and fed back into niche confidence metadata.

URL Intelligence Pipeline

A 12-stage pipeline turns any URL into structured product intelligence: Playwright renders the page headlessly, structured data (Open Graph, JSON-LD, microdata) and heuristic signals (title, meta, headings) are extracted, the page is classified into one of 9 page types, and an LLM (GPT-4o-mini) enriches it with brand, audience, pain points, benefits, and search intent. A cross-session knowledge cache short-circuits repeat lookups for known domains, a taxonomy DAG fills in gaps the LLM misses, and a source-aware confidence score is computed — schema/meta data weighted at full confidence, taxonomy-inferred fields at 0.75×, and LLM-only fields at 0.5× — so downstream consumers know exactly how much to trust each field, not just the score.

Semantic Diversity & Platform Personality

Every tag is classified into 8 marketing dimensions (intent, audience, community, lifestyle, emotional, trend, discovery, commercial) using pattern matching and named-entity lists. Diversity is enforced in two passes — an early dimension-overlap penalty and a late MMR cosine-diversity rerank — so results don't cluster semantically or lexically. Platform personality is handled entirely through dimension-weight profiles rather than separate models: the same tag can rank differently on Instagram (lifestyle/emotional-weighted) versus LinkedIn (intent/commercial-weighted) purely from how the ranking weights shift per platform.

Adaptive Learning

TagGenie logs how posts using its recommended tags actually perform — combining real engagement data pulled via the Reddit API with clearly-labeled synthetic data — and maintains a Beta(α, β) posterior per (platform, tag_type) pair using Thompson Sampling. A nightly APScheduler job recomputes these weights and blends them into platform-fit scoring, meaning the system explores uncertain recommendations while exploiting ones it's already confirmed work, sharpening its own recommendations the more it's used.

Additional Capabilities

  • Gap Finding — surfaces high-reach, low-competition "blue ocean" terms worth acting on
  • Competitor Intelligence — compares two brands/products across keywords, audience, and platform strategy
  • Content Briefs & Simulation — generates full AI content briefs (hooks, CTAs, outlines, SEO metadata) and previews platform-styled post drafts from selected tags
  • Multi-Industry Niches — new verticals can be bootstrapped from 5+ sample posts, auto-generating a starter corpus, jargon profile, and topics via LLM
  • Explainability — every ranked tag ships with a dimension-aware, strategy-grounded explanation for why it ranked where it did
  • Evaluation Harness — backtests ranking quality against held-out historical data, computing precision@5/@10 against a TF-IDF baseline

Key Design Decisions

  • Graceful degradation at every stage — Playwright failure falls back to heuristic-only extraction; LLM failure falls back to taxonomy + heuristics; both failing still yields a low-confidence URL-based guess rather than an error
  • Taxonomy is DAG-based, not embedding-based — deterministic keyword matching (exact → substring → word-overlap → fuzzy) chosen deliberately for speed and debuggability over embedding search
  • Source-aware confidence — hard facts (schema/meta) are never treated the same as derived facts (taxonomy) or AI-generated ones (LLM-only), so confidence scores reflect actual reliability