How avhijay/secure-voting-system works
Project Type and Purpose
• SecureVote is a monolithic backend service built with Spring Boot 3+, exposing REST APIs for a large-scale, concurrent election/voting system.
• It implements a clean, layered architecture (Controllers → Service → Repository → Database), plus custom DSA modules (VoteTracker, VerificationQueue) for performance and integrity.
File Structure
• Top-level: pom.xml, Maven wrapper, src/main/java & src/main/resources, Flyway migrations under resources/db/migration.
• Java packages under com.votingSystem.secureVote:
• rest (API endpoints / Controllers)
• service & service/implementation (business logic)
• repository (Spring Data JPA interfaces)
• entity (JPA entities)
• dto (data transfer objects)
• security (Spring Security configuration, user details, auth context)
• dsa (custom data-structure modules: VerificationQueue, VoteTracker)
• GlobalExceptionHandler handles exceptions; application.properties configures DB & security.
README Insights
• Emphasis on thread-safe vote casting, audit logging (@Transactional), custom exception handling, and future DSA-driven optimizations (caching, duplicate prevention, ranking).
a. Main Components
• Clients (Web/Mobile UI, other services)
• Load Balancer / API Gateway (optional)
• SecureVote Service (Spring Boot application)
• Security Layer (filters, CustomUserDetailsService, SecurityConfig)
• REST Controllers (UserController, VoteController, etc.)
• Service Layer & DSA Modules (ElectionService, VoteService + VoteTracker, VerificationService + VerificationQueue)
• Repository Layer (JPA Repositories)
• Database (RDBMS with Flyway migrations)
• Audit Logging (AuditService → AuditRepository)
b. Relationships & Data Flow
• Clients → (HTTPS) → Security Layer → Controllers → Services → Repositories → Database
• VoteService invokes VoteTracker for deduplication; VerificationService enqueues into VerificationQueue → processed asynchronously
• AuditService logs each critical action to the Audit table in the same transactional context
c. Architectural Patterns & Principles
• Layered (Controller → Service → Repository)
• Transactional boundaries at Service layer (@Transactional)
• Dependency Injection (Spring)
• Separation of Concerns (security, business logic, persistence, DTO mapping)
• Modular DSA components for specialized processing
d. Key Technologies
• Spring Boot, Spring MVC, Spring Data JPA, Hibernate
• Flyway (db migrations), Maven
• Java Concurrency (thread-safety in DSA classes)
• PostgreSQL/MySQL (or chosen RDBMS)