Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c1268f4
add static changes
yukl-c Oct 12, 2025
4902a34
fail to show register form
yukl-c Oct 12, 2025
42068f9
Working with Mongoose to provide API endpoints
yukl-c Oct 12, 2025
d973579
register the CarMake and CarModel models with the admin site
yukl-c Oct 12, 2025
f544941
Create function to interact with backend
Oct 14, 2025
18c2a75
Deploy sentiment analysis on Code Engine as a microservice
yukl-c Oct 14, 2025
f26fe1e
Update .env
yukl-c Oct 14, 2025
4c6f03e
Add dynamic pages
yukl-c Oct 14, 2025
2ecd3ed
new updaet
yukl-c Oct 15, 2025
3c3086e
new update
yukl-c Oct 15, 2025
397f362
Add GitHub Actions workflow for linting Python and JS
yukl-c Oct 17, 2025
9d39ea3
Add linting jobs for Python and JavaScript files
yukl-c Oct 17, 2025
89cb217
Fix URL patterns for dealer and postreview paths
yukl-c Oct 17, 2025
95aa247
Fix formatting in settings.py for static files
yukl-c Oct 17, 2025
cc0d892
Fix URL patterns in urls.py for Django project
yukl-c Oct 17, 2025
d009938
Fix URL patterns in urls.py
yukl-c Oct 17, 2025
53fba41
Add JSHint directive for ES6 support
yukl-c Oct 17, 2025
474001f
Update review.js
yukl-c Oct 17, 2025
c9bdbbe
Add JSHint directive for ES version 8
yukl-c Oct 17, 2025
d611e6a
Fix linter command to find JavaScript files
yukl-c Oct 17, 2025
0ae33a0
Format ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS
yukl-c Oct 17, 2025
8591785
Update ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS format
yukl-c Oct 17, 2025
511da20
Refactor Django views for clarity and consistency
yukl-c Oct 17, 2025
78985c3
Refactor Django settings for clarity and organization
yukl-c Oct 17, 2025
5c2fe53
Refactor sentiment analysis and error handling
yukl-c Oct 17, 2025
7f19a96
Refactor populate.py for car makes and models
yukl-c Oct 17, 2025
dd0aa9f
Refactor GET and POST request handling in restapis.py
yukl-c Oct 17, 2025
e1cca22
Refactor URL patterns for better readability
yukl-c Oct 17, 2025
5bf3ab4
Refactor authentication and registration views
yukl-c Oct 17, 2025
8f11273
Implement CarMake and CarModel models
yukl-c Oct 17, 2025
7b58b0f
Create Dockerfile
yukl-c Oct 17, 2025
51226f9
Create entrypoint.sh
yukl-c Oct 17, 2025
8cc5be8
Create deployment.yaml
yukl-c Oct 17, 2025
53e7a6e
containerize
yukl-c Oct 18, 2025
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
51 changes: 51 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Lint Code'

on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
lint_python:
name: Lint Python Files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Print working directory
run: pwd
- name: Run Linter
run: |
pwd
# This command finds all Python files recursively and runs flake8 on them
find . -name "*.py" -exec flake8 {} +
echo "Linted all the python files successfully"

lint_js:
name: Lint JavaScript Files
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install JSHint
run: npm install jshint --global
- name: Run Linter
run: |
# This command finds all JavaScript files recursively and runs JSHint on them
# find ./server/database -name "*.js" -exec jshint {} +
jshint ./server/database --esversion 8 || true
echo "Linted all the js files successfully"
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.0-slim-bookworm

ENV PYTHONBUFFERED 1
ENV PYTHONWRITEBYTECODE 1

ENV APP=/app

# Change the workdir.
WORKDIR $APP

# Install the requirements
COPY requirements.txt $APP

RUN pip3 install -r requirements.txt

# Copy the rest of the files
COPY . $APP

EXPOSE 8000

RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]

CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]
29 changes: 29 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: dealership
name: dealership
spec:
replicas: 1
selector:
matchLabels:
run: dealership
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
run: dealership
spec:
containers:
- image: us.icr.io/sn-labs-cmaisy010822/dealership:latest
imagePullPolicy: Always
name: dealership
ports:
- containerPort: 8000
protocol: TCP
restartPolicy: Always
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Make migrations and migrate the database.
echo "Making migrations and migrating the database. "
python manage.py makemigrations --noinput
python manage.py migrate --noinput
python manage.py collectstatic --noinput
exec "$@"
25 changes: 25 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12.0-slim-bookworm

