Git Product home page Git Product logo

pulzion23-skyline's Introduction

Project Structure

  • /Project
    • /db
      • conn.js
    • /middlewares
      • producer_middlewares
      • recycler_middlewares
    • /routes
      • app_routes
      • producer_routes
      • recycler_routes
    • /static
      • /css
        • dashboard.css
        • index.css
        • login.css
      • /images
        • create_order_icon.png
      • /js
        • producer_dashboard.js
        • recycler_dashboard.js
        • login.js
        • register.js
    • /templates
      • /partials
        • header.hbs
        • footer.hbs
      • /views
        • contact.hbs
        • index.hbs
        • login.hbs
        • producer_dashboard.hbs
        • recycler_dashboard.hbs
        • register.hbs
    • index.js
    • package-lock.json
    • package.json
    • README.md

Routes

  1. App Routes

  2. Producer Routes

  3. Recycler Routes


Routes Explained

  • / [GET]

    • This route uses a GET request to display the static 'Home Page'
  • /login [GET]

    • The '/login' route uses a GET request to display the static 'Login Page'
  • /register [GET]

    • The '/register' route uses a GET request to display the static 'Registration Page'
  • /contact [GET]

    • The '/contact' get route uses a GET request to display the static 'Contact Us Page'
  • /contact [POST]

    • The '/contact' post route uses a POST request to send an email to the company.
  • /producer/register [POST]

    • The '/producer/register' route handles the POST request from the 'Register Page'
    • It has a middleware isAuth which checks if the user is already logged in.
      • If the user is already logged in it redirects the Producer to their dashboard.
      • Else it proceeds further.
    • It then updates the databases using the register middleware.
    • Upon successful registration, it redirects the Producer to the dashboard.
    • Else it refreshes the 'Registration Page'.
  • /producer/login [POST]

    • The '/producer/login' route handles the POST request from the 'Login Page'
    • It has a middleware isAuth which checks if the user is already logged in.
      • If the user is already logged in it redirects the Producer to their dashboard.
      • Else it proceeds further
    • Then it checks the entry in the database using the login middleware.
    • Upon successful login, it redirects the user to the dashboard of the Producer.
    • Else it refreshes the 'Login Page'.
  • /producer/dashboard [GET]

    • The '/producer/dashboard' route displays the dashboard of the Producer.
    • It has a middleware isAuth which checks if the user is logged in or not.
      • If the user is already logged it proceeds further.
      • Else it redirects the Producer to the 'Login Page'.
    • It displays all the accepted and pending requests.
  • /producer/create-order [POST]

    • This request is posted after the Producer clicks on 'Create Order' button present on the dashboard.
    • Displays an interface to create an order.
    • It has a createOrder middleware which updates the databases.
    • Then it refreshes the dashboard page also displaying the order and order status.
  • /producer/order/execute/:id [POST]

    • This request is posted after the Producer clicks on 'Execute Order' button present on the dashboard.
    • The order with order id = id is executed from both the ends.
    • It has a executeOrder middleware which updates the databases.
    • Then it refreshes the dashboard page.
  • /producer/logout [GET]

    • Delete the session.
    • Clear the cookies.
    • Redirect to the 'Login Page'.
  • /recycler/register [POST]

    • The '/recycler/register' route handles the POST request from the 'Register Page'
    • It has a middleware isAuth which checks if the user is already logged in.
      • If the user is already logged in it redirects the Recycler to their dashboard.
      • Else it proceeds further.
    • It then updates the databases using the register middleware.
    • Upon successful registration, it redirects the Recycler to the dashboard.
    • Else it refreshes the 'Registration Page'.
  • /recycler/login [POST]

    • The '/recycler/login' route handles the POST request from the 'Login Page'
    • It has a middleware isAuth which checks if the user is already logged in.
      • If the user is already logged in it redirects the Recycler to their dashboard.
      • Else it proceeds further
    • Then it checks the entry in the database using the login middleware.
    • Upon successful login, it redirects the user to the dashboard of the Recycler.
    • Else it refreshes the 'Login Page'.
  • /recycler/dashboard [GET]

    • The '/recycler/dashboard' route displays the dashboard of the Recycler.
    • It has a middleware isAuth which checks if the user is logged in or not.
      • If the user is already logged it proceeds further.
      • Else it redirects the Recycler to the 'Login Page'.
    • It displays all the accepted and pending requests.
  • /recycler/accept/:id [GET]

    • This request facilitates the Recycler to accept the order corresponding to order_id=id.
    • It has a middlware acceptOrder which updates the databases.
    • Then it refreshes the dashboard page.
  • /recycler/execute/:id [GET]

    • This request facilitates the Recycler to initialize the execution of order corresponding to order_id=id.
    • It has a middlware executeOrder which updates the databases.
    • Then it refreshes the dashboard page.
  • /recycler/reject/:id [GET]

    • This request facilitates the Recycler to reject the order corresponding to order_id=id.
    • It has a middlware rejectOrder which updates the databases.
    • Then it refreshes the dashboard page.
  • /recycler/logout [GET]

    • Delete the session.
    • Clear the cookies.
    • Redirect to the 'Login Page'.

Middlewares

  1. Producer Middlewares

    • register

      • It takes all the information from the input fields of the 'Registration Page'.
      • Inserts all the information about Producer into the db1.Producers table.
      • Then it inserts the information about the location into the db1.addresses table
      • Upon successful insertions it stores the following session variables :-
        • req.session.username = Producer's Name
        • req.session.id = Company ID
        • req.session.north = North Coordinates
        • req.session.east = East Coordinates
        • req.session.entity = "producer"
        • req.session.isAuth = true
      • And proceeds further
    • login

      • It takes all the information from the input fields of the 'Login Page'.
      • Checks all the information about Producer into the db1.Producers table.
      • Upon successful checking the databases it stores the following session variables :-
        • req.session.username = Producer's Name
        • req.session.id = Company ID
        • req.session.north = North Coordinates
        • req.session.east = East Coordinates
        • req.session.entity = "producer"
        • req.session.isAuth = true
      • And proceeds further
    • isAuth

      • It checks the req.session.isAuth variable to check the user is already logged in.
    • createOrder

      • IMP First it checks if there are any available recyclers who recycle that particular waste.
      • Then it checks which recycler is the nearest (within some radius).
      • If no recyclers are present which satisfy the above conditions then it doesn't create any order.
      • Else it creates an order with order_status = number of available recyclers whoc satisfy the conditions.
      • Updates the order status (created/not) in the Producer's dashboard.
    • executeOrder

      • This option is visible at the pending verification section.
      • The recycler has to initiate the execution process by clicking on the execute button.
      • The status of order with order_id = id is set as executed by the producer.
      • The order is then set as completely executed.
  2. Recycler Middlewares

    • register

      • It takes all the information from the input fields of the 'Registration Page'.
      • Inserts all the information about Recycler into the db1.Recyclers table.
      • Then it inserts the information about the location into the db1.addresses table
      • Upon successful insertions it stores the following session variables :-
        • req.session.username = Recycler's Name
        • req.session.id = Company ID
        • req.session.waste_type = Waste Type
        • req.session.entity = "recycler"
        • req.session.isAuth = true
      • And proceeds further
    • login

      • It takes all the information from the input fields of the 'Login Page'.
      • Checks all the information about Producer into the db1.Producers table.
      • Upon successful checking the databases it stores the following session variables :-
        • req.session.username = Recycler's Name
        • req.session.id = Company ID
        • req.session.waste_type = Waste Type
        • req.session.entity = "recycler"
        • req.session.isAuth = true
      • And proceeds further
    • isAuth

      • It checks the req.session.isAuth variable to check the user is already logged in.
    • acceptOrder

      • It takes all the order_id from the url itself using req.params.
      • It updates the order_status in the orders table as 111.
      • It also updates the recycler_id of the same entry.
    • executeOrder

      • The recycler has to initiate the execution process by clicking on the execute button.
      • The status of order with order_id = id is set as executed by the recycler.
      • This makes the order display in the pending verfication section of the producer.
      • The order is then set as executed by the recycler.
    • rejectOrder

      • The recycler can reject an order by clicking on Reject button.
      • The status of order with order_id = id is set as rejected by the corresponding recycler.
      • This order is never show to that recycler again.

Databases

  1. MySQL

    • Producers Table

      • Schema
      Field Type Null Key Default Extra
      company_id int NO PRI NULL auto_increment
      producer_name char(30) YES NULL
      producer_email varchar(30) YES NULL
      producer_contact_number varchar(13) YES NULL
      waste_type int YES NULL
      password char(60) YES NULL
    • Recyclers Table

      • Schema
      Field Type Null Key Default Extra
      company_id int NO PRI NULL auto_increment
      recycler_name char(30) YES NULL
      recycler_email varchar(30) YES NULL
      recycler_contact_number varchar(13) YES NULL
      waste_type int YES NULL
      password char(60) YES NULL
    • Orders Table

      • Schema
      Field Type Null Key Default Extra
      order_id int NO PRI NULL auto_increment
      recycler_id int YES MUL NULL
      producer_id int YES MUL NULL
      waste_type int YES NULL
      waste_quantity varchar(20) YES NULL
      pickup_date datetime YES NULL
      order_status int YES NULL
      north_coordinate float YES NULL
      east_coordinate float YES NULL
    • Addresses Table

      • Schema
      Field Type Null Key Default Extra
      company_id int NO PRI NULL
      building_number varchar(20) YES NULL
      building_name varchar(20) YES NULL
      street_landmark varchar(20) YES NULL
      city varchar(20) YES NULL
      district varchar(20) YES NULL
      pincode int YES NULL
      north_coordinate float YES NULL
      east_coordinate float YES NULL
  2. MongoDB

    • Rejected Orders Collection

      • Model
      Field Type
      _id ObjectId
      order_id int
      building_name int array

pulzion23-skyline's People

Contributors

bhushanvp avatar ronin2810 avatar khalidm3463 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.