- Introduction
- Architectural Overview
- Technologies
- Installation
- Node.js Mongo DB Dockerized Server
- Run Client-side (REACT for Dynamic pages)
- Create Django Proxy Services of Backend APIs
- Deploy sentiment analysis on Code Engine as a microservice
A national car dealership with local branches spread across the United States recently conducted a market survey. One of the suggestions that emerged from the survey was that customers would find it beneficial if they could access a central database of dealership reviews across the country.
You are a new hire at the company. You are assigned the task of building a website that allows new and existing customers to look up different branches by state and look at customer reviews of the various branches. Customers should be able to create an account and add their review for any of the branches. The management hopes this will bring transparency to the system and also increase the trust customers have in the dealership.
After thorough research and brainstorming, the team developed use cases for anonymous, authorized, and admin users.
- View the Contact Us page.
- View the About Us page.
- View the list of dealerships.
- Filter the list of dealerships by state:
- Select Show all or a specific state from the State dropdown on the dealership page.
- View all states if nothing is selected in the dropdown.
- View a table of dealerships for the selected state when the form is submitted.
- Click on a dealership to view the reviews for that dealership on the details page with each review displayed on a bootstrap card.
- Log in using their credentials.
In addition to the above, authorized users should be able to write a review for any dealership on the dealership's page. In order to enable authorized users to write their reviews:
- A Review button should be provided against each dealer listed in the dealership table.
- Clicking on the Review button should take the user to the review page.
- Filling the form on the review page and submitting it should add the review.
{
"user_id": 1, => from Django
"name": "Berkly Shepley", => from Django
"dealership": 15, => from the form
"review": "Total grid-enabled service-desk", => form textbox
"time": "", => current time
"purchase": true, => form checkbox
"purchase_date": "07/11/2020", => form calendar (bootstrap)
"car_make": "Audi", => from django dropdown
"car_model": "A6", => from django dropdown
"car_year": 2010 => form django dropdown
}
- On submission, the user should be taken back to the dealership detail page with the submitted review featured at the top of the reviews list, sorted on time.
- Log in to the admin site with a predefined username and password.
- Add new make, model, and other attributes.
-
Django Application:
- Add user management using the Django user authentication system.
- Create Django models and views to manage car model and car make.
- Create Django proxy services and views to integrate dealers and reviews together.
-
React Frontend:
- Implement user management using the Django user authentication system.
- Create a React frontend for the application.
-
Backend Services:
- Create a Node.js server to manage dealers and reviews using MongoDB.
- Dockerize the Node.js server.
- Deploy the sentiment analyzer on Code Engine.
-
Sentiment Analyzer:
- Deploy and integrate the sentiment analyzer as a backend service.
The user interacts with the "Dealerships Website", a Django website, through a web browser.
The Django application provides the following microservices for the end user:
get_cars/
- To get the list of cars.get_dealers/
- To get the list of dealers.get_dealers/:state
- To get dealers by state.dealer/:id
- To get dealer by id.review/dealer/:id
- To get reviews specific to a dealer.add_review/
- To post review about a dealer.
The Django application uses an SQLite database to store the Car Make and the Car Model data.
The "Dealerships and Reviews Service" is an Express Mongo service running in a Docker container. It provides the following services:
/fetchDealers
- To fetch the dealers./fetchDealer/:id
- To fetch the dealer by id./fetchReviews
- To fetch all the reviews./fetchReview/dealer/:id
- To fetch reviews for a dealer by id./insertReview
- To insert a review.
"Dealerships Website" interacts with the "Dealership and Reviews Service" through the "Django Proxy Service" contained within the Django Application.
The "Sentiment Analyzer Service" is deployed on IBM Cloud Code Engine and provides the following service:
/analyze/:text
- To analyze the sentiment of the text passed. It returns positive, negative, or neutral.
The "Dealerships Website" consumes the "Sentiment Analyzer Service" to analyze the sentiments of the reviews through the Django Proxy contained within the Django application.
Frontend | Backend | Services | Other |
---|---|---|---|
React | Django | Docker (for containerization) | Python (for the Django application) |
Bootstrap (for form and UI components) | Node.js | Code Engine (for deploying the sentiment analyzer) | JavaScript (for the Node.js server and React frontend) |
MongoDB |
git clone https://github.com/KSaiPrashanth/Car_Dealership_Full_Stack_App
cd Car_Dealership_Full_Stack_App/server
pip install virtualenv
virtualenv djangoenv
source djangoenv/bin/activate
python3 -m pip install -U -r requirements.txt
python3 manage.py makemigrations
python3 manage.py migrate --run-syncdb
python3 manage.py runserver
cd Car_Dealership_Full_Stack_App/server/database
docker build . -t nodeapp
3. The docker-compose.yml has been created to run two containers, one for Mongo and the other for the Node app. Run the following command to run the server:
docker-compose up
cd Car_Dealership_Full_Stack_App/server/frontend
npm install
npm run build
2. Once the code engine set up is complete, you can see that it is active. Click on Code Engine CLI to begin the pre-configured CLI in the terminal below.
cd Car_Dealership_Full_Stack_App/server/djangoapp/microservices
docker build . -t us.icr.io/${SN_ICR_NAMESPACE}/senti_analyzer
docker push us.icr.io/${SN_ICR_NAMESPACE}/senti_analyzer
ibmcloud ce application create --name sentianalyzer --image us.icr.io/${SN_ICR_NAMESPACE}/senti_analyzer --registry-secret icr-secret --port 5000
5. Open djangoapp/.env and replace your code engine deployment url with the deployment URL you obtained above.
sentiment_analyzer_url=your code engine deployment url