P-01
Fim da Escala 6x1
The platform behind the campaign to end Brazil's 6x1 work schedule: nationwide sign-ups, a volunteer network and 7-layer anti-bot defense
clientNational civil-society campaign to end the 6x1 work schedule
Digital platform for Brasil Quer Mais Tempo, the campaign that rallied Brazil to end the 6x1 work schedule (six workdays for one day off), a change enacted as Constitutional Amendment 141/2026. Public site with time-lost and time-gained calculators, sign-ups for supporters, mothers and businesses, Mobilizer and Ambassador portals with a tree-shaped referral network, the Brasil Vai Parar national day of action and a 26-screen admin panel. Supabase backend with 44 edge functions, 125 RLS policies and a quarantine system that tells bots from real supporters without blind blocking.
- react
- supabase
- postgres
- rls
- edge
- anti-bot
- rate-limiting
- pg-cron
- crm
- lgpd
01Overview
The 6x1 schedule (six days of work for one day off) was daily life for millions of Brazilian workers. The Brasil Quer Mais Tempo ("Brazil wants more time") campaign organized public pressure to end it. The amendment passed the Chamber of Deputies in May 2026 (461 to 19 in the second round) and the Senate in October (75 to 1), and was enacted as Constitutional Amendment 141/2026: a 5x2 schedule within 60 days and the workweek going from 44 to 40 hours over 14 months, with no pay cut. This project is the campaign's digital platform, live from the start of the mobilization to the final stretch.
One system covers the public campaign site, the sign-up forms and a two-tier volunteer network: Mobilizers, who spread the campaign through a personal link, and Ambassadors, who build and track their own referral network.
Behind the public site is a 26-screen admin panel. The coordination team uses it to follow sign-ups by region, manage volunteers, review suspicious records, run live broadcasts and organize Brasil Vai Parar ("Brazil will stop"), the national day of action on June 30. Sign-ups are also synced to the mobilization CRM the team already used for outreach and segmentation.
The platform stayed live for the whole campaign, through traffic spikes and automated sign-up attacks. Much of the engineering went into telling people and bots apart without turning away real supporters.
02The problem
- A cause that goes viral. Ending 6x1 became a national conversation, and every news cycle brought a new wave of sign-ups. A viral campaign packs thousands of sign-ups into a few hours. The form can't fail or slow down at the peak.
- Automated abuse. Public sign-up forms attract scripts that inflate numbers or pollute the database. Blocking too aggressively has a cost too: reCAPTCHA v3 misfires a lot on mobile.
- A referral network people can trust. Mobilizers and Ambassadors compete on leaderboards. Without validation, referral codes and clicks can be forged.
- CRM integration. The CRM API allows about 4 requests per second and fails intermittently. No sign-up may be lost on the way.
- Many audiences, one cause. Workers, mothers, business owners who had already dropped 6x1, volunteers and the coordination team each needed their own way in, all feeding the same database.
03The solution
- Public site: landing page, downloadable materials, sign-up pages per profile (supporter, collection point, mothers against 6x1) and legal pages (terms, privacy, consent).
- 6x1 calculators: the time lost calculator shows how many days of their life a person has worked extra under 6x1 (52 days a year compared to 5x2), and the time gained one shows how many days off ending the schedule gives back. Both generate a shareable image, and a "mission" version turns the result into an outreach task.
- Companies that dropped 6x1: sign-up and showcase for business owners who had already switched schedules and backed the change, with their own WhatsApp group.
- Supporter sign-up: WhatsApp validation (10–11 digits, with support for international numbers and people living abroad), area-code ↔ state consistency check and automatic routing to the right regional WhatsApp group.
- Mobilizer portal: personal referral link, results dashboard, leaderboard and tips.
- Ambassador portal: tree-shaped referral network with child ambassadors and a consolidated "super ambassador" view, computed with a recursive CTE in Postgres.
- Admin panel: per-profile dashboards (bar charts and progress bars only), consolidated leaderboard, UTM analytics, WhatsApp groups, collection points, admin management, audit trail, login and integration health, a quarantine queue and CRM reconciliation tools.
- The Chamber vote, live: the
/votacaopage covered the Chamber of Deputies floor vote on the amendment (May 27–28, 2026), with a live stream and real-time commentary. The module was built on May 25–26 and was live on vote day. It had a live page with CTAs and a timeline that a dedicated panel edits in real time, lead capture during the stream and sign-up for re-broadcasters. - Brasil Vai Parar (June 30): submission and moderation of in-person events across the country, an event map and attendance confirmation.
- Official platform of the campaign to end the 6x1 schedule, which ended in Constitutional Amendment 141/2026 (461–19 in the Chamber, 75–1 in the Senate)
- Time-lost and time-gained calculators for 6x1 (52 days a year), with a ready-to-share image
- Chamber-vote broadcast module built in two days and live on vote day
- 7-layer anti-bot defense with three-tier quarantine (strong, medium, weak) instead of blind blocking
- 125 RLS policies across 31 tables; direct inserts into the supporters table denied with WITH CHECK (false)
- Public leaderboards served from security_invoker views exposing only first name and code
- Resilient sync with a CRM capped at ~4 req/s: retry on 429, pending queue and pg_cron reprocessing every 5 min
- Tree-shaped referral network resolved with a recursive CTE, codes validated by trigger
- Per-minute sign-up spike alert with cooldown, driven from the database





