๐Ÿ’ป Developer Documentation

Technical documentation for Renewed Renaissance Saleor platform

๐Ÿ—๏ธ Architecture Overview

๐Ÿ Backend

Saleor 3.20

  • Python 3.11
  • Django 4.2
  • GraphQL (Graphene)
  • Gunicorn + Uvicorn

๐Ÿ“Š Database

PostgreSQL 16

  • Alpine Linux base
  • Custom healthchecks
  • Automated backups

โšก Cache & Queue

Redis 7.2

  • Session storage
  • Celery broker
  • Cache backend

๐Ÿ”„ Task Queue

Celery

  • Background jobs
  • Async processing
  • Scheduled tasks

๐ŸŒ Web Server

Nginx Alpine

  • Reverse proxy
  • Path-based routing
  • Static file serving

๐Ÿ“ฆ Containerization

Docker Compose

  • Multi-container orchestration
  • Health checks
  • Network isolation

๐Ÿš€ Frontend

Saleor Dashboard 3.20

  • React 18
  • TypeScript
  • Material-UI

๐Ÿ”’ Security

Cloudflare Tunnel

  • Zero-trust access
  • No exposed ports
  • DDoS protection

๐ŸŒ API Endpoints

GraphQL API

POST https://www.renewed-renaissance.com/graphql/

Main GraphQL endpoint for all queries and mutations

GET https://www.renewed-renaissance.com/graphql/

GraphQL Playground (interactive documentation)

Health & Status

GET https://www.renewed-renaissance.com/health/

API health check endpoint

Static Assets

GET https://www.renewed-renaissance.com/static/

Static files (CSS, JS, fonts)

GET https://www.renewed-renaissance.com/media/

Product images and uploaded media

๐Ÿ”ง Development Setup

Prerequisites

Clone Repository

git clone https://bitbucket.org/wilsonify/renewed-renaissance-saleor.git
cd renewed-renaissance-saleor

Environment Setup

# Copy environment template
cp deploy/01_dev/.env.example deploy/01_dev/.env

# Edit configuration
nano deploy/01_dev/.env

Start Development Environment

cd deploy/01_dev
docker-compose up -d

Run Database Migrations

docker-compose exec api python manage.py migrate

Create Superuser

docker-compose exec api python manage.py createsuperuser --noinput
โœ… Development environment ready!
Access the API at http://localhost:8000
Access the dashboard at http://localhost:9000

๐Ÿš€ Deployment

Environment Configuration

Environment Directory Ports URL
Development deploy/01_dev/ 8000, 9000 localhost
Staging deploy/02_stage/ 9080, 9081 stage.renewed-renaissance.com
Production deploy/03_prod/ 8080, 8081 www.renewed-renaissance.com

Deploy to Staging

cd deploy/02_stage

# Start services
docker-compose up -d

# Run migrations
docker-compose exec api python manage.py migrate

# Create superuser (if needed)
docker-compose exec api python manage.py createsuperuser --noinput

# Restart nginx to pick up new container IPs
docker-compose restart nginx

Deploy to Production

cd deploy/03_prod

# Pull latest images
docker-compose pull

# Start services with force recreate
docker-compose up -d --force-recreate

# Run migrations
docker-compose exec api python manage.py migrate

# Collect static files
docker-compose exec api python manage.py collectstatic --noinput
โš ๏ธ Production Deployment Checklist:
  • โœ… Test changes in staging first
  • โœ… Backup database before deploying
  • โœ… Review migration scripts
  • โœ… Update environment variables
  • โœ… Set DEBUG=False
  • โœ… Configure proper SECRET_KEY
  • โœ… Set up RSA_PRIVATE_KEY for JWT
  • โœ… Enable SENTRY_DSN for error tracking

๏ฟฝ๏ธ Product Manager

Declarative Product Management
The Saleor Product Manager is a custom Next.js application that enables managing products via Markdown files. Products are version-controlled and synced to Saleor via GraphQL API.

Product Definition Format

Products are defined as Markdown files in src/saleor-product-manager/products/:

