Inspiration
Moderating a rapidly expanding subreddit is a constant battle against a relentless flow of independent reports. Standard moderation queues are fundamentally reactive: a user violates a rule, content is flagged, and moderators eventually clear it item-by-item from a hidden workspace queue.
The major flaw in community health management is a lack of real-time pattern recognition. Malicious actors and toxic accounts rarely stop at a single infraction; instead, they exploit the gaps between separate moderator shifts by repeating disruptive behaviors across different comment sections before a human moderator connects the dots.
We built ModShield to solve this exact problem. By serving as a proactive, continuous memory layer for the subreddit, ModShield hooks into raw activity feeds, calculates cumulative infrastructure footprints across posts and comments, and mitigates repeat offenders before they can hijack the community timeline.
What it does
ModShield is an automated, enterprise-grade moderation intelligence suite engineered directly on top of Reddit's ecosystem. It fully digitizes the tracking and containment lifecycle of disruptive community members via three pillars:
- Intelligent Detection ($\mathbb{D}$): The system continuously listens to native
PostReportandCommentReporttrigger payloads. Upon event arrival, ModShield automatically isolates the unique hash identifiers and matches them against active database profiles using high-speed API lookups. - Automated Enforcement ($\mathbb{E}$): The app evaluates user profiles using multi-tiered infraction bounds. Let $R_u$ be the cumulative reports mapped to a unique user $u$, and $T$ represent the community's configured violation threshold:
- Tier 1 Alert ($R_u \ge T$): Renders a structured data card with a clickable markdown profile index and routes it directly to the subreddit's private Modmail inbox.
- Tier 2 Containment ($R_u \ge 2T$): Instantly triggers an autonomous
muteUser()directive to insulate the community from further escalation.
- Administrative Oversight ($\mathbb{O}$): Moderators have access to a beautiful, full-scale command console built natively with Devvit UI Blocks. It provides complete transparency over operations through an immutable live user metrics table, a real-time stream tracking the last 20 events, and manual override reset keys.
How we built it
ModShield is written entirely in TypeScript using the Devvit SDK. To support rapid, concurrent event handling on high-traffic subreddits, we moved away from volatile data storage formats in favor of an optimized, multi-key Redis architecture layer:
- Atomic Counters (
incrBy): Provides thread-safe increment routines to guarantee data consistency during massive reporting spikes. - Hashes (
hset/hget): Manages distinct metadata records per flagged user profile. - Sorted Sets (
zadd): Indexes the real-time activity stream using precision Unix epoch timestamps ($t_s$) as scores.
To keep the application highly performant, we engineered an internal Settings Caching Engine. Subreddit preferences like master switches, numeric limits, and dry-run toggles are continuously synced to low-latency Redis storage, ensuring sub-millisecond evaluation routines during live report incidents.
Challenges we faced
Handling structural differences between data payloads was our primary bottleneck. Reddit's PostReport event emits an author's unique account hash (t2_ ID) instead of a plain text string, which initially caused silent tracking dropouts. We engineered an asynchronous type-resolution routine using context.reddit.getUserById() to reliably extract target usernames.
We also faced concurrency challenges when managing atomic calculations during rapid bursts of report events. Transitioning our data store from standard JSON key-value blocks to specialized Redis operations completely eliminated data race conditions.
What we learned
Building ModShield gave us deep technical insight into the lifecycle of real-time Reddit platform applications. We mastered high-concurrency data engineering, state management under strict computational windows, and complex UI layouts within strict block rendering structures. Most importantly, we learned to build from a moderator's perspective—introducing compact preview teaser banners and quick subreddit navigation tools to blend seamlessly into their existing day-to-day workflow.
Built With
- devvit
- redis
- typescript
- ui-blocks
Log in or sign up for Devpost to join the conversation.