cd /news/ai-products/building-civicgemma-a-tamper-evidentโ€ฆ ยท home โ€บ topics โ€บ ai-products โ€บ article
[ARTICLE ยท art-161412] src=dev.to โ†— pub= topic=ai-products verified=true sentiment=โ†‘ positive

Building CivicGemma: A Tamper-Evident E-Voting Microservices Platform with Gemma 4 ๐Ÿ—ณ๏ธ

A developer built CivicGemma, an open-source microservices e-voting pilot for local body elections, combining Java 21 and Spring Boot 3.4.2 services, an Angular 22 frontend, and Google's open-weights Gemma 4 multimodal model. The platform uses a database-per-service architecture with a compound unique index and SHA-256 ballot sealing to prevent double voting and produce tamper-evident receipts, while Gemma 4 handles voter ID image verification and multilingual manifesto summaries in English, Hindi, and Odia.

by read4 min views1 publishedOct 31, 2026

During Hacktoberfest Hack Day Bhubaneswar ร— DatrixLabs, I built CivicGemma โ€” an open-source, full-stack microservices e-voting pilot system designed specifically for local body elections (Panchayats, Municipalities, and Wards).

It combines Java 21 & Spring Boot 3.4 microservices, Angular 22, and Gemma 4 multimodal AI to deliver double-voting prevention, cryptographic SHA-256 ballot sealing, and multilingual voter assistance.

Grassroots democracy is where policy directly impacts daily life โ€” from local roads to sanitation and water supply. However, local body elections face unique logistical hurdles:

We asked: Can we build a transparent, auditable, and accessible digital voting platform that guarantees ballot integrity while empowering voters with AI?

That was the birth of CivicGemma.

Rather than building a monolithic prototype, we architected CivicGemma around the Database-per-Service pattern using Spring Cloud 2024 and Spring Boot 3.4.2:

             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
               โ”‚  Angular 22 Frontend    โ”‚
               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚ HTTP / REST
                            โ–ผ
               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
               โ”‚   Spring Cloud Gateway  โ”‚ (Port 8080)
               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚ lb://

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”

โ–ผ โ–ผ โ–ผ โ–ผ โ–ผ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Auth Service โ”‚โ”‚Voter Serviceโ”‚โ”‚Voting Serviceโ”‚Result Serviceโ”‚Audit Serviceโ”‚ โ”‚ (Port 8086) โ”‚โ”‚ (Port 8081) โ”‚โ”‚ (Port 8084) โ”‚โ”‚ (Port 8085) โ”‚โ”‚ (Port 8087) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ [Auth DB] [Voter DB] [Voting DB] [Result DB] [Audit DB]

Auth, Voter, Election, Candidate, Voting, Result, and Audit. In electronic voting, preventing race conditions (e.g., clicking "Vote" simultaneously across multiple tabs) is paramount. We implemented a three-tier defense:

if (voteRepository.existsByElectionIdAndVoterId(dto.getElectionId(), dto.getVoterId())) {
    throw new IllegalStateException("Voter has already cast a ballot.");
}

Database Engine Constraint (The Hard Wall): We enforce a compound unique index constraint at the database level:

ALTER TABLE votes ADD CONSTRAINT uk_election_voter UNIQUE (election_id, voter_id);

Cryptographic SHA-256 Ballot Sealing: Every ballot generates a tamper-evident digital seal returned to the voter as a verifiable receipt:

String rawData = voterId + ":" + electionId + ":" + candidateId + ":" + timestamp + ":" + UUID.randomUUID();

MessageDigest digest = MessageDigest.getInstance("SHA-256");

byte[] hashBytes = digest.digest(rawData.getBytes(StandardCharsets.UTF_8));

// Returns 64-character hexadecimal receipt hash

๐Ÿค– Core Innovation #2: Gemma 4 Multimodal Civic AI

We leveraged Google's open-weights Gemma 4 model to solve two real-world accessibility challenges:

1. Multimodal Voter ID (EPIC) Verification

Elderly or rural voters can upload an image of their Electors Photo Identity Card (EPIC). Gemma 4's vision capabilities inspect the card, verify document legibility, extract the identifier, and cross-validate with the voter-service registry.

2. Multilingual Manifesto Explainer

Local voters can ask natural language questions in English, Hindi, or Odia:

"Who is running in Ward 12?"
"Summarize Candidate Arjun Sharma's key promises in 3 bullet points."
"Which candidate has promised better water drainage?"

Gemma parses structured candidate manifestos and delivers impartial, concise summaries.

๐Ÿ› ๏ธ The Tech Stack
Domain  Technologies
Backend Java 21 LTS, Spring Boot 3.4.2, Spring Cloud 2024 (Eureka, Gateway, OpenFeign)
Frontend    Angular 22 (Standalone Components, SSR, Tailwind CSS)
Databases   MySQL (Isolated schema per microservice)
AI / ML Google Gemma 4 / Gemini API
Security    Stateless JWT (HMAC-SHA256), BCrypt, SHA-256
DevOps  Maven Multi-Module, Automated Batch Launchers (start-all.bat)

๐Ÿง— Challenges Faced & Lessons Learned
1. The JDK Compiler vs. Lombok Dilemma

During compilation, we hit a compiler error:

Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTag :: UNKNOWN

We discovered that the host environment was compiling with bleeding-edge JDK 25/26, which introduced breaking internal changes to com.sun.tools.javac.code.TypeTag that broke annotation processors like Lombok. We diagnosed and resolved this by pinning our toolchain to Eclipse Temurin JDK 21 LTS, restoring clean, reproducible builds.

2. Distributed State vs. Network Partitions

When voting-service records a ballot, it must sync hasVoted = true with voter-service. While OpenFeign handles synchronous calls gracefully, a network partition requires resilience. We architected fallback exception handlers and designed the schema so that the ballot ledger remains authoritative even if the voter metadata service experiences latency.

๐Ÿ”ฎ What's Next for CivicGemma?
Zero-Knowledge Proofs (ZKP): Implementing zk-SNARKs to achieve complete ballot unlinkability while mathematically guaranteeing eligibility.
Consortium Blockchain (Hyperledger Fabric): Moving the audit log service onto a distributed ledger so no single administrative authority can modify election logs.
Offline Polling Station Sync: Edge-caching for rural booths with intermittent connectivity.
๐Ÿ™ Acknowledgements

Huge thanks to Major League Hacking (MLH), DatrixLabs, and the Hacktoberfest community for organizing this hackathon!

GitHub Repository: https://github.com/hira8969/E-Voting-Pilot-System-for-Local-Body-Elections
Live Demo Video / Project Link: https://lnkd.in/p/dKgcisNt

Drop a โค๏ธ if you found this interesting, and leave your thoughts on digital voting in the comments!

---

### 4. Optional Polish:
- **Cover Image:** You can click the **โœจ Generate Image** button at the top to let DEV generate an AI cover banner for your post.
- **Preview:** Click the **Preview** tab next to "Edit" to see how clean the article looks before publishing.
- Click **Publish** (blue button at the bottom left) when you're ready!
โ”€โ”€ more in #ai-products 4 stories ยท sorted by recency
โ”€โ”€ more on @civicgemma 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain โ€” perfect for shipping the agent you just read about.

$git push zahid main
โ†’ Live at https://your-agent.zahid.host โœ“
Get free account โ†’ Pricing
from โ‚ฌ0/mo ยท no card required
LIVE [news/building-civicgemma-โ€ฆ] indexed:0 read:4min 2026-10-31 ยท โ€”