Skip to content

Pull Request to merge changes to main #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude = djangoenv, node_modules, migrations
max-line-length = 88
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Lint Code'

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

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: Run Linter
run: |
find . -name "*.py" -exec flake8 {} +
echo "✅ Python linting completed"

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 -g jshint

- name: Run Linter
run: |
find ./server/database -name "*.js" -exec jshint {} +
echo "✅ JavaScript linting completed"
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esversion": 8
}
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
# coding-project-template
# 🚗 Car Dealer Full-Stack Capstone Project

This repository showcases a production-ready full-stack web application developed as part of a capstone project. It simulates a **Car Dealership Management System** with features including user authentication, inventory tracking, and sentiment analysis.

---

## 📌 Project Overview

This capstone demonstrates hands-on application of modern full-stack development skills using:

- **Frontend**: React, HTML5, CSS3
- **Backend**: Node.js, Express.js, Python, Django
- **Database**: MongoDB (NoSQL)
- **CI/CD**: GitHub Actions, Docker
- **NLP Integration**: Sentiment analysis for user input

The project implements a modular, scalable architecture suitable for future enhancement and microservices adoption. It emphasizes secure user access, CRUD operations for car inventory, and basic analytics features.

---

## 🛠 Features

- 🔐 **User Registration/Login**
- 📦 **Inventory Management (CRUD)**
- 📊 **Sentiment Analysis of Customer Input**
- 🌐 **RESTful API Integration**
- 🧪 **CI/CD Pipeline** via GitHub Actions & Docker
- ☁️ **Cloud-native ready** with Kubernetes deployment in progress

---

## 🧰 Tech Stack

| Layer | Technologies |
|--------------|-------------------------------------|
| Frontend | React, HTML5, CSS3 |
| Backend | Node.js, Express, Django (Python) |
| Database | MongoDB |
| DevOps | Docker, GitHub Actions, Pre-commit |
| Linting | ESLint, Prettier, JSHint, flake8 |

---

## 🚀 Getting Started

```bash
# Clone the repo
git clone https://github.com/Silvafox76/car-dealer-fullstack-capstone.git

# Install backend dependencies
cd server
npm install

# Install frontend dependencies
cd client
npm install

# Run backend & frontend concurrently (example setup)
npm run dev
Environment variables for database and API integration should be added in .env.

🔬 Project Status
✅ MVP Complete
🚧 Docker & Kubernetes optimization in progress
🧠 Sentiment Analysis tuning planned

📄 License
Apache 2.0 License – see LICENSE file for details.

🙋‍♂️ Author
Ryan Dear
GitHub | LinkedIn | Email
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"]
67 changes: 43 additions & 24 deletions server/database/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const express = require('express');
const mongoose = require('mongoose');
const fs = require('fs');
const cors = require('cors')
const app = express()
const cors = require('cors');
const app = express();
const port = 3030;

app.use(cors())
app.use(cors());
app.use(require('body-parser').urlencoded({ extended: false }));

const reviews_data = JSON.parse(fs.readFileSync("reviews.json", 'utf8'));
Expand All @@ -20,10 +20,10 @@ const Dealerships = require('./dealership');

try {
Reviews.deleteMany({}).then(()=>{
Reviews.insertMany(reviews_data['reviews']);
Reviews.insertMany(reviews_data.reviews);
});
Dealerships.deleteMany({}).then(()=>{
Dealerships.insertMany(dealerships_data['dealerships']);
Dealerships.insertMany(dealerships_data.dealerships);
});

} catch (error) {
Expand All @@ -33,7 +33,7 @@ try {

// Express route to home
app.get('/', async (req, res) => {
res.send("Welcome to the Mongoose API")
res.send("Welcome to the Mongoose API");
});

// Express route to fetch all reviews
Expand All @@ -56,38 +56,57 @@ 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 dealers = await Dealerships.find();
res.json(dealers);
} catch (error) {
res.status(500).json({ error: 'Error fetching dealerships' });
}
});

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

// Express route to fetch dealer by a particular id
app.get('/fetchDealer/:id', async (req, res) => {
//Write your code here
});
const id = parseInt(req.params.id, 10); // Parse the ID as an integer
try {
const dealership = await Dealerships.findOne({ id });
if (!dealership) {
res.status(404).json({ error: 'No dealership found with ID: ${id}'});
} else {
res.json(dealership);
}
} catch (error) {
res.status(500).json({ error: 'Error fetching dealership by ID'});
}
});

//Express route to insert review
app.post('/insert_review', express.raw({ type: '*/*' }), async (req, res) => {
data = JSON.parse(req.body);
const documents = await Reviews.find().sort( { id: -1 } )
let new_id = documents[0]['id']+1
const documents = await Reviews.find().sort( { id: -1 } );
let new_id = documents[0].id + 1;

const review = new Reviews({
"id": new_id,
"name": data['name'],
"dealership": data['dealership'],
"review": data['review'],
"purchase": data['purchase'],
"purchase_date": data['purchase_date'],
"car_make": data['car_make'],
"car_model": data['car_model'],
"car_year": data['car_year'],
});
"id": new_id,
"name": data.name,
"dealership": data.dealership,
"review": data.review,
"purchase": data.purchase,
"purchase_date": data.purchase_date,
"car_make": data.car_make,
"car_model": data.car_model,
"car_year": data.car_year,
});

try {
const savedReview = await review.save();
Expand All @@ -101,4 +120,4 @@ app.post('/insert_review', express.raw({ type: '*/*' }), async (req, res) => {
// Start the Express server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
});
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-ryanwdear/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://ryanwdear-3030.theiadockernext-0-labs-prod-theiak8s-4-tor01.proxy.cognitiveclass.ai
sentiment_analyzer_url=https://sentianalyzer.1ux214w5ffje.us-south.codeengine.appdomain.cloud
Empty file removed server/djangoapp/__init__.py
Empty file.
10 changes: 5 additions & 5 deletions server/djangoapp/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# from django.contrib import admin
# from .models import related models


# Register your models here.
from django.contrib import admin
from .models import CarMake, CarModel

# Registering models with their respective admins
admin.site.register(CarMake)
admin.site.register(CarModel)
# CarModelInline class

# CarModelAdmin class
Expand Down
Loading