πΈ Flower Shop Project
Flower Shop is a full-stack web application for an online flower shop, developed as a capstone project for the "Basics of Object-Oriented Programming" course.
The project combines classic e-commerce functionality, strict object-oriented architecture, and the use of graph theory algorithms to calculate bouquet complexity.
π Table of Contents
- Lab 1: OOP Basics
- Lab 1a: Refactoring & UML 3. Lab 2: Graphical User Interface (GUI)
- Lab 3: External Libraries
- Academic Project
- Documentation
- Installation & Setup
- Project Structure
1. Lab 1: OOP Basics
Implementation of Encapsulation, Inheritance, and Polymorphism requirements.
The project implements a strict OOP architecture:
- Classes & Objects: Over 12 classes implemented (minimum requirement: 9).
- Entities:
User,Order,Payment,Shipping. - Products:
ShopItem,Flower,DecorItem,Bouquet,SpecialBouquet. - Utils:
Graph,Store.
- Entities:
- Encapsulation: All classes utilize private fields (
#price,#items,#status). Access is controlled via getters and validation methods (e.g.,User.setShippingAddressvalidates string length). - Inheritance (Hierarchies):
ShopItem(Base) βFlower,DecorItem,Bouquet.BouquetβSpecialBouquet(Deep hierarchy, 3 levels).Shipping(Abstract) βNovaPoshtaShipping.
- Polymorphism:
- Dynamic: The
getDescription()method is overridden inFlower,DecorItem, andSpecialBouquetclasses. - Static (Generics Simulation): The
Storeclass implements a container that accepts only objects inheriting fromShopItem.
- Dynamic: The
- Non-trivial Methods: Over 25 complex methods implemented, including
findOptimalFlowerConnections(graph algorithm),processPayment, andupdateStatus.
1a. Lab 1a: Refactoring & UML Modeling
Advanced system modeling and architectural improvements.
1. Refactoring (Strategy Pattern)
- Problem: The
Orderclass had high coupling with specific shipping logic (NovaPoshtaShipping), violating the Open/Closed Principle. - Solution: Implemented the Strategy Pattern. Shipping logic was encapsulated into separate strategy classes (
NovaPoshtaStrategy,PickupStrategy) implementing a common interface. - Result: New delivery methods can be added without modifying the core
Orderlogic.
2. UML Modeling A complete set of 8 UML diagrams was created to document the system:
- Static Structure: Class Diagram, Component Diagram, Deployment Diagram, Object Diagram.
- Dynamic Behavior: Use Case Diagram, Sequence Diagram, Activity Diagram, State Machine Diagram.
2. Lab 2: Graphical User Interface (GUI)
Implementation of interactive user interaction.
The interface is decoupled from business logic (Frontend in frontend/, Backend in backend/).
- Screens (Forms/Windows): 6 pages implemented (minimum requirement: 4):
index.html(Home)products.html(Catalog with filters)details.html(Product Details)cart.html(Shopping Cart)checkout.html(Order Checkout)builder.html(Bouquet Builder)
- Controls: Over 25 elements used (minimum requirement: 20):
- Filters: by color (radio buttons), seasonality (toggle), price (inputs), search (text input).
- Drag-and-Drop zone for the builder.
- Quantity controls (+/-), Add to Cart, Remove buttons.
- Data Containers: Dynamic population of product lists (
.product-list), cart items, and builder components. - Event Handling: Event listeners implemented for
click,input,submit,dragstart,drop,dragover,DOMContentLoaded.
3. Lab 3: External Libraries
Integration of third-party solutions to enhance code quality.
A detailed retrospective report can be found here: π LAB3_REPORT.md
Libraries Used:
validator(v13.12.0):- Used on the backend for input sanitization (XSS protection) and email validation during order processing.
date-fns(v4.1.0):- Used in the
Orderclass for precise delivery date calculations (adding days, date formatting).
- Used in the
4. Academic Project
Implementation of unique functionality and domain analysis.
A detailed market and analog analysis can be found here: π ANALYSIS.md
Key Project Features:
- Bouquet Builder: A unique feature distinguishing this project from typical flower shops. Users can custom-build a bouquet by dragging and dropping flowers (Drag & Drop).
- Algorithmic Component (Graph Theory):
- Flowers are represented as Graph Vertices, and their compatibility as Edge Weights.
- Kruskalβs Algorithm (MST - Minimum Spanning Tree) is used to calculate the optimal "Assembly Cost" based on the compatibility of selected components.
- This solves the "Black Box Pricing" issue by transparently explaining the composition complexity to the user.
5. Documentation
Full technical documentation for the project's classes, methods, and modules has been generated using JSDoc.
It covers all backend entities, product classes, and utility functions.
π View Full Documentation: https://sakharochok.github.io/flower-shop/module-details.html
π Installation & Setup
-
Clone the repository:
git clone [https://github.com/your-username/flower-shop.git](https://github.com/your-username/flower-shop.git) cd flower-shop -
Install dependencies:
npm install -
Start the server:
node backend/server.js -
Open in browser: Navigate to
http://localhost:3001 -
Run Tests:
node tests/oop-tests.js
π Project Structure
FLOWER-SHOP
βββ backend
β βββ data
β β βββ entities # User, Order, Payment, Shipping (Strategy)
β β βββ products # ShopItem, Flower, Bouquet, SpecialBouquet
β β βββ utils # Graph Algorithms, Store
β βββ server.js # Express Server & API Endpoints
βββ frontend
β βββ css # Styles
β βββ js # Client logic (main.js, cart.js, builder.js)
β βββ *.html # Pages
βββ tests # Unit Tests (OOP logic check)
βββ docs # Project Documentation
β βββ diagrams # UML Diagrams (PlantUML/Images)
βββ ANALYSIS.md # Project & Analog Analysis
βββ LAB3_REPORT.md # External Libraries Report
βββ README.md # Project Documentation