ENV PYTHONBUFFERED 1
ENV PYTHONWRITEBYTECODE 1

ENV APP=/app

# Change the workdir.
WORKDIR $APP

# Install the requirements
COPY requirements.txt $APP

RUN pip3 install -r requirements.txt

# Copy the rest of the files
COPY . $APP

EXPOSE 8000

RUN chmod +x /app/entrypoint.sh

ENTRYPOINT ["/bin/bash","/app/entrypoint.sh"]

CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "djangoproj.wsgi"]
22 changes: 19 additions & 3 deletions server/database/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* jshint esversion: 8 */
const express = require('express');
const mongoose = require('mongoose');
const fs = require('fs');
Expand Down Expand Up @@ -58,17 +59,32 @@ app.get('/fetchReviews/dealer/:id', async (req, res) => {

// Express route to fetch all dealerships
app.get('/fetchDealers', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find();
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch Dealers by a particular state
app.get('/fetchDealers/:state', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find({state: req.params.state});
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching documents' });
}
});

// Express route to fetch dealer by a particular id
app.get('/fetchDealer/:id', async (req, res) => {
//Write your code here
try {
const documents = await Dealerships.find({ id: req.params.id });
res.json(documents);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealers by ID' });
}
});

//Express route to insert review
Expand Down
1 change: 1 addition & 0 deletions server/database/review.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* jshint esversion: 8 */
const mongoose = require('mongoose');

const Schema = mongoose.Schema;
Expand Down
29 changes: 29 additions & 0 deletions server/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: dealership
name: dealership
spec:
replicas: 1
selector:
matchLabels:
run: dealership
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
run: dealership
spec:
containers:
- image: us.icr.io/sn-labs-cmaisy010822/dealership:latest
imagePullPolicy: Always
name: dealership
ports:
- containerPort: 8000
protocol: TCP
restartPolicy: Always
4 changes: 2 additions & 2 deletions server/djangoapp/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
backend_url =your backend url
sentiment_analyzer_url=your code engine deployment url
backend_url ="https://cmaisy010822-3030.theiadockernext-0-labs-prod-theiak8s-4-tor01.proxy.cognitiveclass.ai"
sentiment_analyzer_url="https://sentianalyzer.21n1woj7t5ov.us-south.codeengine.appdomain.cloud/"
6 changes: 4 additions & 2 deletions server/djangoapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# from django.contrib import admin
# from .models import related models
from django.contrib import admin
from .models import CarMake, CarModel


# Register your models here.
admin.site.register(CarMake)
admin.site.register(CarModel)

# CarModelInline class

Expand Down
65 changes: 44 additions & 21 deletions server/djangoapp/models.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
# Uncomment the following imports before adding the Model code

# from django.db import models
# from django.utils.timezone import now
# from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator


# Create your models here.

# <HINT> Create a Car Make model `class CarMake(models.Model)`:
# - Name
# - Description
# - Any other fields you would like to include in car make model
# - __str__ method to print a car make object


# <HINT> Create a Car Model model `class CarModel(models.Model):`:
# - Many-To-One relationship to Car Make model (One Car Make has many
# Car Models, using ForeignKey field)
# - Name
# - Type (CharField with a choices argument to provide limited choices
# such as Sedan, SUV, WAGON, etc.)
# - Year (IntegerField) with min value 2015 and max value 2023
# - Any other fields you would like to include in car model
# - __str__ method to print a car make object
# Car Make model
class CarMake(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
# created_at = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.name


# Car Model model
class CarModel(models.Model):
# Many-to-One relationship (one CarMake has many CarModels)
car_make = models.ForeignKey(
CarMake,
on_delete=models.CASCADE,
)
name = models.CharField(max_length=100)

CAR_TYPES = [
('SEDAN', 'Sedan'),
('SUV', 'SUV'),
('WAGON', 'Wagon'),
# Add more choices as required
]

type = models.CharField(
max_length=10,
choices=CAR_TYPES,
default='SUV',
)

year = models.IntegerField(
default=2023,
validators=[
MaxValueValidator(2023),
MinValueValidator(2015),
],
)

def __str__(self):
return self.name
Loading