Never read another hate comment. Moderaty is an open-source YouTube comment protection platform for creators. It applies the creator's rules first, uses AI as a second opinion, and sends uncertain decisions to a human review queue.
- Connects YouTube channels through Google OAuth.
- Matches top-level comments against keyword, regex, and blocked-user rules.
- Applies
hold,reject,delete, orbanactions to matching comments. - Uses OpenAI moderation and an optional per-channel tone pass for comments that rules do not decide.
- Routes AI failures and borderline scores to a human review queue instead of silently approving or rejecting them.
- Records decisions in an audit log and supports
DRY_RUN=truepreviews.
Each scheduled run is bounded and checkpointed. It processes one eligible channel, records enforcement work in the database before writing to YouTube, and reconciles unfinished actions on a later run.
Moderaty is a SvelteKit 2 application using Svelte 5, TypeScript, and the Netlify adapter. Server code calls the Google and OpenAI HTTP APIs directly; there are no auth, Google, or OpenAI SDKs in the dependency tree.
| Path | Purpose |
|---|---|
src/routes/ |
Landing page, authenticated app pages, OAuth routes, and cron API |
src/lib/ |
Shared Svelte components, landing-page content, and server modules |
src/lib/server/ |
Sessions, OAuth, encryption, rules, moderation, pipeline, and database access |
drizzle/ |
Database migrations for libSQL/SQLite and Turso |
netlify/functions/cron.mjs |
Scheduled Netlify function that invokes the cron endpoint |
scripts/ |
Local demo-data seeding and live tone calibration tools |
docs/ |
Manual end-to-end verification notes |
DEPLOY.md |
Netlify, Turso, Google OAuth, and cron deployment instructions |
EXECUTION_PLAN_YouTube_Comment_Moderator.md |
Implementation plan and system invariants |
The app uses local SQLite through file:local.db during development and Turso
in production. Sessions are stored in the database, and YouTube refresh tokens
are encrypted before storage. The application is multi-user: authenticated
queries and mutations are scoped to the signed-in user's channels.
- Node.js 24+
- npm 11+
- Google Cloud OAuth credentials for sign-in and YouTube channel access
- An OpenAI API key for live moderation runs
git clone https://github.com/Bonobo791/Moderaty.git
cd Moderaty
npm ci
cp .env.example .envFill in .env with the required values. For a local database, keep
TURSO_DATABASE_URL=file:local.db and start with DRY_RUN=true. Apply the
migrations before starting the app:
set -a
source .env
set +a
npm run db:migrate
npm run devOpen http://localhost:5173. Google OAuth redirect URIs and production setup
are documented in DEPLOY.md; the manual credential and smoke-test
checklist is in docs/e2e-verification.md.
To populate the local app with a safe demo channel and sample queue data:
node --env-file=.env scripts/seed-dev.mjs
node --env-file=.env scripts/seed-dev.mjs --resetThe seed script refuses non-local database URLs.
Copy .env.example and provide these values as appropriate:
| Variable | Purpose |
|---|---|
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET |
Google OAuth client credentials |
APP_URL |
Canonical app URL used for OAuth redirects |
TURSO_DATABASE_URL, TURSO_AUTH_TOKEN |
Local SQLite or production Turso connection |
OPENAI_API_KEY |
AI moderation and tone scoring |
OPENAI_TONE_MODEL |
Optional tone model; defaults to gpt-4.1-nano |
CRON_SECRET |
Secret for scheduled and manual cron requests |
ENCRYPTION_KEY |
Key used to encrypt stored YouTube refresh tokens |
DRY_RUN |
Must be true or false; true records audit previews without durable moderation changes |
Never commit .env or real credentials. Netlify environment-variable setup is
covered by DEPLOY.md.
npm run dev # Start the development server
npm run check # Run SvelteKit sync and strict TypeScript diagnostics
npm run test # Run the Vitest suite
npm run build # Build the Netlify deployment
npm run preview # Serve the production build locally
npm run db:migrate # Apply Drizzle migrationsThe test suite includes route, OAuth, session, database, moderation, pipeline, and UI-state tests. The tone evaluator is a separate live API check:
node scripts/tone-eval.mjsUsers sign in with Google identity (openid email profile) and then grant a
separate youtube.force-ssl consent to connect a channel. Self-hosted
instances use the same code path and bring their own Google, OpenAI, and Turso
credentials. Moderaty is designed for Netlify Functions with Turso as the
production database; see DEPLOY.md for the scheduled function and
post-deployment verification.
Moderaty is source-available under a dual-license model:
- PolyForm Shield 1.0.0: LICENSE — free to use, self-host, modify, and distribute, including for commercial purposes, provided that you do not use Moderaty to provide a product or service that competes with Moderaty or another product or service provided by Advanced Digital Marketing LTDA using Moderaty.
- Commercial license: available for competing hosted services, competing white-label products, competing SaaS offerings, or other uses not permitted by the PolyForm Shield License.
For commercial licensing, contact contact@AdvancedDigitalMarketingLTDA.com.
See COMMERCIAL.md.
Copyright (C) 2026 Advanced Digital Marketing LTDA.