๐ฆ Hashtag Parser & Redis Rotation ๐ง Conceptual Overview
- Webhook Listener: Receives JSON payloads from GitHub
- Parser: Scans text fields for hashtags
- Rotation Module: Stores and rotates hashtags
- Redis Queue: Acts as a fast buffer for display
๐ ️ Technical Workflow
| Step | Component | Description |
| 1️⃣ | req.body | Raw JSON payload from GitHub |
| 2️⃣ | Hashtag Parser | Regex-based scanner to extract #hashtags |
| 3️⃣ | Sanitizer | Removes duplicates, trims whitespace |
| 4️⃣ | Redis Queue | Pushes hashtags into a rotating buffer |
| 5️⃣ | Rotation Logic | Pops hashtags for display every X seconds |
๐งช Scientific & Algorithmic Breakdown
๐ Hashtag Extraction
const extractHashtags = (text) => { return text.match(/#[\w-]+/g) || []; };
๐ Rotation Logic
await redis.lpush('hashtagQueue', ...hashtags); await redis.ltrim('hashtagQueue', 0, 49); // Keep only latest 50
✅ Normalize casing, deduplicate, and timestamp each entry for audit-grade integrity.
๐งฐ Required Tools & Libraries
| Tool | Purpose |
| Node.js / Express | Serverless webhook listener |
| Redis | Fast, in-memory queue for rotation |
| Regex | Hashtag extraction |
| Micro Buffer | Raw body capture for HMAC |
| Supabase / Firebase | Optional persistent fallback |
| Socket.io / SSE | Optional real-time dashboard updates |
๐ Academic & Civic Justification
- Information Theory: Hashtags preserve semantic entropy
- Civic Informatics: Rotation reflects public discourse
- Security Science: Raw body ensures cryptographic integrity
- UX Design: Rotation improves dashboard freshness
๐งญ Deployment Checklist
- Enable raw body capture (
bodyParser: false) - Validate HMAC signature before parsing
- Extract hashtags from relevant fields
- Push to Redis queue with rotation logic
- Integrate with civic dashboard or ticker
- Log events for audit and debugging
๐ Glossary (Kid-Friendly)
| Term | Meaning |
Webhook | A message GitHub sends when something happens |
Hashtag | A keyword with # used to tag topics |
Rotation | Changing what’s shown every few seconds or minutes |
Redis | A fast memory tool that stores and rotates data |
Raw Body | The untouched message before any changes |
Audit Trail | A record of what happened and when |
No comments:
Post a Comment