Skip to content

andrewr303/ElectionAI

Repository files navigation

ElectionAI

The AI campaign intelligence platform built for modern candidates.

Opposition research. Debate prep. District analysis. Messaging. All automated. All in one place.

electionai.io

TypeScript React Supabase Vite Tailwind CSS License


Why ElectionAI?

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.


What It Does

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.


Screenshots

Command Center β€” personalized campaign dashboard with district terrain, demographics, and key metrics
Command Center β€” personalized campaign dashboard
Opponent Dossier β€” threat assessment with strengths, achilles heel, and recommended narrative
Opponent Dossier β€” threat assessment and vulnerability research
Debate Preparation β€” topic briefs with attack and pivot strategies for every issue
Debate Prep β€” topic briefs, attack/pivot strategies, mock simulator
District Intelligence β€” voter segments, historical election data, and demographic breakdown
District Intelligence β€” voter segmentation and historical results

Features

πŸ” Opposition Research Engine

Opponent Dossier

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.


πŸŽ™οΈ Debate Preparation Studio

Debate Preparation

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.


πŸ—ΊοΈ District Intelligence

District Intelligence

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.


πŸ“£ Message Lab

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.

πŸ“° Media Monitoring & Rapid Response

Real-time news alert tracking with sentiment analysis and one-click rapid response generation. Counter a news cycle before it sets.

πŸ”Ž Self-Opposition Research

Find your own vulnerabilities before your opponent does and generate preemptive response messaging. Know what's coming.

πŸ“Š Polling Analysis

Import and visualize polling data, track head-to-head trends, and access a polling landscape assessment for your race.

πŸ—‚οΈ Race Explorer

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.

πŸ“‹ Customizable Dashboard

Command Center Dashboard

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.


πŸ‘₯ Team Hub

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.

πŸ›‘οΈ Built for Trust

  • 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

Tech Stack

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

Architecture

Five-Agent Intelligence System

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

27 Specialized Edge Functions

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

Database Model

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

Access Control

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)

Repository Structure

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

Getting Started

Prerequisites

Installation

git clone https://github.com/andrewr303/election-ally-pro.git
cd election-ally-pro
npm install

Configuration

Create 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.

Database Setup

# Apply all migrations and the full schema
supabase db push

# Or manually: run public/schema.sql in the Supabase SQL editor

Start the Dev Server

npm run dev
# β†’ http://localhost:8080

Available Scripts

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

Development

Regenerating Database Types

When the schema changes, regenerate the typed Supabase client:

supabase gen types typescript --project-id <your-project-id> \
  > src/integrations/supabase/types.ts

Running Edge Functions Locally

supabase functions serve --env-file .env

Functions are available at http://localhost:54321/functions/v1/<function-name>.

Path Alias

@/ maps to src/ throughout the project:

import { useCampaign } from '@/hooks/useCampaign'
import { Button } from '@/components/ui/button'

Testing

npm run test          # single run
npm run test:watch    # watch mode

Tests use Vitest with Testing Library React. Test files live alongside the code they test or under src/test/.


Deployment

Lovable (default)

The project is preconfigured for Lovable. Connect your GitHub repo, set environment variables under Project β†’ Settings β†’ Environment, and every push to main deploys automatically.

Self-Hosted

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>

Roadmap

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.


Contributing

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.

  1. Fork the repo and create a branch from main
  2. Install dependencies: npm install
  3. Make your changes
  4. Run npm run lint and npm run test
  5. 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.


License

MIT β€” see LICENSE for details.


electionai.io Β· Built for the 2026 election cycle and beyond

About

Open-source AI campaign intelligence for modern political candidates. Automates opposition research, debate prep, district analysis, and messaging through a five-agent AI system, giving every campaign the strategic firepower of a top political firm. Built for the 2026 election cycle.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors