Skip to content
Snippets Groups Projects
Commit 42d16ef5 authored by Chude, Chiamaka A (PG/T - Comp Sci & Elec Eng)'s avatar Chude, Chiamaka A (PG/T - Comp Sci & Elec Eng)
Browse files

Update - implemented the event driven architecture using kafka for...

Update - implemented the event driven architecture using kafka for asynchronous communication between the user and product microservice
parents fdec3b37 799a2f63
No related branches found
No related tags found
1 merge request!5Update - implemented the event driven architecture using kafka
#ReadME
<h1>Folders and Files in the Product Microservice </h1>
<h4>1. Controllers/: <h4>
<p>a. productHomeController.py: This page is the landing page of the application. It gets product data from the database by category using a POST method. </p><br>
<p>b. getProductController.py: A user is redirected to this page after they have clicked on a product. It shows information of that product – image, name, price, reviews, ratings. It uses a GET request method to get the product ID. The product ID is sent to the database. </p><br>
<p>c. addReviewController.py: This section allows a user to add a review to a product. It first of all uses a GET request to get the product ID. It first of all checks if a user's session is active and if they are logged in. If the user is not logged in, it throws an error and asks them to log in.
An HTTP request is also made to the User Microservice to get the username of the user leaving review. This is because the username is stored in the ReviewsandRatings table to avoid always having to make requests to the User Microservice to retrieve names of users when displaying all the reviews. On the same page, a POST request is also used when a user clicks the button to add the review. After the user has posted the review, the username gotten from the microservice, product ID, review and rating are sent to the database. </p><br>
<h4>2. Models/: </h4>
<p>a. productHome.py: This page sends product information by category from the database to "productHomeController.py". </p><br>
<p>b. getProduct.py: This page has a function that collects the product ID from "getProductController.py", it retrieves information about the product using the ID it collected. </p><br>
<p>c. addRevew.py: This collects review information from "addReviewController.py" and inserts into the ReviewsandRatings table of the product database. </p><br>
<p>d. database_connection.py: This section handles the database connection details for this microservice. </p><br>
<h4>3. Config.py:</h4> This file contains the necessary configurations for this microservice - port number, server name.
<h4>4. Index.py:</h4> This file manages the routing for this microservice.
#ReadMe
<h2>User Microservice</h2>
<h3>Folders and Files in the User Microservice</h3>
<h5>1. Controllers/:</h5><br>
<p>a. signupController.py: This page collects information from the user when they log sign up. It uses a POST request method. The user's password is encoded using the hashlib and secrets libraries. If no email address is entered, it does not allow sign up. Because email is set to not null in the database.</p><br>
<p>b. loginController.py: This page handles user log in and user authentication. It uses a POST request method to collect the user's email address and password. If an email is entered that does not exist, it throws an error to the user. If the email exists in the database, it then checks the entered password. The password is encoded and compared with the encoded password in the database. If it matches, the sign in is successful. A session is then created and is accessible from the server.</p><br>
<p>c. logoutController.py: This page handles the logout function and uses a POST request. It first of all checks if the session is active. If it is, it is deleted from the server.</p><br>
<p>d. updateProfileController.py: This section handles changes made to the user's personal information. It uses a POST request method to get the updated information from the user. It does not update the email address because this is constant. It checks if the user's session is active. If it is active, it sends the updated information to the database using the session data. If the session is not active, it throws an error message to the user to log in.</p><br>
<p>e. changePasswordController.py: This section handles changing the user's password. It is collected from the user using a POST request. It checks if the user's session is active. If it isn't, it throws an error for the user to log in. If it is, the user's old and new password are collected. The old password is checked against the database. If it matches, the new password is then decoded and updated in the database.</p><br>
<p>f. deleteProfileController.py: This section handles deleting a user's profile. It checks if the user's session is active. If it isn't, it throws an error for the user to log in. If the session is active, it calls the database function to delete the user's profile.</p><br>
<h5>2. Models/:</h5><br>
<p>a. sigup.py: This collects the user's information from "signupController.py" and checks if the email exists in the database. If the email does not exist, it inserts the user's data in the database.</p><br>
<p>b. login.py: This page collects log in information from "loginController.py". It has 2 functions. The first function retrieves the email the user entered if it exists. The second function collects the password and sends it to the "loginController.py" page for verification.</p><br>
<p>c. updateProfile.py: This page collects the user's information from "updateProfileController.py" and inserts it into the database.</p><br>
<p>d. changePassword.py: This page collects password information from "changePasswordController.py". It has 2 functions. The first function gets the old password, and the second function sets the new password. The second function is called only if the old password matches the password in the database.</p><br>
<p>e. deleteProfile.py: This section collects the user's ID from "deleteProfileController.py" and deletes the user's profile if the profile exists.</p><br>
<p>f. Database_connection.py: This section handles the database connection details for this microservice.</p><br>
<p>All database codes use the try statement for error handling and rolls back changes if not all database operations were successful in a given function.</p><br>
<h5>3. Config.py:</h5><p> This file contains the necessary configurations for this microservice - port number, server name</p>
<h5>4. Index.py:</h5><p> This file manages the routing for this microservice</p>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment