Opposition research. Debate prep. District analysis. Messaging. All automated. All in one place.
Running for office used to mean paying six figures for consultants who deliver research decks weeks after you need them. Incumbents and well-funded campaigns have always had a structural intelligence advantage β and challengers without that infrastructure lose.
ElectionAI closes that gap.
It's an open-source campaign war room that gives every candidate β from city council to statewide β the same caliber of AI-driven intelligence that previously only existed inside the most expensive political firms. Feed it your campaign context once. Get continuous, personalized briefings across every dimension of your race.
This project is open source and actively developed. If you're a candidate, consultant, engineer, or political operative interested in where this is headed β star the repo and watch for updates. A commercial offering with managed hosting, white-labeling, and premium data integrations is on the roadmap.
ElectionAI orchestrates a five-agent AI system around your specific campaign β your candidate profile, your opponent, your district, your race level β and delivers a continuous stream of actionable intelligence:
| You need... | ElectionAI delivers... |
|---|---|
| Know your opponent's weaknesses | Tier 1β4 opposition research with attack angles |
| Prepare for a debate | Topic briefs, pivot strategies, opening/closing drafts |
| Understand your district | Voter segmentation, demographics, persuasion strategies |
| Test your message | AI-scored A/B message variants across email, SMS, social |
| Monitor the news | Real-time media alerts with rapid-response generation |
| Find your own blind spots | Self-opposition research before your opponent does |
| Get strategic direction | Campaign synthesis and deployment recommendations |
No retainer. No waiting. No decks that arrive after the news cycle moves on.
Automated vulnerability discovery across eight categories β voting record, financials, policy, attendance, character, public statements, hypocrisy, and associations β each finding classified into a four-tier threat system:
- Tier 1 β Race-changing. Devastating if surfaced.
- Tier 2 β Serious. Requires a prepared response.
- Tier 3 β Moderate. Useful in the right context.
- Tier 4 β Minor. Background awareness only.
Every finding includes messaging angles, suggested debate pivots, a threat assessment (biggest strength, achilles' heel, recommended narrative), and a tie to your campaign's broader story.
A full debate prep workflow from zero to briefing doc: generate topic cards from opposition research, build attack/pivot strategy pairs, run a mock debate simulator with live AI coaching, draft opening and closing statements, and export a formatted briefing. Supports both quick prep and deep research modes.
Demographic breakdowns (age, race, education, income), voter segmentation with per-segment persuasion strategies, issue priority rankings, economic indicators, and historical election results β all contextualized to your specific race.
Generate message variants for any audience or channel, score them via AI, and run A/B tests across email, SMS, and social. Build a reusable message library your whole team can access.
Real-time news alert tracking with sentiment analysis and one-click rapid response generation. Counter a news cycle before it sets.
Find your own vulnerabilities before your opponent does and generate preemptive response messaging. Know what's coming.
Import and visualize polling data, track head-to-head trends, and access a polling landscape assessment for your race.
Browse 780+ tracked races across all 50 states in table, board, list, map, or calendar views. Filter by state, office level, and competitiveness. Drill into any race for full candidate and district context.
Thirteen configurable intelligence cards β win probability, days to election, top priorities briefing, fundraising comparison, polling trends, district terrain, media summary, recent alerts, debate readiness, and more. Arrange them to match how your team works.
Channel-based team collaboration (strategy, comms, oppo, field, urgent) with threaded discussions, emoji reactions, and read tracking β built directly into the platform so your war room doesn't live in a separate Slack.
- Ground Truth integration β curated verified facts anchor AI responses and prevent hallucination
- Row-Level Security β database-enforced data isolation; campaigns never see each other's data
- Response caching β 18-hour TTL on AI outputs for fast retrieval and cost efficiency
- Invite-code access control β controlled campaign onboarding
| Layer | Technology |
|---|---|
| Framework | React 18.3 + TypeScript 5.8 |
| Build | Vite 5.4 with SWC |
| Styling | Tailwind CSS 3.4 + shadcn/ui (60+ components) |
| Routing | React Router DOM 6.30 |
| Server state | TanStack React Query 5.83 |
| Forms | React Hook Form 7.61 + Zod 3.25 |
| Animations | Framer Motion 12.34 |
| Charts | Recharts 2.15 |
| Notifications | Sonner |
| Markdown | React Markdown 10.1 |
| Database | Supabase PostgreSQL (40+ tables, 18 migrations) |
| Auth | Supabase Auth with RLS enforcement |
| Edge Functions | 27 Deno functions on Supabase Edge |
| Testing | Vitest 3.2 + Testing Library React 16 |
| Linting | ESLint 9.32 |
The AI engine runs on Supabase Edge Functions with real-time streaming. Every agent receives full campaign context on each call β no generic answers.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ElectionAI Engine β
β Campaign context injected on every call β
βββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββ€
β Data β Communications β Opposition β Media β
β Intelligence β Agent β Research β Intelligence β
β β β Agent β Agent β
β Polling β Message gen β Tier 1β4 β News alerts β
β Demographics β A/B testing β 8 vuln cats β Sentiment β
β Voter segs β Tone tuning β Attack angles β Rapid resp. β
β Resources β Rapid response β Debate pivots β Earned media β
βββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββ€
β Strategic Command Agent β
β Synthesis Β· Deployment recs Β· Risk assessment β
β Coalition building Β· Cross-agent coordination β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
Ground Truth DB Β· AI Cache Β· Campaign Context
Beyond the main chat engine, discrete Deno functions power every feature:
| Function | Purpose |
|---|---|
generate-oppo-research |
Deep/quick opposition vulnerability discovery |
generate-message |
Audience-targeted message generation |
debate-research |
Topic research with attack/pivot strategy pairs |
generate-district-intel |
Demographic analysis and voter segmentation |
generate-self-oppo |
Self-vulnerability identification |
generate-rapid-response |
Counter-messaging generation |
enrich-candidate |
AI-powered candidate profile enrichment |
enrich-race |
Race intelligence enrichment |
scan-media |
News monitoring and sentiment analysis |
estimate-fundraising |
Fundraising analysis and projections |
analyze-race-field |
Competitive landscape analysis |
search-polling-data |
Polling data research |
parse-pdf |
Campaign document parsing |
bulk-import |
Race and candidate data ingestion |
get-ground-truths |
Verified fact retrieval for AI grounding |
rank-candidates / rank-races |
Competitiveness ranking |
40+ normalized PostgreSQL tables across four dependency tiers, with RLS on every table and a separate AI response cache:
Tier 0 β profiles, user_roles, races, candidate_profiles, ai_prompts, ground_truth_collections
Tier 1 β campaigns, race_candidates, pending_enrichments, invite_codes
Tier 2 β opposition_research, chat_messages, messages, district_data, ai_cache,
polling_data, documents, dashboard_layouts, team_channels, personas, ads, speeches
Tier 3 β team_messages, team_channel_reads
Tier 4 β team_message_reactions
Four-tier role system enforced at both application and database level:
| Role | Access |
|---|---|
explorer |
Public race and candidate browsing |
approved |
Full campaign intelligence features |
consultant |
Multi-campaign portfolio management |
admin |
Full platform control (data import, enrichment approvals, user management) |
election-ally-pro/
βββ public/
β βββ logo.png # ElectionAI logo
β βββ schema.sql # Full database schema (1,489 lines)
βββ src/
β βββ pages/ # 35 page components
β β βββ Index.tsx # Public landing page
β β βββ Dashboard.tsx # Customizable campaign dashboard
β β βββ Opposition.tsx # Opposition research engine
β β βββ DebatePrep.tsx # Debate preparation studio
β β βββ Messages.tsx # Message lab + A/B testing
β β βββ Chat.tsx # AI chat interface
β β βββ District.tsx # District intelligence
β β βββ ExploreRaces.tsx # Race explorer (780+ races)
β β βββ AdminPanel.tsx # Admin control panel
β β βββ ... # 25 additional pages
β βββ components/
β β βββ ui/ # 60+ shadcn/ui components
β β βββ admin/ # 15+ admin panel components
β β βββ dashboard/ # 13 configurable dashboard cards
β β βββ chat/ # Streaming chat interface
β β βββ debate/ # Debate prep workflow
β β βββ explore/ # Race explorer + map view
β β βββ team/ # Team collaboration
β β βββ onboarding/ # Campaign setup wizard
β βββ hooks/
β β βββ useAuth.tsx # Authentication context
β β βββ useCampaign.tsx # Campaign context + role detection
β β βββ useAICache.ts # AI response caching (18hr TTL)
β β βββ ...
β βββ lib/
β β βββ streamChat.ts # AI streaming logic
β β βββ backgroundTasks.ts # Task scheduling
β βββ integrations/supabase/ # Client + auto-generated DB types
βββ supabase/
βββ migrations/ # 18 versioned schema migrations
βββ functions/ # 27 Deno edge functions
βββ campaign-chat/ # Multi-agent orchestration
βββ _shared/ # Auth, error handling, web research utils
βββ ... # 25 specialized intelligence functions
- Node.js 18+ with npm (install via nvm)
- A Supabase project
- Supabase CLI (for edge functions and migrations)
git clone https://github.com/andrewr303/election-ally-pro.git
cd election-ally-pro
npm installCreate a .env file at the project root:
VITE_SUPABASE_URL=https://<your-project-id>.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=<your-anon-key>Both values are in your Supabase project under Settings β API.
# Apply all migrations and the full schema
supabase db push
# Or manually: run public/schema.sql in the Supabase SQL editornpm run dev
# β http://localhost:8080| Command | Description |
|---|---|
npm run dev |
Start dev server on port 8080 with HMR |
npm run build |
Production build |
npm run build:dev |
Development build for debugging |
npm run preview |
Preview the production build locally |
npm run lint |
Run ESLint |
npm run test |
Run tests once |
npm run test:watch |
Run tests in watch mode |
When the schema changes, regenerate the typed Supabase client:
supabase gen types typescript --project-id <your-project-id> \
> src/integrations/supabase/types.tssupabase functions serve --env-file .envFunctions are available at http://localhost:54321/functions/v1/<function-name>.
@/ maps to src/ throughout the project:
import { useCampaign } from '@/hooks/useCampaign'
import { Button } from '@/components/ui/button'npm run test # single run
npm run test:watch # watch modeTests use Vitest with Testing Library React. Test files live alongside the code they test or under src/test/.
The project is preconfigured for Lovable. Connect your GitHub repo, set environment variables under Project β Settings β Environment, and every push to main deploys automatically.
The frontend is a standard Vite SPA β deploy the dist/ output to any static host (Vercel, Netlify, Cloudflare Pages, etc.):
npm run build
# Deploy dist/Deploy edge functions via Supabase CLI:
supabase functions deploy --project-ref <your-project-id>This is the open-source foundation. The roadmap for a hosted commercial platform includes:
- Managed hosting β zero-config setup for non-technical campaigns
- Premium data integrations β FEC filings, voter file access, redistricting maps, live poll aggregation
- White-labeling β consultant-branded portals for political firms
- Team tiers β expanded collaboration features for larger campaign organizations
- Mobile app β native iOS/Android for field staff and rapid response
- API access β integrate ElectionAI intelligence into existing campaign tools
- Real-time monitoring β continuous background research with proactive alerts
Interested in a hosted version or using this commercially? Open an issue, start a discussion, or reach out via electionai.io. Early interest shapes what gets built first.
Contributions are welcome. This is an early-stage open-source project and there's plenty of surface area β from new AI features and data integrations to UI improvements and test coverage.
- Fork the repo and create a branch from
main - Install dependencies:
npm install - Make your changes
- Run
npm run lintandnpm run test - Open a pull request with a clear description
For significant changes, open an issue first to align on approach. If you're a political technologist, campaign operative, or developer with ideas for where this should go β please start a discussion.
MIT β see LICENSE for details.
electionai.io Β· Built for the 2026 election cycle and beyond




