Executive Summary: Problem, Solution & Results
| Dimension | Project Insight |
|---|---|
| Civic Challenge | Severe citizen barrier to accessing and scrutinizing profiles, records, and proposals of hundreds of subnational candidates in an agile, neutral, and localized format over slow mobile connections. |
| Engineering Solution | High-speed civic platform built with Astro and React 19 on GitHub Pages ($0 hosting costs), GeoJSON cartography via Leaflet with SSR-bypassed chunking, client-side Ray-Casting geolocation, and Appwrite data graph. |
| Measurable Impact | Zero fixed server costs for the civic foundation, instant sub-second page transitions without database roundtrip lag, zero-latency fuzzy client search, and full territorial coverage of Bolivian municipalities and departments. |
Engineering Stack & Frontend Tooling
Static Site Generator (SSG) framework using Islands Architecture for zero unnecessary JavaScript overhead.
Dynamic interactive islands powering the dashboard, useReducer search state, and cartographic views.
Styling engine with `@theme` CSS tokens, high-contrast civic terracotta palette (#bf4a18), and dark mode.
Interactive mapping engine optimized with Vite SSR stubs and client-side dynamic lazy loading.
Backend BaaS structured as a semantic Knowledge Graph (Entities, Claims, Qualifiers, and References).
Strict data modeling for electoral entities, GeoJSON contracts, and territorial index structures.
Accessible UI primitives for dropdown filters, modal dialogs, and ergonomic pagination controls.
Asynchronous state management and background revalidation for candidate and authority datasets.
1. Context: Subnational Elections, Civic Impact & Launch
Ahead of Bolivia’s subnational elections (electing Governors, Mayors, Councilors, and Departmental Assembly Members), Fundación ARU, the UMSA Scientific Society of Statistics (SOCIEST), and LABTECNOSOCIAL partnered to build an open, accessible civic transparency platform.
The project was conceived as a pro-bono civic initiative, driven by a desire to apply modern engineering to democratic empowerment. The platform successfully launched into production during the election cycle, enabling voters across all 9 departments and 330+ municipalities to audit candidate track records, local platforms, and scientific polling studies.
The Challenge: 100% Static on GitHub Pages
The main constraint was operational: the platform had to be hosted entirely on GitHub Pages. This meant:
- No server-side Node.js runtime to process queries on the fly.
- No live database accessible through dynamic backend endpoints.
- All interactive filtering, candidate search, and geospatial map rendering had to run either in the client’s browser or be pre-computed at build time.
I contributed as Frontend Developer, spearheading the UI architecture, client-side geospatial algorithms, component systems with Astro and React 19, and integration with the Appwrite knowledge graph.
2. Technical Decisions & Engineering Challenges Overcome
2.1 Smooth Interactive Mapping on Static Architecture
When pre-rendering web applications on static platforms, interactive mapping libraries like Leaflet often fail because they expect a live browser window object during build time.
To solve this cleanly:
- At build time: Designed a lightweight custom Vite plugin (
leafletSsrStubPlugin) that substitutes Leaflet dependencies with minimal no-op stubs during Astro’s SSR pass, allowing static HTML compilation withoutwindow is not definedruntime exceptions. - Granular Chunk Isolation (Chunk Splitting): Configured
rollupOptions.manualChunksto split Leaflet (leaflet-vendor), React runtime (react-vendor), and the Appwrite SDK (appwrite-vendor) into isolated packages, keeping non-map pages featherlight. - In the browser: The full interactive cartography engine downloads on-demand (lazy loading) only when the user navigates to the map section.
2.2 Instant Territory Detection with Zero Cloud Mapping Costs
To immediately show voters the correct local candidates through GPS or interactive map selection, conventional architectures require maintaining a dedicated geospatial database server (PostGIS) with recurring monthly hosting fees.
I shifted spatial calculation entirely into the client’s browser:
- Instant bounding box pruning: The client eliminates 95% of national municipal boundaries in under 1 millisecond by checking coordinate boundaries.
- Geometric intersection calculation (Ray-Casting): For candidate areas, it mathematically checks whether the user’s location falls within the municipality’s geographic perimeter.
- Resilient CI/CD Indexing: The pre-indexed dataset (
municipalities-index.json) is generated at build time with an automated fallback mechanism that survives Cloudflare rate-limits or GitHub Actions network hiccups.
This resolved the voter’s local electoral ballot instantly, with zero network lag and zero server infrastructure costs.
2.3 Layered Asynchronous Authority Streaming
Retrieving candidates across municipal, provincial, and departmental tiers from a graph database often causes noticeable rendering delays if all tiers are awaited simultaneously.
We engineered a Hierarchical Streaming Pipeline (getAuthoritiesByMunicipalityStreaming):
- Level 0 (Municipality): Fetches and immediately emits local candidates (
onBatch(..., replace=true)), rendering mayor and councilor cards without delay. - Levels 1 and 2 (Department & Region): Incrementally resolves and streams gubernatorial and departmental candidates (
onBatch(..., replace=false)), progressively enriching the view without interrupting user interaction.
2.4 Polymorphic Entity Rendering with Code-Splitting
The underlying knowledge graph stores polymorphic data across diverse entity models. To prevent bloated components and brittle conditionals:
- Built
EntityRenderer: an orchestration layer combining TypeScript discriminated unions with dynamicReact.lazyandSuspense. - Automatically code-splits and renders 8 distinct entity archetypes:
TERRITORIO,INSTITUCION,PARTIDO_POLITICO,ENCUESTA,CASA_ENCUESTADORA,EDUCACION,ROL, andPERSONA.
2.5 Polling Audit & Survey Verification System
A core pillar of the platform is combating electoral disinformation:
- Direct integration with verified Polling Firms and registered Electoral Studies (e.g., Ciesmori, Focaliza, IPSOS).
- Transparent presentation of methodology cards: sample sizes, margins of error, confidence intervals, field dates, and territorial coverage.
- Normalized voting intention charts allowing citizens to compare polling trends and scientific rigor with full data provenance.
2.6 Client-Side Weighted Fuzzy Search Scoring
To ensure voters could locate candidates and political parties despite typos, phonetic misspellings, or missing accents:
- Unicode Normalization: Text was normalized using
NFDdecomposition to strip diacritics ([\u0300-\u036f]). - Weighted Relevance Scoring:
- Exact name match:
+1000 pts - Prefix match (starts-with):
+500 pts - Partial containment (includes):
+100 pts - Acronym and party alias match:
+80 pts - Multi-word compound match:
+200 pts
- Exact name match:
- Three-Tier Caching Architecture:
RAM Memory (Map) ──> LocalStorage (TTL 24h) ──> Static CDN Fetch
2.7 Visual Stability and Smooth Hydration Transition
To eliminate visual flicker and jarring layout shifts as dynamic React islands hydrated over Astro’s static shell:
- In
index.astro, an absolutely positioned static skeleton renders instantly on initial paint. - The
DashboardWrapperisland (client:load) hydrates in the background. - Upon initial render completion, React outputs
data-dashboard-ready="true". A lightweight Vanilla JS observer triggers a smooth CSS opacity fade-out and physically removes the skeleton from the DOM, preventing visual jumps during data load.
3. Data Architecture: Semantic Knowledge Graph in Appwrite
The Appwrite backend was structured not as disjointed flat relational tables, but as a Semantic Knowledge Graph modeled after Wikidata conventions:
entities: Candidates, political parties, voting districts, and public offices.claims: Relational statements and associations (e.g., binding an individual to a political alliance via propertyP_IDand office roleinstance_of).qualifiersandreferences: Documented journalistic and statutory sources supporting each claim.
To navigate client-side rate limits, we implemented batch chunking (fetching in increments of 500 and 1,000 records) and in-memory relationship resolvers, displaying complete candidate hierarchies instantaneously.
4. Visual Identity & Design System
The visual framework was constructed on Tailwind CSS v4 around a clean, accessible civic aesthetic:
Sora VariableTypography: Selected for its geometric precision and superior readability when displaying district numerals, vote percentages, and dense name rosters on mobile devices.- Civic Identity Palette:
- Brand / Terracotta Primary (
#bf4a18): An institutional warm hue communicating democratic participation and civic commitment without political bias. - Soft Accents (
#cc6e4b/#d88e77): Peach and rust accents for active states, subtle boundaries, and micro-interactions. - Pure Neutral Background (
#fcfcfc): Crisp reading surface optimized for high-contrast viewing under outdoor sunlight on handheld devices. - Full Dark Mode: Deep charcoal surface (
oklch(0.145 0 0)) paired with delicate translucent borders (oklch(1 0 0 / 10%)).
- Brand / Terracotta Primary (
- Accessible Primitives: Modular filters, dialogs, and navigation built on Radix UI with fluid transitions (
tw-animate-css).
5. Key Takeaways
- Pre-computation is a superpower: Moving heavy data processing to the build step (generating spatial indices, simplifying polygon rings, and pre-calculating bounding boxes) allows a static site on GitHub Pages to deliver instant interactions with zero infrastructure costs.
- Understand your bundler: Knowing how Vite handles SSR modules let us resolve the Leaflet
windowcrash cleanly with a tiny custom plugin instead of brittle runtime hacks. - Frontend resilience against backend lifecycles: Temporary event-driven backends eventually get retired, but decoupled static frontends backed by pre-cached indices preserve working demos and architectural proof long after the campaign is over.




