# 🗳️ Student Council Election System

A modern, full-stack voting platform designed for school and university student council elections. This system offers a secure, user-friendly experience for voters and a powerful management interface for administrators.

## 🚀 Key Features

### 🛠️ Intelligent Initial Setup
- **No Hardcoded Passwords**: On first startup, the system automatically redirects to a setup screen where you can configure unique Admin and Booth credentials.
- **Role-Based Access**: Secure login for Administrators (management) and Booths (voting stations).

### ☁️ Database Redundancy & Cloud Sync
- **Device-to-Device Redundancy**: Supports PostgreSQL (via `DATABASE_URL`) to allow multiple servers to share the same data in real-time.
- **Offline Reliability**: Falls back to local SQLite if no cloud database is provided.
- **LAN Ready**: Built-in support for access across a Local Area Network (LAN), allowing students to vote from any device on the network.

### 🗳️ Seamless Voting Experience
- **Step-by-Step Flow**: A guided voting process that ensures every student casts a complete and valid ballot.
- **Duplicate Prevention**: Tracks voter participation via admission numbers to prevent multiple votes from the same student.
- **Dynamic Ballots**: Voters only see the candidates relevant to the positions currently being contested.

### 📊 Administrative Dashboard
- **Position Management**: Create, edit, and order election roles (e.g., President, Secretary).
- **Candidate Management**: Add candidates with names, detailed bios, and profile images.
- **Real-Time Results**: Instantly view vote counts and rankings as they are cast.
- **Secure Reset**: A multi-step confirmation process for clearing election data for a new cycle.

---

## 🛠️ Tech Stack

- **Frontend**: [Vue.js 3](https://vuejs.org/) (Composition API), [Vite](https://vitejs.dev/), [Vue Router](https://router.vuejs.org/)
- **Backend**: [Node.js](https://nodejs.org/), [Express.js](https://expressjs.com/)
- **Database**: [SQLite](https://www.sqlite.org/) (Local) / [PostgreSQL](https://www.postgresql.org/) (Redundant/Cloud)
- **Styling**: Vanilla CSS with modern Glassmorphism aesthetics

---

## ⚙️ Installation & Setup

### 1. Prerequisites
- Node.js (v16 or higher)
- npm (Node Package Manager)

### 2. Clone and Install
```bash
git clone <your-repo-url>
cd student-council-election
npm run install-all
```

### 3. Running the Application
To start both the client and server concurrently:
```bash
npm run dev
```
- **Frontend**: http://localhost:5173
- **Backend**: http://localhost:3000

---

## 🔄 Enabling Redundancy (Cloud Database)

To keep data synchronized across multiple devices or to ensure data safety if a device fails:

1. Create a PostgreSQL database (using [Supabase](https://supabase.com/), [Neon](https://neon.tech/), or [Aiven](https://aiven.io/)).
2. Create a `.env` file in the `server/` directory.
3. Add your connection string:
   ```env
   DATABASE_URL=postgres://user:password@host:port/dbname
   ```
4. Restart the application. The system will automatically migrate the schema to the cloud database.

---

## 📱 LAN Access

To allow other devices on your network to access the voting booth:
1. Ensure the server is running on your main machine.
2. Find your local IP address (e.g., `192.168.1.15`).
3. Other devices can then access the app via: `http://192.168.1.15:5173`.
4. The system will automatically route API requests to your main machine.

---

## 🔒 Security Note
Ensure that you use a strong password during the initial setup. For production environments, it is recommended to deploy the backend with SSL/HTTPS.

---

## 📄 License
This project is open-source and available under the MIT License.
