This repository contains both the backend and frontend components of an e-commerce application. The backend is built with Django REST Framework, while the frontend utilizes Vue.js with TypeScript.
- Django
- MySQL (default database)
class Product:
name: str # max 40 characters
price: int # positive integer
description: str # text field with default
quantity_in_stock: int # positive integer, default 0
rating: int # 1-5 scale
image: str # image URL/data
slug: str # auto-generated from name
- Automatic slug generation for SEO-friendly URLs (not done to completion)
- RESTful API endpoints
- Vue.js 3
- TypeScript
- Vue Router
- Pinia (State Management)
- SCSS
src/
├── assets/ # Static assets
├── components/ # Reusable Vue components
├── router/ # Route definitions
├── state/ # Pinia stores
└── views/ # Page components
// State
userCart: CartItem[] // Stores cart items
name: string // User name
// Actions
addProductToCart() // Add/update cart items
clearCart() // Reset cart state
// Getters
cartTotal // Calculate total cart value
- User interactions trigger actions
- Actions modify state
- Components react to state changes
- UI updates automatically
- Responsive header with logo
- Main navigation menu
- Dynamic routing system
- Product listings
- Product details
- Mobile-first approach
- Flexbox layout system
- Bootstrap utility classes
- Custom SCSS styling
- Backend Environment Setup
Create a
.env
file in the root directory of the backend project:
# Django Settings
DEBUG=True
SECRET_KEY=your_secret_key_here
ALLOWED_HOSTS=localhost,127.0.0.1
# Database Configuration (if using custom database)
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your_db_host
DB_PORT=your_db_port
# CORS Settings
CORS_ALLOWED_ORIGINS=['http://localhost:5173']
# Static Files
STATIC_URL=/static/
MEDIA_URL=/media/
- Never commit
.env
files to version control - Make sure to add
.env
to your.gitignore
file
- Backend Setup
# Create virtual environment
python -m venv env
source env/bin/activate # Linux/Mac
.\env\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run migrations
python manage.py migrate
# Start server
python manage.py runserver
- Frontend Setup
# Install dependencies
cd frontend
npm install
# Start development server
npm run dev
- Follow Django's conventions
- Write docstrings for complex functions
- Use TypeScript for type safety
- Implement component-based architecture
- Follow Vue.js composition API patterns
- Maintain centralized state management
- Use consistent indentation
- Follow naming conventions
- Write clear comments
- Keep components focused and reusable
- GET /api/v1/products/ - List all products
-
- GET /api/v1/products/{id}/ - Get single product by the id
- GET /api/v1/products/{slug}/ - Get single product (wasn't completely implemented)
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request