Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
# Electhon - 2023

#### Team Name -
#### Problem Statement -
#### Team Leader Email -
#### Team Name - 0xace

#### Problem Statement - 1. How can we ensure registration of new voters in the electoral role.

#### Team Leader Email - aadit2002nov@gmail.com

## A Brief of the Prototype:
What is your solution? and how it works.

## Code Execution Instruction:
*[If your solution is **not** application based, you can ignore this para]

*The Repository must contain your **Execution Plan PDF**.
What is your solution? and how it works.
We devised a solution that will help user get voterID as soon as he is about to turn 18 . We automated the form filling and introduced online verification . We have identified a unique identifier that will map all the government verified IDs. Th.e user can get VoterID just at a click of button in couple of minutes

## To Install This Project Follow Below Steps

### Requirements
- [x] Windows 11 OS
- [x] VS Code
- [x] Download below Dependencies

### Installation
Clone the repository: [git clone git@github.com:Coollaitar/Electhon.git](https://github.com/Coollaitar/Electhon.git)
### Install any required dependencies:
#### Frontend Dependencies :
- [x] npm install axios react react-dom react-scripts
#### Backend Dependencies
- [x] npm install dotenv express body-parser twilio

Start the application: npm start
106 changes: 106 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
const mysql = require('mysql2');
const express = require('express');
const query = require('express');
const nodemon = require('nodemon');
const cors = require('cors');
const app = express();
app.use(express.json());
app.use(cors());

const db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '@adit27nov',
database: 'aadhar',
});
const accountSid = 'ENTER YOUR ACCOUNT_SID_TWILIO';
const authToken = 'ENTER YOUR AUTHTOKEN_TWILIO';
const client = require('twilio')(accountSid, authToken);
client.messages
.create({
body: 'Authentication OTP is 1211 . Please enter OTP and then click on this link http://localhost:3000/details/123',
from: 'FROM',
to: 'TO',
})
.then((message) => console.log(message.sid));

app.get('/', (req, res) => {
res.json('Backend check');
});
app.get('/details/:aadharNumber', (req, res) => {
const aadharNumber = req.params.aadharNumber;
const q = 'SELECT * FROM details WHERE aadharNumber=?';

db.query(q, aadharNumber, (err, data) => {
if (err) return res.json(err);
return res.json(data);
});
});
// @notice -> so here we want to keep and option for updates so suppose a user wants to edit just the address part so he should be able change only that part -> if else if work?
// Address update check
app.put('/details/:aadharNumber/add', (req, res) => {
const aadharNumber = req.params.aadharNumber;
const q = 'UPDATE details SET `Address`=? WHERE aadharNumber=?';
const value = [req.body.Address];
db.query(q, [...value, aadharNumber], (err, data) => {
if (err) return res.json(err);
return res.json(data);
});
});
// Relative Name update check
app.put('/details/:aadharNumber/relativeUpdate', (req, res) => {
const aadharNumber = req.params.aadharNumber;
const q =
'UPDATE details SET `relativeFirstName`= ? ,`relativeSurname`= ?,`realtiveNumber`= ? ,`typeofRelation` = ? WHERE aadharNumber= ?';
const value = [
req.body.relativeFirstName,
req.body.relativeSurname,
req.body.realtiveNumber,
req.body.typeofRelation,
];
db.query(q, [...value, aadharNumber], (err, data) => {
if (err) return res.json(err);
return res.json(data);
});
});
// Query 1 @condition-> below 18 for address
app.get('/query1/:UID', (req, res) => {
const aadharNumber = req.params.aadharNumber;
const age = req.params.AGE;
const q =
'SELECT epic.Address FROM epic JOIN details ON epic.epicNumber = details.realtiveEPICNum WHERE details.AGE < 18';

db.query(q, aadharNumber, (err, data) => {
if (err) return res.json(err);
return res.json(data);
});
});

// Query 2 @condition-> fetch address form passport AGE>18
app.get('/query2/:UID', (req, res) => {
const aadharNumber = req.params.aadharNumber;
const age = req.params.AGE;
const q =
'SELECT passport.Address FROM passport JOIN details ON passport.UID = details.UID WHERE details.UID=12';

db.query(q, aadharNumber, (err, data) => {
if (err) return res.json(err);
return res.json(data);
});
});
// Query @condition-> aadhar is not linked with mobile so get data from bc & address from govt verified docs
app.get('/query3/:UID', (req, res) => {
const aadharNumber = req.params.aadharNumber;
const age = req.params.AGE;
const q =
'SELECT rationcard.Address FROM rationcard JOIN details ON rationcard.UID = details.UID WHERE details.UID=214';

db.query(q, aadharNumber, (err, data) => {
if (err) return res.json(err);
return res.json(data);
});
});

app.listen(8800, () => {
console.log('Connected to backend');
});
Loading