# Schon

![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)
![Django 5.2](https://img.shields.io/badge/django-5.2-green.svg)
![License](https://img.shields.io/badge/license-Custom-red.svg)
![Version](https://img.shields.io/badge/version-2026.1-purple.svg)

<p align="center">
  <img src="engine/core/static/logo.png" alt="Schon Logo" width="200"/>
</p>

**Schon** is a production-ready e-commerce backend. Storefront, product catalog, cart, orders, and payments work out of the box. Minimal complexity, maximum flexibility.

---

## What is Schon?

Schon is a complete backend solution for online stores. Whether you're launching a small shop or scaling a marketplace, Schon provides the foundation:

- **Ready to use** - Clone, configure, deploy. No assembly required.
- **API-first** - REST and GraphQL endpoints for any frontend framework.
- **Multilingual** - 28 languages supported out of the box.
- **Extensible** - Modular Django apps, easy to customize.

---

## Features

| Category | Details |
|----------|---------|
| **Framework** | Django 5.2, Django REST Framework 3.16, Graphene-Django |
| **Database** | PostgreSQL with PostGIS, Redis caching, Elasticsearch search |
| **Tasks** | Celery workers with Redis broker, scheduled tasks with Beat |
| **Auth** | JWT authentication, rate limiting, custom user model (email-based) |
| **APIs** | REST + GraphQL, Swagger/ReDoc documentation |
| **i18n** | 28 languages, model translation support |
| **Deployment** | Docker Compose or native Linux with systemd |

---

## Quick Start

### Prerequisites

- Git
- Docker and Docker Compose **or** Linux with Python 3.12+, PostgreSQL, Redis, Elasticsearch

### Docker (Recommended for Development)

```bash
# Clone the repository
git clone https://git.wiseless.xyz/fureunoir/schon
cd schon

# Generate environment file
make generate-env

# Review and adjust .env as needed
nano .env

# Install (pull and build images)
make install

# Start all services
make run
```

### Native Linux (Production)

```bash
# Clone to /opt/schon
sudo git clone https://git.wiseless.xyz/fureunoir/schon /opt/schon
cd /opt/schon

# Generate environment file
make generate-env

# Review and adjust .env
sudo nano .env

# Install (creates schon user, syncs dependencies, configures systemd)
sudo make install
# Select option 2: Native Linux

# Start services
sudo systemctl start schon-web schon-worker schon-beat schon-stock-updater
```

### Storefronts

The `main` branch ships backend-only. For a complete store with frontend:

```bash
git checkout storefront-<nuxt|next|sk|qwik>
```

---

## Configuration

### Environment Variables

After running `make generate-env`, review `.env`:

| Variable | Description |
|----------|-------------|
| `DEBUG` | Set to `0` for production |
| `SECRET_KEY` | Django secret key (auto-generated) |
| `JWT_SIGNING_KEY` | JWT token signing key (auto-generated) |
| `POSTGRES_*` | Database credentials |
| `REDIS_PASSWORD` | Redis authentication |
| `SCHON_PROJECT_NAME` | Your store name |
| `SCHON_BASE_DOMAIN` | Your domain (e.g., `example.com`) |

### Nginx

1. Copy the example config:
   ```bash
   sudo cp nginx.example.conf /etc/nginx/sites-available/schon
   ```

2. Update domain names and paths in the config

3. Enable the site:
   ```bash
   sudo ln -s /etc/nginx/sites-available/schon /etc/nginx/sites-enabled/
   ```

4. Obtain SSL certificates:
   ```bash
   sudo certbot --nginx -d api.yourdomain.com -d yourdomain.com -d www.yourdomain.com
   ```

5. Reload Nginx:
   ```bash
   sudo systemctl reload nginx
   ```

### DNS Records

Configure these DNS records pointing to your server:

- `yourdomain.com` (A record)
- `www.yourdomain.com` (A or CNAME)
- `api.yourdomain.com` (A or CNAME)
- `prometheus.yourdomain.com` (A or CNAME, optional)

---

## API Documentation

Once running, access the API documentation:

| Endpoint | Description |
|----------|-------------|
| `http://api.localhost:8000/` | API root / Admin redirect |
| `http://api.localhost:8000/docs/swagger/` | Swagger UI |
| `http://api.localhost:8000/docs/redoc/` | ReDoc |
| `http://api.localhost:8000/graphql/` | GraphQL Playground |
| `http://api.localhost:8000/admin/` | Django Admin |
| `http://api.localhost:8000/health/` | Health check endpoint |

Authentication header: `X-SCHON-AUTH: Bearer <token>`

---

## Development

### Commands

```bash
make run              # Start services
make restart          # Restart services
make test             # Run tests with coverage
make format           # Format code with Ruff
make check            # Lint code with Ruff
make typecheck        # Type check with ty
make precommit        # Run format, check, typecheck
make make-messages    # Extract translation strings
make compile-messages # Compile translations
make backup           # Create database backup
```

### Running Migrations

```bash
# Docker
docker compose exec app uv run python manage.py migrate

# Native
cd /opt/schon && .venv/bin/python manage.py migrate
```

### Creating a Superuser

```bash
# Docker
docker compose exec app uv run python manage.py createsuperuser

# Native
cd /opt/schon && .venv/bin/python manage.py createsuperuser
```

---

## Project Structure

```
schon/
├── schon/                 # Django project settings
│   ├── settings/          # Split settings (base, drf, celery, etc.)
│   ├── middleware.py      # Custom middleware
│   └── urls.py            # URL routing
├── engine/                # Django apps
│   ├── core/              # Products, orders, categories, vendors
│   ├── payments/          # Transactions, payment gateways
│   ├── vibes_auth/        # Custom User model, JWT auth
│   └── blog/              # Blog posts
├── Dockerfiles/           # Docker configurations
├── systemd/               # Systemd service files
├── scripts/               # Installation and utility scripts
└── nginx.example.conf     # Nginx configuration template
```

---

## Feedback & Issues

We value your feedback. Please open issues for:

- Bug reports
- Feature suggestions
- Questions about usage

**Issue Tracker:** [Plane](https://plane.wiseless.xyz/spaces/issues/dd33cb0ab9b04ef08a10f7eefae6d90c/?board=kanban)

Due to licensing restrictions, we cannot accept pull requests. See the LICENSE file for details.

---

## License

Schon is released under a custom license. Key points:

- **Non-commercial use**: Free for personal, academic, and non-commercial purposes
- **Commercial use**: Requires written authorization or automatic 8% royalty

See the [LICENSE](LICENSE) file for complete terms.

---

## Contact

**Author:** Egor "fureunoir" Gorbunov

- Email: [contact@fureunoir.com](mailto:contact@fureunoir.com)
- Telegram: [@fureunoir](https://t.me/fureunoir)

---

<p align="center">
  <sub>Built with care by the Wiseless Team</sub>
</p>