---
name: "Elegant Bloom - Hand-Printed Dahlia Print"
sku: "ELE/PRI/6IN"
price: 180.00
category: "Art Prints"
description: "A stunning hand-printed dahlia artwork..."
trackInventory: true
stockQuantity: 10
tags:
  - art
  - prints
  - dahlia
---

# Elegant Bloom

Additional markdown content for product description...

API Endpoints

Endpoint Method Description
/api/sync POST Sync products from Markdown to Saleor
/api/products GET List all product definitions
/api/validate POST Validate product definitions

Sync Request Example

# Development (port 3001)
curl -X POST http://localhost:3001/api/sync \
  -H "Content-Type: application/json" \
  -d '{
    "environment": "dev",
    "productsDir": "/app/products",
    "dryRun": false
  }'

# Staging (port 3002)
curl -X POST http://localhost:3002/api/sync \
  -H "Content-Type: application/json" \
  -d '{
    "environment": "stage",
    "productsDir": "/app/products",
    "dryRun": false
  }'

Sync Response

{
  "created": [],
  "updated": [
    "Elegant Bloom - Hand-Printed Dahlia Print",
    "Eternal Flight - Handcrafted Origami Crane Print",
    "Ethereal Drift - Handcrafted Jellyfish Print"
  ],
  "skipped": [],
  "deleted": [],
  "errors": [],
  "dryRun": false
}
โœ… Current Status: Product Manager is deployed and syncing products to both Dev and Staging environments.

๏ฟฝ๐Ÿ“ GraphQL Examples

Query: List Products

query ListProducts {
  products(first: 10, channel: "default-channel") {
    edges {
      node {
        id
        name
        slug
        description
        thumbnail {
          url
        }
        variants {
          id
          name
          sku
          pricing {
            price {
              gross {
                amount
                currency
              }
            }
          }
        }
      }
    }
  }
}

Query: Get Product Details

query GetProduct($slug: String!) {
  product(slug: $slug, channel: "default-channel") {
    id
    name
    description
    category {
      name
    }
    images {
      url
      alt
    }
    variants {
      id
      name
      sku
      quantityAvailable
    }
  }
}

# Variables
{
  "slug": "vintage-pocket-watch"
}

Mutation: Create Checkout

mutation CreateCheckout($input: CheckoutCreateInput!) {
  checkoutCreate(input: $input) {
    checkout {
      id
      token
      totalPrice {
        gross {
          amount
          currency
        }
      }
      lines {
        id
        quantity
        variant {
          name
        }
      }
    }
    errors {
      field
      message
    }
  }
}

# Variables
{
  "input": {
    "channel": "default-channel",
    "email": "customer@example.com",
    "lines": [
      {
        "quantity": 1,
        "variantId": "UHJvZHVjdFZhcmlhbnQ6MQ=="
      }
    ]
  }
}

Mutation: Add to Cart

mutation AddToCheckout($checkoutId: ID!, $lines: [CheckoutLineInput!]!) {
  checkoutLinesAdd(
    checkoutId: $checkoutId
    lines: $lines
  ) {
    checkout {
      id
      lines {
        quantity
        variant {
          name
        }
      }
    }
    errors {
      field
      message
    }
  }
}

# Variables
{
  "checkoutId": "Q2hlY2tvdXQ6MQ==",
  "lines": [
    {
      "quantity": 2,
      "variantId": "UHJvZHVjdFZhcmlhbnQ6Mg=="
    }
  ]
}

๐Ÿ” Authentication

Get Auth Token

mutation TokenAuth($email: String!, $password: String!) {
  tokenCreate(email: $email, password: $password) {
    token
    refreshToken
    csrfToken
    user {
      id
      email
      firstName
      lastName
    }
    errors {
      field
      message
    }
  }
}

# Variables
{
  "email": "your-email@example.com",
  "password": "your-password"
}

Use Token in Requests

# Add to request headers
{
  "Authorization": "Bearer YOUR_TOKEN_HERE"
}

Refresh Token

mutation RefreshToken($refreshToken: String!) {
  tokenRefresh(refreshToken: $refreshToken) {
    token
    errors {
      field
      message
    }
  }
}

๐Ÿณ Docker Commands

Container Management

# Start all services
docker-compose up -d

# Stop all services
docker-compose down

