{"id":19555880,"url":"https://github.com/theijhay/vote-system","last_synced_at":"2026-06-11T04:31:09.775Z","repository":{"id":256895823,"uuid":"855716200","full_name":"theijhay/Vote-System","owner":"theijhay","description":"Voting system using Django and Django Rest Framework ","archived":false,"fork":false,"pushed_at":"2024-09-18T22:02:07.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T07:43:18.220Z","etag":null,"topics":["celery","django-rest-framework","gjango","python","rabbitmq","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theijhay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-11T10:51:26.000Z","updated_at":"2024-10-16T21:39:11.000Z","dependencies_parsed_at":"2024-11-11T04:51:34.061Z","dependency_job_id":null,"html_url":"https://github.com/theijhay/Vote-System","commit_stats":null,"previous_names":["theijhay/student-voter-system-design","theijhay/vote-system"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theijhay%2FVote-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theijhay%2FVote-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theijhay%2FVote-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theijhay%2FVote-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theijhay","download_url":"https://codeload.github.com/theijhay/Vote-System/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240814837,"owners_count":19861955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["celery","django-rest-framework","gjango","python","rabbitmq","rest-api"],"created_at":"2024-11-11T04:35:56.847Z","updated_at":"2026-06-11T04:31:09.728Z","avatar_url":"https://github.com/theijhay.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Project Documentation\n\nThe Student Voter System is a backend system built with Django and Django Rest Framework (DRF) to process CSV/Excel files containing student voter data. The system asynchronously processes large files using Celery and RabbitMQ to ensure performance and scalability. After processing, the system saves the data to a database and notifies the admin via email upon successful completion.\n\n#### Setup and Installation\n\n- Python 3.x\n- RabbitMQ (for Celery)\n- RabbitMQ for message brokering in production\n\n**Steps:**\n- Clone the repository:\n```\ngit clone https://github.com/your-username/student-voter-system.git\n```\n```\ncd student-voter-system\n```\n\n- Set up a virtual environment:\n```\npython -m venv env\nsource env/bin/activate  # On Windows: .\\env\\Scripts\\activate\n```\n\n- Install dependencies:\n```\npip install -r requirements.txt\n```\n\n- Install and configure RabbitMQ:\n\nInstall RabbitMQ by following the instructions for your OS: [RabbitMQ Installation Guide](https://www.rabbitmq.com/docs/download)\n\nEnsure RabbitMQ is running:\n```\nsudo service rabbitmq-server start\n```\n\n- Apply database migrations:\n```\npython manage.py migrate\n```\n\n- Create a superuser for admin access:\n```\npython manage.py createsuperuser\n```\n### Environment Variables\nCreate a .env file in the root directory to configure the environment variables:\n```\n# Django settings\nSECRET_KEY=\"your-secret-key\"\nDEBUG=True  # Change to False in production\nALLOWED_HOSTS=\"*\"\n\n\n# Email settings (for Gmail)\nEMAIL_BACKEND=\"django.core.mail.backends.smtp.EmailBackend\"\nEMAIL_HOST=\"smtp.gmail.com\"\nEMAIL_PORT=587\nEMAIL_USE_TLS=True\nEMAIL_HOST_USER=\"your-email@gmail.com\"\nEMAIL_HOST_PASSWORD=\"your-email-password\"\nDEFAULT_FROM_EMAIL=\"your-email@gmail.com\"\nADMIN_EMAIL=\"admin@example.com\"\n\n\n# Celery settings\nCELERY_BROKER_URL=\"amqp://localhost\"\nMake sure to update the credentials according to your setup (e.g., email credentials, database URL).\n```\n\n### Running the Application\nTo run the backend application, follow these steps:\n\n- Run the Django development server:\n```\npython manage.py runserver\n```\n\n- Start the Celery worker:\n```\ncelery -A student_election worker --loglevel=info\n```\n\n### API Endpoints\n\n- **File Upload Endpoint:**\n- **URL:** `/api/upload/`\n- **Method:** `POST`\n- **Description:** Upload a CSV or Excel file for asynchronous processing.\n- **Request Body:**\nfile (multipart/form-data): The file to be processed.\n- **Response:**\n\n- **Status:** `202 Accepted`\n- **Body:**\n```json\n{\n  \"message\": \"File uploaded and processing started\",\n  \"task_id\": \"string\"\n}\n```\n- Task Status Endpoint:\n\n- **URL:** `/api/task-status/\u003ctask_id\u003e/`\n- **Method:** GET\n- **Description:** Get the status of the processing task.\n- **Response:**\n- **Status:** `200 OK`\n\n- **Body:**\n\n```json\n{\n  \"state\": \"SUCCESS\",\n  \"status\": \"Task is processing\",\n  \"result\": \"File processing completed successfully\"\n}\n```\n\n### Asynchronous Processing with Celery\n\nThe file processing is handled asynchronously using Celery and RabbitMQ. The system reads large files in chunks to prevent memory overload and processes each row, saving the data into the database.\n\n\n### Database Design\n\nThe StudentVoter model represents the structure for student voter information. The model contains the following fields:\n```\nstudent_id: Unique ID for each student.\nfirst_name: Student's first name.\nlast_name: Student's last name.\nemail: Student's email address.\ndepartment: Department the student belongs to.\nyear: Year of study.\nis_eligible: Boolean indicating whether the student is eligible to vote.\n```\n\n### Handling File Uploads\n\n- The system accepts CSV or Excel files for processing. \n- Uploaded files are validated for format, and each row is processed asynchronously. \n- The processed data is stored in the StudentVoter model.\n- File validation ensures that only CSV or Excel files are accepted.\n- Chunked processing is used to handle large files efficiently.\n\n### Email Notification System\n\n- Once the file processing is complete, the system sends an email to the admin notifying them of the success or failure of the operation.\n\nThe email contains details about:\n- Number of records processed and saved.\n- Any missing fields in the file.\n\n\n### Testing\n\nYou can run tests using Django’s built-in test framework:\n```\npython manage.py test voters\n```\n\nEnsure that the file upload, data saving, and email notifications work as expected.\n\n### Deployment Instructions\n\nFor deployment, you can use Railway, Render, or any other PaaS provider. Make sure to:\n\n- Set environment variables correctly for production (`DEBUG=False`, `ALLOWED_HOSTS`, etc.).\n- Configure the database and email settings for your production environment.\n- Ensure your deployment supports asynchronous processing with Celery and RabbitMQ.\n\n### Thought Process and Problem-Solving Approach\n\n- Scalability: The use of Celery and chunked file processing ensures that the system can handle large files without performance issues.\n- Asynchronous Processing: The system leverages Celery to process files asynchronously, ensuring that the application remains responsive even when dealing with large datasets.\n- Email Notifications: After processing, the system notifies the admin of the results, providing transparency into the system’s operations.\n- Data Integrity: Only rows with valid data (like `student_id` and `email`) are saved to the database, ensuring data integrity.\n\n**Challenges:**\n- Handling large file uploads without overwhelming the server.\n- Ensuring that email notifications work reliably across different environments (development vs. production).\n\n### Conclusion\nThis project provides a scalable and efficient system for processing student voter data, ensuring that the election process is seamless and data replication is handled effectively. The use of asynchronous tasks, combined with clear notifications and error handling, ensures that admins are always informed of the system’s status.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheijhay%2Fvote-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheijhay%2Fvote-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheijhay%2Fvote-system/lists"}