Modern Django REST API backend with support for multiple frontends (React, Svelte, etc.). Built with scalability, performance, and developer experience in mind.
Backend:
- Django 4.2+ (Python 3.10+)
- Django REST Framework
- PostgreSQL
- Redis
- Celery (async tasks & scheduling)
- Docker & Docker Compose
Features:
- JWT Authentication (rest_framework_simplejwt)
- CORS support
- API documentation (drf-spectacular with Swagger UI)
- Celery for background tasks
- Comprehensive logging
- Security best practices built-in
- Python 3.10+
- Docker & Docker Compose
- Git
git clone https://github.com/KLWS-Affiliate-Program/practicing-Svelte.git
cd Project\ Horizon- VS Code will prompt you to install recommended extensions
- Click "Install All" or manually install extensions from
.vscode/extensions.json
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate# From pyproject.toml
pip install -e ".[dev]"
# Or from requirements.txt
pip install -r requirements.txt# Copy example env file
cp .env.example .env
# Update .env with your local settings if neededOption A: Using Docker Compose (Recommended)
# Start all services (PostgreSQL, Redis, Django, Celery, Celery Beat)
docker compose up -d
# Run migrations
docker compose exec web python manage.py migrate
# Create superuser
docker compose exec web python manage.py createsuperuser
# Load fixtures (if available)
docker compose exec web python manage.py loaddata fixtures/initial_data.jsonOption B: Using VS Code Task (if configured)
- Open the Command Palette:
Ctrl/Cmd + Shift + P - Run:
βΆοΈ START: Full Dev Environment
Option C: Manual Local Setup
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver- Django Admin: http://localhost:8000/admin/
- API Root: http://localhost:8000/api/v1/
- API Documentation: http://localhost:8000/api/docs/
- Schema (OpenAPI): http://localhost:8000/api/schema/
Project Horizon/
βββ config/ # Project settings & configuration
β βββ __init__.py
β βββ settings.py # Django settings
β βββ urls.py # URL routing
β βββ wsgi.py # WSGI for production
β βββ asgi.py # ASGI for WebSockets
β βββ celery.py # Celery configuration
β
βββ apps/ # Django applications
β βββ __init__.py
β βββ urls.py # API endpoint routing
β
βββ tests/ # Test suite
β βββ __init__.py
β βββ conftest.py # Pytest configuration
β
βββ fixtures/ # Database fixtures
β
βββ static/ # Static files (CSS, JS, images)
βββ media/ # User-uploaded media
βββ logs/ # Application logs
β
βββ manage.py # Django management script
βββ pyproject.toml # Project metadata & dependencies
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker image definition
βββ .gitignore # Git ignore rules
βββ README.md # This file
# Make migrations
python manage.py makemigrations
# Apply migrations
python manage.py migrate
# Create superuser
python manage.py createsuperuser
# Load fixtures
python manage.py loaddata fixtures/initial_data.json
# Collect static files
python manage.py collectstatic# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ -v --cov=. --cov-report=html
# Run specific test file
pytest tests/test_users.py -v
# Run with markers
pytest -v -m "smoke"# Lint with Ruff
ruff check . --fix
# Format with Ruff
ruff format .
# Type check with mypy
mypy apps config# Start services
docker compose up -d
# Stop services
docker compose down
# View logs
docker compose logs -f
# Run command in container
docker compose exec web python manage.py migrate# Start worker
celery -A config worker --loglevel=info
# Start beat scheduler
celery -A config beat --loglevel=info
# With Docker
docker compose up -d celery celery-beatPOST /api/v1/token/ - Get JWT token
POST /api/v1/token/refresh/ - Refresh token
GET /api/schema/ - OpenAPI schema
GET /api/docs/ - Swagger UI
Add your app-specific endpoints in apps/urls.py.
Security is built-in with:
- CSRF protection
- CORS configuration
- Secure headers (HSTS, CSP, X-Frame-Options)
- JWT authentication
- SQL injection prevention (parameterized queries)
- Input validation
Review config/settings.py for production security settings.
Application logs are stored in logs/django.log. Logging is configured in settings.py with:
- Console output for development
- Rotating file handler for production
- Structured logging for errors and requests
docker build -t project-horizon:latest .docker run -p 8000:8000 -e DEBUG=False project-horizon:latestKey dependencies are listed in pyproject.toml:
- Django & DRF
- JWT authentication
- PostgreSQL driver
- Redis client
- Celery
- API documentation tools
See pyproject.toml for complete list including dev dependencies.
Tests are configured with pytest. Example test structure:
# tests/test_example.py
import pytest
from django.test import Client
@pytest.mark.django_db
def test_api_endpoint():
client = Client()
response = client.get('/api/v1/example/')
assert response.status_code == 200- Create a feature branch:
git checkout -b feature/your-feature - Write tests for your changes
- Format code:
ruff format . - Lint:
ruff check . --fix - Run tests:
pytest tests/ - Commit:
git commit -am "feat: your feature" - Push:
git push origin feature/your-feature - Create a Pull Request
MIT License - See LICENSE file for details
KLWS Affiliate Program
For issues and questions, open a GitHub issue or contact the team.
Happy coding! π