# Restart specific service
docker-compose restart api

# View logs
docker-compose logs -f api

# View all service status
docker-compose ps

# Force recreate (reload env vars)
docker-compose up -d --force-recreate api worker

Database Operations

# Run migrations
docker-compose exec api python manage.py migrate

# Create migrations
docker-compose exec api python manage.py makemigrations

# Database shell
docker-compose exec db psql -U saleor saleor

# Backup database
docker-compose exec db pg_dump -U saleor saleor > backup.sql

# Restore database
cat backup.sql | docker-compose exec -T db psql -U saleor saleor

Django Commands

# Django shell
docker-compose exec api python manage.py shell

# Create superuser
docker-compose exec api python manage.py createsuperuser

# Collect static files
docker-compose exec api python manage.py collectstatic --noinput

# Run tests
docker-compose exec api pytest

# Check for issues
docker-compose exec api python manage.py check

๐Ÿ”Œ Environment Variables

Required Variables

Variable Description Example
DATABASE_URL PostgreSQL connection string postgres://user:pass@db:5432/saleor
REDIS_URL Redis connection string redis://:pass@redis:6379/0
SECRET_KEY Django secret key (50+ chars) Generated random string
ALLOWED_HOSTS Comma-separated domains www.renewed-renaissance.com,localhost
ALLOWED_CLIENT_HOSTS Allowed GraphQL clients www.renewed-renaissance.com,localhost

Optional Variables

Variable Description Default
DEBUG Enable debug mode False
SENTRY_DSN Error tracking URL None
EMAIL_URL SMTP configuration smtp://localhost:1025
DEFAULT_FROM_EMAIL Sender email address noreply@example.com
RSA_PRIVATE_KEY JWT signing key Auto-generated in DEBUG

๐Ÿงช Testing

Run Unit Tests

# All tests
docker-compose exec api pytest

# Specific test file
docker-compose exec api pytest tests/test_products.py

# With coverage
docker-compose exec api pytest --cov=saleor

# Verbose output
docker-compose exec api pytest -v

GraphQL Playground

Interactive Testing:
Visit https://www.renewed-renaissance.com/graphql/ to use the GraphQL Playground.
This provides auto-completion, documentation, and query validation.

๐Ÿ“Š Monitoring & Logging

View Logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f api
docker-compose logs -f nginx
docker-compose logs -f worker

# Last 100 lines
docker-compose logs --tail=100 api

# Since specific time
docker-compose logs --since 2025-11-27T10:00:00 api

Container Health

# Check all container statuses
docker-compose ps

# Inspect specific container
docker inspect saleor-api-prod

# Resource usage
docker stats

๐Ÿ”„ CI/CD Integration

Recommended Workflow

  1. Development: Local testing with hot-reload
  2. Staging: Automated deployment on merge to staging branch
  3. Production: Manual deployment after staging approval

GitHub Actions Example

name: Deploy to Staging

on:
  push:
    branches: [staging]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Deploy to staging
        run: |
          ssh user@server 'cd /path/to/deploy/02_stage && \
            docker-compose pull && \
            docker-compose up -d --force-recreate && \
            docker-compose exec -T api python manage.py migrate'

๐Ÿ› Debugging

Common Issues

Issue: API returns 502 Bad Gateway
  • Check if API container is running: docker-compose ps api
  • View API logs: docker-compose logs api
  • Verify database connection
  • Restart nginx: docker-compose restart nginx
Issue: Database migration errors
  • Check database is accessible
  • Review migration files for conflicts
  • Try fake migration: python manage.py migrate --fake
  • Roll back if needed: python manage.py migrate app_name migration_name
Issue: Static files not loading
  • Run collectstatic: python manage.py collectstatic
  • Check STATIC_ROOT and STATIC_URL settings
  • Verify nginx static file configuration

Enable Django Debug Toolbar

# In .env file
DEBUG=True
ENABLE_DEBUG_TOOLBAR=True

# Restart API
docker-compose restart api

๐Ÿ“š Additional Resources

๐Ÿ”— Official Documentation

๐Ÿ› ๏ธ Tools

  • GraphQL Playground (built-in)
  • Docker Desktop
  • Postman/Insomnia