This is a Flask-based web application with functionalities that include Grocery Store management and Marketplace . The application integrates with SQLite database using Flask-SQLAlchemy and provides secure authentication using Flask-Login and Werkzeug. As mentioned No Css has been used , Only Bootstrap and Jinja has been used in the html templates
- Python
- Flask
- Flask-SQLAlchemy
- Flask-Login
- Werkzeug
- Matplotlib
- Numpy
While Developing the project , Was getting some errors so I avoided using Venv , as a result many unnecessary requirements have been added ..
-
Install the required packages:
pip install -r requirements.txt
-
Run the application:
python app.py
-
-
- Using Cascade in SQL to delete all the products with the categories , Right now ,each product is needed to removed first before deleting each category
-
- Api's not working
-
- No css used , So not great styling !!
-
- Minor Bugs might present.
-
- entire Code is in one app.py which is Horrible , But I tried to make it as good as possible by adding Comments and lines between each independent functions
-
- Attributes:
id
: Unique identifier.username
: Unique username of the user.password
: Hashed password for authentication.
- Relationships:
cart_items
: Related items from the CartItem model.
- Attributes:
id
: Unique identifier.name
: Name of the product.unit
: Measurement unit of the product.price_per_unit
: Price per individual unit.stock_quantity
: Current stock quantity.
- Relationships:
cart_items
: Related items from the CartItem model.category
: Associated category from the Category model.
- Attributes:
id
: Unique identifier.user_id
: Related user identifier.product_id
: Related product identifier.quantity
: Quantity of the product in the cart.
- Relationships:
user
: Associated user from the User model.product
: Associated product from the Product model.cart
: Associated cart from the Cart model.
- Methods:
calculate_total_price
: Calculates the total price for this cart item.
- Attributes:
id
: Unique identifier.user_id
: Related user identifier.
- Relationships:
cart_items
: Related items from the CartItem model.
- Attributes:
id
: Unique identifier.name
: Name of the category.
- Relationships:
products
: Associated products from the Product model.
- Attributes:
id
: Unique identifier.user_id
: Related user identifier.product_id
: Related product identifier.content
: Review content.
- Relationships:
- No direct relationships in the provided snippet.
- Endpoint: Internal use for Flask-Login
- Purpose: Fetches a user from the database using their ID.
- Endpoint:
/
- Methods:
GET
,POST
- Purpose: Renders login page and checks credentials.
- Endpoint:
/dashboard
- Methods:
GET
,POST
- Purpose: Displays all product categories.
- Endpoint:
/add-category
- Methods:
POST
- Purpose: Adds a new category.
- Endpoint:
/delete-category/<int:category_id>
- Purpose: Deletes a category.
- Endpoint:
/edit-category/<int:category_id>
- Methods:
GET
,POST
- Purpose: Fetches category for editing or updates it.
- Endpoint:
/add-product/<int:category_id>
- Methods:
POST
- Purpose: Adds a new product to a category.
- Endpoint:
/edit-product/<int:product_id>
- Methods:
GET
,POST
- Purpose: Fetches product for editing or updates it.
- Endpoint:
/delete-product/<int:product_id>
- Purpose: Deletes a product.
- Endpoint:
/logout
- Purpose: Logs the user out.
- Endpoint:
/summary
- Purpose: Provides a visual summary of sales, products, and user activity.
- Endpoint:
/user_login
- Methods:
GET
,POST
- Purpose: Handles user login. Redirects if already authenticated.
- Endpoint:
/user_register
- Methods:
GET
,POST
- Purpose: Handles user registration. Redirects if already authenticated.
- Endpoint:
/user_dashboard
- Methods:
GET
- Purpose: Displays available products and categories, allows for product search and sorting.
- Endpoint:
/buy-product/<int:product_id>
- Methods:
GET
- Purpose: Decreases the stock of a product by one and confirms the purchase.
- Endpoint:
/user_logout
- Purpose: Logs out the user and redirects to the login page.
- Endpoint:
/add-to-cart/<int:product_id>
- Methods:
POST
- Purpose: Adds a product to the user's cart or increments its quantity if already present.
- Endpoint:
/remove-from-cart/<int:item_id>
- Methods:
GET
- Purpose: Removes a product from the user's cart.
- Endpoint:
/checkout
- Methods:
GET
,POST
- Purpose: Displays the user's cart for checkout. On confirmation, updates product stocks and clears the cart.
- Endpoint:
/add_review/<int:product_id>
- Methods:
POST
- Purpose: Allows users to add a review for a product Feedback.