Installation Guide
Complete guide to setting up ModestWear API locally for development.
Prerequisites
Python: 3.11 or higher
PostgreSQL: 15 or higher
Redis: 7.0 or higher (optional for caching)
Git: For cloning repository
Quick Setup
1. Clone Repository
git clone https://github.com/yourusername/modestwear.git
cd modestwear
2. Create Virtual Environment
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate
3. Install Dependencies
cd modestwear
pip install -r requirements.txt
4. Configure Environment Variables
Create .env file in modestwear/core/ directory:
# Django Settings
SECRET_KEY=your-secret-key-here-generate-with-django
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/modestwear
# Redis (optional for development)
REDIS_URL=redis://127.0.0.1:6379/1
CELERY_BROKER_URL=redis://127.0.0.1:6379/0
CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0
# Email (Gmail SMTP)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-app-password
# Cloudinary (optional for development)
CLOUDINARY_URL=cloudinary://api_key:api_secret@cloud_name
# Social Auth
GOOGLE_CLIENT_ID=your-google-client-id
FACEBOOK_APP_ID=your-facebook-app-id
# Frontend URL
FRONTEND_URL=http://localhost:3000
5. Setup Database
# Create PostgreSQL database
createdb modestwear
# Or using psql
psql -U postgres
CREATE DATABASE modestwear;
\q
6. Run Migrations
python manage.py migrate
7. Create Superuser
python manage.py createsuperuser
8. Load Sample Data (Optional)
python manage.py loaddata fixtures/sample_data.json
9. Run Development Server
python manage.py runserver
API will be available at: http://localhost:8000
Detailed Setup
PostgreSQL Setup
Windows
Download PostgreSQL from postgresql.org
Install with default settings
Remember the password for
postgresuserAdd PostgreSQL bin to PATH
# Create database
psql -U postgres
CREATE DATABASE modestwear;
CREATE USER modestwear_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE modestwear TO modestwear_user;
\q
macOS
# Install via Homebrew
brew install postgresql@15
brew services start postgresql@15
# Create database
createdb modestwear
Linux (Ubuntu/Debian)
# Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contrib
# Start service
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database
sudo -u postgres psql
CREATE DATABASE modestwear;
CREATE USER modestwear_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE modestwear TO modestwear_user;
\q
Redis Setup (Optional)
Windows
Download Redis from redis.io
Or use WSL:
wsl --installIn WSL:
sudo apt install redis-server
macOS
brew install redis
brew services start redis
Linux
sudo apt install redis-server
sudo systemctl start redis
sudo systemctl enable redis
Cloudinary Setup (Optional)
Sign up at cloudinary.com
Get your
CLOUDINARY_URLfrom dashboardAdd to
.envfile
For local development, you can skip Cloudinary and use local media storage.
Google OAuth Setup
Go to Google Cloud Console
Create new project
Enable Google+ API
Create OAuth 2.0 credentials
Add authorized origins:
http://localhost:8000http://localhost:3000
Copy Client ID to
.env
Project Structure
modestwear/
├── core/ # Project settings
│ ├── settings.py
│ ├── urls.py
│ ├── wsgi.py
│ └── .env # Environment variables
├── apps/ # Application modules
│ ├── users/ # Authentication & profiles
│ │ ├── models.py
│ │ ├── serializers.py
│ │ ├── auth/ # Auth logic
│ │ └── verification/ # Email verification
│ ├── catalog/ # Product catalog
│ │ ├── models.py
│ │ ├── views.py
│ │ └── services.py
│ ├── orders/ # Cart & orders
│ │ ├── models.py
│ │ └── views.py
│ └── outfits/ # Outfit builder
│ ├── models.py
│ └── views.py
├── static/ # Static files
├── media/ # Uploaded files (local)
├── templates/ # Email templates
├── manage.py
└── requirements.txt
Running Tests
# Run all tests
python manage.py test
# Run specific app tests
python manage.py test apps.users
python manage.py test apps.catalog
# Run with coverage
pip install coverage
coverage run --source='.' manage.py test
coverage report
coverage html # Generate HTML report
Development Tools
Django Admin
Access at: http://localhost:8000/admin/
Login with superuser credentials created earlier.
API Documentation
Swagger UI:
http://localhost:8000/docs/ReDoc:
http://localhost:8000/redoc/
Django Shell
python manage.py shell
# Example: Create test data
from apps.catalog.models import Category, Product
category = Category.objects.create(name="Dresses", slug="dresses")
Database Shell
python manage.py dbshell
Common Issues
Issue: ModuleNotFoundError
Solution:
pip install -r requirements.txt
Issue: Database connection error
Solution:
Check PostgreSQL is running
Verify DATABASE_URL in .env
Test connection:
psql -U modestwear_user -d modestwear
Issue: Redis connection error
Solution:
Check Redis is running:
redis-cli ping(should return PONG)Or disable Redis in settings for development
Issue: Email not sending
Solution:
Use Gmail App Password (not regular password)
Enable “Less secure app access” or use App Password
Or use console backend for development:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Issue: Static files not loading
Solution:
python manage.py collectstatic
Development Workflow
1. Create Feature Branch
git checkout -b feature/new-feature
2. Make Changes
Edit code, add features, fix bugs.
3. Run Tests
python manage.py test
4. Check Code Quality
# Install tools
pip install flake8 black
# Format code
black .
# Check linting
flake8 .
5. Commit Changes
git add .
git commit -m "Add new feature"
6. Push and Create PR
git push origin feature/new-feature
Environment-Specific Settings
Development
# core/settings.py
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Staging
DEBUG = False
ALLOWED_HOSTS = ['staging.modestwear.com']
SECURE_SSL_REDIRECT = True
Production
DEBUG = False
ALLOWED_HOSTS = ['modestwear.onrender.com', 'modestwear.com']
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 31536000
Next Steps
Read Authentication Guide
Explore API Endpoints
Learn about Deployment