Full-stack e-commerce web application built with Django & PostgreSQL
πΉ A full demo walkthrough is available as
demo.mp4in the root of this repository.
- Overview
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Database Setup
- Running the Project
- Admin Panel
- Usage Guide
- Screenshots
- What I Learned
- License
ShopAlpha is a fully functional e-commerce store built as Task 1 of the CodeAlpha Full Stack Development Internship. It covers the complete shopping flow β from browsing products by category, adding items to a session-based cart, registering/logging in, and placing an order that persists to a PostgreSQL database.
The project was built from scratch without any frontend framework β just Django templates, plain CSS, and vanilla JavaScript β to solidify understanding of how full-stack web applications work at their core.
- Product listing with responsive CSS Grid layout
- Category filtering via URL query parameters
- Product detail page with stock status
- Session-based shopping cart (works without login)
- Add to cart, update quantity, remove items
- Cart item count badge in navbar (context processor)
- User registration with email, first name, last name
- Automatic login after registration
- Login / logout
- User profile page with address and phone fields
@login_requiredprotection on checkout
- Full checkout flow with shipping address
- Order creation with per-item price snapshot
- Stock decrement on successful order
- Order success page with order ID and details
- Order management via Django admin
- Category and Product management
- Auto-slug generation from product name
- Inline order item editing
- Bulk stock and availability editing
| Layer | Technology |
|---|---|
| Language | Python 3.14 |
| Framework | Django 6.0 |
| Database | PostgreSQL |
| ORM | Django ORM |
| Frontend | HTML5, CSS3 (Grid/Flexbox), Vanilla JS |
| Templating | Django Template Language |
| Auth | Django built-in auth system |
| Image handling | Pillow |
| Environment | python-dotenv |
| DB Driver | psycopg2-binary |
CodeAlpha_EcommerceStore/
β
βββ manage.py
βββ requirements.txt
βββ .env # secrets β not committed to git
βββ .gitignore
βββ preview.png # store screenshot for README
βββ demo.mp4 # full walkthrough video
β
βββ ecommerce/ # Django project config
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
β βββ asgi.py
β
βββ users/ # User auth app
β βββ models.py # Profile model (extends User)
β βββ forms.py # RegisterForm, ProfileUpdateForm
β βββ views.py # register, login, logout, profile
β βββ urls.py
β βββ admin.py
β
βββ store/ # Products, cart, orders app
β βββ models.py # Category, Product, Order, OrderItem
β βββ views.py # home, product_detail, cart, checkout
β βββ urls.py
β βββ admin.py
β βββ context_processors.py # cart_count injected into every template
β
βββ templates/
β βββ base.html # parent layout
β βββ navbar.html # navigation partial
β βββ users/
β β βββ login.html
β β βββ register.html
β β βββ profile.html
β βββ store/
β βββ home.html
β βββ product_detail.html
β βββ cart.html
β βββ checkout.html
β βββ order_success.html
β
βββ static/
β βββ css/
β β βββ style.css
β βββ js/
β βββ cart.js
β
βββ media/ # uploaded product images (auto-created)
βββ products/
Make sure you have these installed on your machine:
- Python 3.10+
- PostgreSQL
- pip
- git
git clone https://github.com/yourusername/CodeAlpha_EcommerceStore.git
cd CodeAlpha_EcommerceStorepython -m venv venv
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windowspip install -r requirements.txtCreate a .env file in the project root:
SECRET_KEY=your-long-random-secret-key-here
DEBUG=True
DB_NAME=ecommerce_db
DB_USER=postgres
DB_PASSWORD=yourpassword
DB_HOST=localhost
DB_PORT=5432
β οΈ Never commit.envto git. It is already listed in.gitignore.
To generate a secure SECRET_KEY:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"Open a terminal and connect to psql:
psql -U postgresThen run:
CREATE DATABASE ecommerce_db;
\qDjango does not create the database for you β only the tables inside it. You must create the database manually first.
python manage.py makemigrations
python manage.py migrateThis creates all required tables in PostgreSQL β including Django's built-in auth, sessions, and your custom models.
python manage.py createsuperuserYou'll be prompted for a username, email, and password. This account is used to access the admin panel.
python manage.py runserverVisit http://127.0.0.1:8000 in your browser.
| URL | Page |
|---|---|
/ |
Home β product listing |
/product/<slug>/ |
Product detail page |
/cart/ |
Shopping cart |
/checkout/ |
Checkout (login required) |
/users/register/ |
Register |
/users/login/ |
Login |
/users/profile/ |
User profile |
/admin/ |
Django admin panel |
Visit http://127.0.0.1:8000/admin and log in with your superuser credentials.
-
Go to Categories β Add Category
- Enter a name (e.g.
Electronics) - The slug auto-fills β leave it as is
- Save
- Enter a name (e.g.
-
Go to Products β Add Product
- Fill in name, description, price, stock
- Select a category
- Upload a product image
- Set Is available to checked
- Save
Products appear on the home page immediately after saving.
Go to Orders to see all placed orders. You can:
- Change order status (Pending β Processing β Shipped β Delivered)
- View all items within each order inline
- Filter orders by status or user
- Browse products on the home page
- Filter by category using the buttons below the hero
- Click a product to see its detail page
- Click Add to Cart β the cart badge in the navbar updates
- Visit the cart to review items, update quantities, or remove items
- Register at
/users/register/ - You are logged in automatically
- Add items to cart and proceed to checkout
- Enter a shipping address and place your order
- See the order confirmation page with your order ID
- Update your profile at
/users/profile/
Building this project from scratch taught me:
Django fundamentals
- The MVT (ModelβViewβTemplate) request lifecycle
- URL routing with
path(),include(), and named URLs - Template inheritance with
{% extends %}and{% block %} - Context processors for injecting global template data
- Static files vs media files and how Django serves each
Database and ORM
- Designing relational models with
ForeignKeyandOneToOneField - Running and understanding Django migrations
- QuerySet methods:
filter(),get(),get_or_create(),order_by() - Why price snapshots in
OrderItemmatter for order history integrity
Authentication
- Django's built-in
Usermodel and session-based auth - Extending
Userwith aProfilemodel viaOneToOneField - Using
UserCreationFormandAuthenticationForm - Protecting views with
@login_requiredand handling?next=redirects
Session-based cart
- Storing cart state in
request.sessionwithout a database table - Why session dict keys must be strings (JSON serialization)
- The importance of reassigning
request.session['cart']to trigger a save
Frontend
- Responsive product grid with CSS Grid
auto-fill+minmax() - Django's messages framework for flash notifications
- Rendering forms manually with field loops for full styling control
- CSRF protection on every POST form
This project was built for the CodeAlpha Full Stack Development Internship. Feel free to use it as a learning reference.
Built by Adnan β CodeAlpha Internship 2026
