/Kura

Primary LanguageTypeScriptMIT LicenseMIT

Choices with IMPACT!


Ibrahim Morad Mogamed Eladly duncan

License GitHub Release

Forks Stars GitHub watchers

KURA is a polling service that helps the institutions and companies to include their employees or others in their decision-making process.

An institution-type user can create polls and get statistical information about votes on their own polls.

A normal user can vote on polls and get some information (what the institution allows) about polls he/she votes on.

Table of Contents

Python SQLAlchemy PostgreSQL Flask React Next.js

Database

Implemented by Ibrahim Morad

  • We used postgresql as the database management system to store our data.
  • We used sqlalchemy as the ORM service that connects our engine to the database server and query the required data.
  • database schema is shown in the following data model.alt text

This data model is made by sqldbm (kura-model).

And it consists of the following tables:

  1. answers
  2. choices
  3. countries
  4. districts
  5. industries
  6. institutions
  7. legal_entities
  8. polls
  9. questions
  10. tags
  11. users
  • There is basemodel class that defines the id, created_at and updated_at columns for all the tables (except tags)
  • The other part of the database is the methods implemented so that the api can use the database without getting involved with the database or the ORM service. These methods are:
the method syntax example description
get get(class_name, id) Storage.get(User, '6666a7d8-7d69-4c7f-a341-14997c8306c0') returns the user with the given id
all all(class_name)
all()
Storage.all(User)
Storage.all()
returns all the users
returns all the records in the whole database
count count(class_name) Storage.count(User) returns the number of records in a certain table
new new(object) Storage.new(user1) adds a new record
delete delete(object) Storage.delete(user1) deletes a record
save save() Storage.save() commit changes

API

Implemented by Duncan The API is designed using Flask to handle requests from the frontend and other clients, processing data and returning responses in a structured format. By utilizing these endpoints, users can perform actions such as retrieving data, creating resources, updating information, and more.

Key Endpoints

  1. /api/v1/users

    • Method: GET
    • Description: Retrieve a list of users.
    • Parameters:
      • None
    • Response:
      • JSON object containing user information.
  2. /api/v1/users/{id}

    • Method: GET
    • Description: Retrieve a specific user by ID.
    • Parameters:
      • id: The ID of the user to retrieve.
    • Response:
      • JSON object containing the user's details.
  3. /api/v1/signup

    • Method: POST
    • Description: Handles the sign-up process for new users.
    • Parameters:
      • Form data structure for signing up a user:
        {
            "json": {
                "username": "New user's username",
                "email": "New user's email",
                "password": "New user's password"
            },
        "pic": "Profile picture file",
        "id_snippet": "ID card file"
        }
    • Response:
      • A response confirming the successful registration of a new user.
  4. /api/v1/update/<obj_id>

    • Method: POST
    • Description: Handles the update process for users and institutions.
    • Parameters:
      • obj_id: The ID of the object to be updated.
      • Form data structure for updating a user:
        {
            "json": {
                "class": "user",
                "mobile_number": "User's mobile number",
                "occupation": "User's occupation",
                "ed_speciality": "User's educational speciality",
                "job_role": "User's job role",
                "company_id": "Valid institution ID",
                "job_description": "Description of user's job",
                "salary": "User's salary",
                "hobbies": "User's hobbies"
            },
            "pic": "Profile picture file",
            "id_snippet": "ID card file"
        }
      • Form data structure for updating an institution:
        {
            "json": {
                "class": "institution",
                "postal_code": "Postal code of institution",
                "phone_number": "Phone number of institution",
                "parent_company": "Parent company details"
            }
        }
    • Response:
      • A response indicating the success or failure of the update process.

Frontend

Implemented by Mohamed Eladly

  • To DO .....
  1. Setup dependencies: run the bash script setup.sh, it should install all the required technologies required for the project.
chmod u+x setup.sh; ./setup.sh
  1. setup the database :
    • run postgresql in interactive mode.
    psql -u postgres postgres
    • Create the database, the user and give the user privilages for the project.
    CREATE DATABASE kura_db;
    CREATE ROLE kura_user WITH LOGIN PASSWORD 'test_choices_01';
    GRANT ALL ON DATABASE kura_db TO kura_user;
    \q
    • got to frontend directory.
    cd frontend
    • start the application.
    npm run dev

Go to home page

A user can go to the home page, which works as the landing page too, using the following url: https://kura-mxoi.onrender.com/.

Register

From there, a user can click join or sign up to register or sign in to (you know).

For a first visit, of course, a user needs to register, so click on join.

This redirects the user to the registration page.

Choose account type

There are two types of accounts, institution and individual. Follow the registration steps by filling the required fields and submit. This redirects you to your home page. There you can create polls if you are an institution or vote on polls if you are an individual.

An institution user

An individual user

  1. Fork the project.
  2. Clone the repository.
  3. Make the changes you see.
  4. commit the changes you made.
  5. Make a pull request and wait for you request to be accepted or commented on.

This project is licensed under the MIT license. Feel free to edit and distribute this template as you like.

See LICENSE for more information.