A full-featured e-commerce web application built with Flask and PostgreSQL.
- User authentication (Admin, Store Owner, Customer roles)
- Multiple stores with independent inventories
- Product management with images
- Shopping cart functionality
- Discount system (Seasonal, Special Event, Shipping discounts)
- Order processing
- Product reviews
- Search and filtering
- Backend: Flask 3.1.2
- Database: PostgreSQL
- ORM: SQLAlchemy
- Authentication: Flask-Login, Flask-Bcrypt
- Forms: Flask-WTF, WTForms
- Frontend: HTML, CSS, Jinja2 templates
- Python 3.8 or higher
- PostgreSQL installed and running
- pgAdmin 4 (recommended for database management)
git clone https://github.com/psyPan/e-commerce-platform.git
cd e-commerce-platform- On Mac
python3 -m venv venv
source venv/bin/activate- On Window
python3 -m venv venv
venv\Scripts\activatepip install -r requirements.txt- Open pgAdmin 4
- Create a new database:
- Right-click on "Databases" → "Create" → "Database"
- Database name:
mystore - Click "Save"
Edit the POSTGRES dictionary in both seed_data.py and run.py with your PostgreSQL credentials:
POSTGRES = {
'user': 'postgres', # Your PostgreSQL username
'password': 'your_password', # Your PostgreSQL password
'db': 'mystore',
'host': 'localhost',
'port': '5432',
}Run the seed script to create tables and populate with sample data:
python3 seed_data.pyThis will create:
- 1 Admin account
- 5 Stores with 2 owners each
- 8 Customer accounts
- 25 Products (5 per store)
- 50 Discount codes
- Shopping carts for all customers
Start the Flask development server:
python3 run.pyThe application will be available at: http://127.0.0.1:5000
- Email:
admin@email.com - Password:
adminpass
- Email:
owner1@email.comtoowner10@email.com - Password:
ownerpass
- Email:
cust1@email.comtocust8@email.com - Password:
customerpass
- Store 1: Laptops (Dell, Apple, ASUS, HP, Lenovo)
- Store 2: Headphones (Sony, Bose, Apple, Sennheiser, Beats)
- Store 3: Cameras (Canon, Sony, Fujifilm, Nikon, Panasonic)
- Store 4: Monitors (Dell, LG, ASUS, Samsung, BenQ)
- Store 5: Gaming Keyboards (Keychron, Logitech, Razer, Corsair, SteelSeries)
e-commerce-platform/
├── flask_store/
│ ├── __init__.py # App factory
│ ├── users/ # User authentication & management
│ ├── credit_card/ # User's credit card
│ ├── stores/ # Store management
│ ├── products/ # Product CRUD operations
│ ├── discounts/ # Discount system
│ ├── cart/ # Shopping cart
│ ├── line_items/ # Line item
│ ├── orders/ # Order processing
│ ├── reviews/ # Product reviews
│ ├── static/ # CSS, JS, images
│ └── templates/ # HTML templates
├── seed_data.py # Database initialization script
├── run.py # Application entry point
├── requirements.txt # Python dependencies
└── README.md # This file
The application uses the following main tables:
users- User accounts with role flags (admin, owner, customer)stores- Store informationproducts- Product catalogline item- Line itemdiscounts- Discount codes with inheritance (Seasoning, SpecialEvent, Shipping)carts- Shopping cart itemsorders- Order recordsreviews- Product reviewscredit card- User's credit card
- The application uses Flask's development server (not for production use)
- Debug mode is enabled by default in
run.py - Product images are stored locally in
static/product_pics/ - Passwords are hashed using bcrypt
- Verify PostgreSQL is running
- Check database credentials in
POSTGRESconfiguration - Ensure database
mystoreexists in pgAdmin
- Activate virtual environment:
source venv/bin/activate - Reinstall dependencies:
pip install -r requirements.txt
- Place image files (product1.png - product25.png) in
flask_store/static/product_pics/ - Ensure filenames match exactly (case-sensitive)