04Architecture
Read the diagram as a list (18 components, 20 connections)
Components
- Clients: Public site<br>landing · calculators · sign-ups, Mobilizer portal<br>personal link · ranking, Ambassador portal<br>referral tree, Admin panel<br>26 screens · quarantine · audit
- Static hosting: React 18 + Vite SPA<br>63 lazy routes · GTM
- Supabase Edge Functions · Deno (44): register-*<br>7 anti-bot layers, login<br>reCAPTCHA v2 + rate limit, manage-* / export-*<br>getClaims + has_role, sync / retry / purge<br>CRM, signup-spike-alert
- Postgres: 31 tables · 125 RLS policies<br>122 SQL functions · 12 triggers, *_public views<br>security_invoker, pg_cron + pg_net<br>1 min · 5 min, Auth · user_roles<br>has_role() SECURITY DEFINER
- External services: reCAPTCHA v2 / v3, Mobilization CRM<br>REST API · ~4 req/s, Resend<br>transactional email, Email validation
Connections
- Public site<br>landing · calculators · sign-ups → React 18 + Vite SPA<br>63 lazy routes · GTM
- Mobilizer portal<br>personal link · ranking → React 18 + Vite SPA<br>63 lazy routes · GTM
- Ambassador portal<br>referral tree → React 18 + Vite SPA<br>63 lazy routes · GTM
- Admin panel<br>26 screens · quarantine · audit → React 18 + Vite SPA<br>63 lazy routes · GTM
- React 18 + Vite SPA<br>63 lazy routes · GTM → register-*<br>7 anti-bot layers (anon key + JWT)
- React 18 + Vite SPA<br>63 lazy routes · GTM → login<br>reCAPTCHA v2 + rate limit
- React 18 + Vite SPA<br>63 lazy routes · GTM → manage-* / export-*<br>getClaims + has_role
- React 18 + Vite SPA<br>63 lazy routes · GTM → *_public views<br>security_invoker (RLS)
- register-*<br>7 anti-bot layers → 31 tables · 125 RLS policies<br>122 SQL functions · 12 triggers (service_role)
- register-*<br>7 anti-bot layers → reCAPTCHA v2 / v3
- login<br>reCAPTCHA v2 + rate limit → reCAPTCHA v2 / v3
- manage-* / export-*<br>getClaims + has_role → Auth · user_roles<br>has_role() SECURITY DEFINER
- manage-* / export-*<br>getClaims + has_role → 31 tables · 125 RLS policies<br>122 SQL functions · 12 triggers
- sync / retry / purge<br>CRM → Mobilization CRM<br>REST API · ~4 req/s
- sync / retry / purge<br>CRM → 31 tables · 125 RLS policies<br>122 SQL functions · 12 triggers
- pg_cron + pg_net<br>1 min · 5 min → sync / retry / purge<br>CRM (5 min)
- pg_cron + pg_net<br>1 min · 5 min → signup-spike-alert (1 min)
- signup-spike-alert → Resend<br>transactional email
- manage-* / export-*<br>getClaims + has_role → Resend<br>transactional email
- manage-* / export-*<br>getClaims + has_role → Email validation
The app is a static SPA. Non-sensitive reads go straight to Postgres through Supabase's REST API, always under RLS. Every sensitive write (sign-ups, login, user management, exports) goes through one of 44 Deno edge functions, which validate input and apply the defenses before writing with the service key. Scheduling lives in the database (pg_cron + pg_net), so there is no separate job server.
05Under the hood
- Postgres (Supabase): 31 tables, 176 versioned migrations, 125 RLS policies, 122 SQL functions and 12 triggers.
- SQL functions do the heavy lifting for the admin panel: leaderboards, per-city counts, UTM analytics, quarantine triage, login statistics and a security scan report. Almost all are
SECURITY DEFINERwith a pinnedsearch_pathand an internal role check. - Triggers generate unique referral codes, keep referral counters up to date and validate the referral code on every recorded click (an unknown code makes the insert fail).
- Referral tree: the root of each ambassador tree is resolved with
WITH RECURSIVE, and direct and indirect totals are served over RPC. - Scheduled jobs:
- every minute, a sign-up spike detector (email alert with a 10-minute cooldown);
- every 5 minutes, a retry of the CRM sync queue, looping with a 50 s ceiling to stay under the runtime timeout.
- CRM integration: edge-function sync with retry on 429, a pending queue, batched admin backfill (
an_backfill_runs/an_backfill_items), export staging and count reconciliation. Quarantined records are never pushed to the CRM.
- React 18, Vite 5 and TypeScript, with Tailwind CSS and shadcn/ui (Radix).
- 65 routes, 63 of them lazy-loaded, plus Vite
manualChunks. - Three authenticated layouts (Admin, Mobilizer, Ambassador). The role check happens in the layout and again in the backend.
- Forms on react-hook-form + zod, with phone masks and Portuguese messages. Data fetching through TanStack Query.
- Semantic design tokens (color, radius, shadow) as CSS variables, with no hard-coded colors in components, and separate desktop and mobile layouts.
- Analytics goes through a single
trackEvent(), with SPA pageviews from aRouteTrackerand a fixed GTM event taxonomy.
- The frontend is hosted and published through Lovable's deploy platform, on custom domains.
- The backend runs on managed Supabase: migrations and edge functions deploy automatically on every push to the main branch.
- From June 2026 the workflow moved to plain Git: feature branches, small PRs (29 in the repo) and conventions written down in a versioned
CLAUDE.md(security, design and naming rules). - Secrets live in Supabase's vault. The repo only has a
.env.example, and the only keys in code are the publicanonones.
06Security
8 attacks considered, 8 defenses in production.
Scripts that flood forms, inflate numbers or sweep the site for openings.
A script registers thousands of fake supporters to inflate numbers
Honeypot, 3 s minimum fill time, per-IP/domain/UA rate limits, area-code check and reCAPTCHA v3; graded signals send the record to quarantine, out of the leaderboard and the CRM
A mass attack goes unnoticed until someone checks the panel
A per-minute pg_cron job checks volume and suspicious sign-ups and emails the team, with a 10-minute cooldown
Skipping the interface to talk straight to the database or API with the public key in hand.
Write straight into the supporters table with the public key, skipping the defenses
RLS insert policy WITH CHECK (false) for anon and authenticated; sign-ups only enter through the edge function
Brute force, rogue account creation, password reset and account takeover.
Brute force and credential stuffing on the portals
Pre-login edge function with reCAPTCHA v2, 5 attempts per IP and 8 per email, 429 with Retry-After and telemetry in login_attempts
Abuse password reset for spam or enumeration
Capped at 3 resets per email per hour, with the redirect pinned to the production domain
Someone with some access trying to get more: becoming admin, reading what they shouldn't, keeping revoked access.
A mobilizer tries to promote themselves to admin by editing their profile
Roles live in user_roles, apart from the profile, checked by has_role() SECURITY DEFINER; edge functions validate getClaims and the role before using the service key
Enumerating who is in the base, scraping personal data, tying questions to people, extracting secrets.
Scrape names, emails and phones through the public leaderboard API
The leaderboard reads from security_invoker views exposing only first name, code and count
Fiddling with counts, wiping the base, editing history or denying what was authorized.
Forge clicks and referrals to climb the leaderboard
A trigger rejects clicks with unknown codes and the referral counter is maintained by the database, not the client
Authentication. All three portals use Supabase Auth. Login first goes through an edge function that requires reCAPTCHA v2 (checkbox), records the attempt in login_attempts with a hashed IP, and returns 429 with Retry-After after 5 attempts per IP or 8 per email inside the window. The password never passes through that function: it only grants permission, and authentication still runs in the official Supabase client. Password resets are capped at 3 per email per hour and always redirect to the production domain. System-generated admin passwords are 16 characters drawn with crypto.getRandomValues.
Authorization. Roles live in a separate user_roles table (enum admin | moderator | ativista), never on the user profile. Checks go through has_role(), a SECURITY DEFINER function that avoids RLS recursion. Privileged edge functions validate the JWT with auth.getClaims() (17 functions) and look up the role in user_roles before doing anything with the service key (20 functions). Admin actions are written to admin_audit_log, which has its own analytics screen.
RLS. All 31 tables have RLS enabled. The supporters table carries an explicit WITH CHECK (false) insert policy for anon and authenticated, so sign-ups only come in through the edge function. Public leaderboards read from supporters_public / profiles_public views with security_invoker, which expose only first name, referral code and referral count. anon gets SELECT only on public-content tables (live page, events).
Anti-bot on sign-ups (13 endpoints with a honeypot, 11 with reCAPTCHA v3). Supporter sign-up stacks:
- a hidden honeypot;
- a minimum fill time (3 s);
- a per-IP rate limit (SHA-256 hash, 15/h, returns 429);
- a per-email-domain rate limit;
- a per-User-Agent rate limit;
- an area-code ↔ state check;
- a reCAPTCHA v3 score.
Instead of a hard block, signals are graded as strong (script User-Agents such as curl/python-requests, very low score), medium (invalid token, which runs at about 50% false positives on mobile) and weak (out-of-state area code, domain burst). The rule: one strong signal, or one medium plus anything else, sends the record to quarantine. Weak signals alone are only logged. Bots stay out of the numbers and out of the CRM, and a real person with a bad signal keeps their sign-up: an admin reviews the queue and releases records in bulk.
Detection and response. A per-minute cron job checks the volume of sign-ups and of suspicious ones and emails the team. The panel shows recurring IPs, suspicious logins and a security scan, and has purge routines that remove attack records from the database and from the CRM.
LGPD (Brazil's data protection law). There are dedicated consent, privacy and terms pages. IPs are stored hashed. Users can delete their own account through an authenticated edge function. Full data exports are admin-only and go through an edge function.
07Technical challenges
Quarantine instead of blocking
The first version blocked on reCAPTCHA score alone, and real supporters on mobile were rejected. The fix was to split detection from decision: every sign-up stores its reasons (flag_suspect_reason) and a three-tier rule decides what happens. For past data, retroactive SQL reclassification (classify_retro_attack_*, bulk_unflag_*) released in bulk the humans held back by weak signals. Each operation has a matching count_* function, so the admin can see the impact before applying it.
Reliable sync with a slow CRM
The CRM allows about 4 req/s and returns 429 under load. Sync is attempted inline with one retry. Failures stay pending, and a job every 5 minutes works through them in a loop, pausing between calls and stopping at 50 s per run. For larger drift, there is batched backfill with control tables and a reconciliation screen that compares counts on both sides.
A fraud-resistant referral network
Codes are generated by a trigger (fixed prefix and length), clicks with an unknown code are rejected by the database, the counter is maintained by a trigger rather than by the client, and the ambassador tree is resolved with a recursive CTE.
An admin panel that doesn't leak data
Twenty-six screens query personal data. Instead of opening tables to authenticated, the panel calls SECURITY DEFINER RPCs that check has_role() and return ready-made aggregates. Full exports go through a role-checked edge function.
08Results
- The official platform of the campaign to end the 6x1 schedule, live through the whole mobilization, which ended with Constitutional Amendment 141/2026, enacted on October 16, 2026 after votes of 461 to 19 in the Chamber and 75 to 1 in the Senate. The win belongs to the movement as a whole; the platform was the digital infrastructure that organized sign-ups.
- The platform covered every decisive moment: the broadcast module was live for the Chamber vote (May 27), then came the national day of action (June 30) and the final stretch in the Senate.
- 3,476 commits between April and October 2026, most of them (≈3,300) in April and May.
- 44 edge functions, 176 migrations, 125 RLS policies and 122 SQL functions.
- 44
- edge functions
- 176
- migrations
- 31
- tables
- 125
- RLS policies
- 122
- SQL functions
- 65
- routes
- 26
- admin screens
- 3,476
- commits
- ≈62k
- TS/TSX lines
- ≈13.5k
- SQL lines
how we measured
ls supabase/functions (one folder per function)
how we measured
ls supabase/migrations | wc -l
how we measured
distinct CREATE TABLE in the migrations; 31 ENABLE ROW LEVEL SECURITY
how we measured
grep -c 'CREATE POLICY' in the migrations (19 DROP POLICY counted separately)
how we measured
distinct CREATE [OR REPLACE] FUNCTION in the migrations
how we measured
path= in src/App.tsx (63 with React.lazy)
how we measured
child routes of /admin in src/App.tsx, including the index
how we measured
git rev-list --count HEAD (Apr–Oct 2026)
how we measured
wc -l on tracked .ts/.tsx files (14,978 + 47,469)
how we measured
wc -l on supabase/migrations/*.sql
09Timeline
- Apr 2026
Kickoff: React SPA + Supabase and supporter sign-up to end 6x1, synced to the CRM
- Apr 2026
Mobilizer and Ambassador portals with referral network
- Apr 2026
Anti-bot quarantine, pg_cron spike alerts and external email validation
- Apr 2026
Time-lost and time-gained calculators for ending 6x1
- May 2026
Chamber vote on the amendment streamed live on the platform (passed 461–19)
- Jun 2026
Brasil Vai Parar: June 30 day of action to end 6x1, with an event map and attendance confirmation
- Jun 2026
Move to a Git workflow with PRs and versioned conventions
- Sep 2026
Sign-up opened to people living abroad, with international phone numbers
- Oct 2026
Senate passes it 75–1 and Congress enacts Constitutional Amendment 141/2026, ending the 6x1 schedule
10Stack
- React 18
- Vite 5
- TypeScript 5
- Tailwind CSS 3
- shadcn/ui (Radix)
- TanStack Query
- react-hook-form
- zod
- Recharts
- Supabase Edge Functions (Deno)
- PL/pgSQL
- PostgreSQL (Supabase)
- Row Level Security
- pg_cron
- pg_net
- Supabase Storage
- Lovable (hosting + deploy)
- Supabase gerenciado
- GitHub
- Supabase Auth
- user_roles + has_role()
- auth.getClaims
- reCAPTCHA v2/v3
- honeypot
- rate limiting em Postgres
- hash de IP (SHA-256)
- quarentena
- audit log
11Tech sheet
- type
- campaign platform · end of 6x1
- stack
- React 18 · Vite · Deno edge
- db
- Postgres · 31 tables · 125 policies
- auth
- Supabase Auth · reCAPTCHA v2
- anti-bot
- 7 layers · 3-tier quarantine
- jobs
- pg_cron · 1 min / 5 min
- modules
- site · mobilizer · ambassador · admin
- status
- in production · EC 141/2026 ✓
Sign-ups, volunteers and a mobilization CRM on one database, with Postgres deciding who is who.
Sign-ups, activists and CRM on one base: every person becomes a single profile, and the database decides who scores.
Public sign-ups, a referral network and a CRM on a database that doesn't trust its own public key.
Want a system like this for your operation?
Node designs, builds and protects tailor-made platforms for campaigns, elected officials and movements.

TECHNOLOGY AND POLITICAL INTELLIGENCE
© 2026 NODE. All rights reserved.