Skip to content

Repository files navigation

MusicStore

MusicStore is a Django web application for selling music-related products such as albums, instruments, and accessories. The project includes user accounts, product catalog, shopping cart, checkout, orders, and a fake payment system.

Features

  • User registration and login.
  • User profile page.
  • Product catalog.
  • Product detail page.
  • Session-based shopping cart.
  • Add products to cart.
  • Remove products from cart.
  • Checkout form.
  • Order creation.
  • Order history.
  • Order detail page.
  • Fake payment system.
  • Different fake card payment methods.
  • MySQL database.
  • Dockerized MySQL setup.
  • Django admin panel.

Technologies Used

  • Python
  • Django
  • MySQL
  • Docker
  • HTML
  • Django Templates
  • PyMySQL
  • python-dotenv

Project Structure

MusicStore/
├── accounts/
├── cart/
├── config/
├── orders/
├── payments/
├── products/
├── templates/
├── docker-compose.yml
├── manage.py
├── requirements.txt
└── .env

Applications

Products

The products app is responsible for the product catalog.

It contains:

  • Product model.
  • Product list page.
  • Product detail page.
  • Product admin registration.

Product types:

  • Album.
  • Instrument.
  • Accessory.

Accounts

The accounts app is responsible for user authentication.

It contains:

  • Registration.
  • Login.
  • Logout.
  • Profile page.

The project uses Django's built-in user model.

Cart

The cart app is responsible for the shopping cart.

The cart is stored in the user session. It does not use a separate database model.

Example session cart:

{
    "1": 2,
    "5": 1
}

This means:

Product with id 1 has quantity 2.
Product with id 5 has quantity 1.

Orders

The orders app is responsible for checkout and order saving.

It contains:

  • Order model.
  • OrderItem model.
  • Checkout form.
  • Order detail page.
  • Order history page.

After checkout, cart data is converted into database records.

Payments

The payments app is responsible for fake payment simulation.

It contains:

  • Payment model.
  • Payment form.
  • Payment method selection.
  • Card last 4 digits saving.
  • Order status update.

Payment changes order status from:

new → paid

This is only a fake payment system. The project does not process real payments.

Database Models

Product

Stores product information.

Main fields:

  • name
  • price
  • product_type
  • description
  • artist
  • brand
  • created_at

Order

Stores user order information.

Main fields:

  • user
  • full_name
  • phone
  • address
  • total_price
  • status
  • created_at

OrderItem

Stores products inside an order.

Main fields:

  • order
  • product
  • quantity
  • price

Payment

Stores fake payment information.

Main fields:

  • order
  • payment_method
  • card_last4
  • status
  • created_at

Setup Instructions

1. Clone the repository

git clone <repository-url>
cd MusicStore

2. Create virtual environment

python -m venv .venv
source .venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Create .env file

Create a .env file in the project root:

SECRET_KEY=django-insecure-local-music-store-key
DEBUG=True

MYSQL_DATABASE=music_store
MYSQL_USER=music_user
MYSQL_PASSWORD=music_password
MYSQL_ROOT_PASSWORD=root_password
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306

5. Start MySQL with Docker

docker compose up -d

6. Apply migrations

python manage.py makemigrations
python manage.py migrate

7. Create superuser

python manage.py createsuperuser

8. Run development server

python manage.py runserver

Open the project in browser:

http://127.0.0.1:8000/products/

Main URLs

/products/              Product list
/products/<id>/         Product detail

/accounts/register/     Register
/accounts/login/        Login
/accounts/logout/       Logout
/accounts/profile/      Profile

/cart/                  Cart detail
/cart/add/<id>/         Add product to cart
/cart/remove/<id>/      Remove product from cart

/orders/                Order history
/orders/checkout/       Checkout
/orders/<id>/           Order detail

/payments/pay/<id>/     Fake payment page

/admin/                 Django admin panel

How the Order Flow Works

  1. User opens the product catalog.
  2. User opens product detail page.
  3. User adds product to cart.
  4. Cart stores product IDs and quantities in session.
  5. User opens cart page.
  6. User clicks checkout.
  7. User enters delivery information.
  8. Django creates an order and order items in MySQL.
  9. Cart is cleared.
  10. User can pay for the order using fake card payment.
  11. Order status changes from new to paid.

Security Notes

This project is created for learning purposes.

The payment system is fake. It does not process real bank cards. It only stores the last 4 digits of the entered card number.

The project uses environment variables for database settings and secret key.

Future Improvements

Possible improvements:

  • Product images.
  • Product search.
  • Product filtering by type.
  • Quantity update in cart.
  • Better design with CSS.
  • Email confirmation after order.
  • Real payment gateway integration.
  • API version with Django REST Framework.
  • Deployment to server.

Author

Created as a Django learning project.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages