Skip to content

buildlyio/django-service-wizard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Django Service Wizard πŸ§™β€β™‚οΈ

Generate production-ready Django microservices for Buildly Core in minutes.

The Django Service Wizard is an interactive command-line tool that scaffolds complete Django microservices with best practices, Docker support, API documentation, and seamless Buildly Core integration. No more manual setup - just describe your service and get a fully configured project ready for development.

License: MIT Python Version Django Version

✨ What Gets Generated

The wizard creates a complete Django microservice with:

  • πŸ—οΈ Django Project Structure - Properly organized settings, apps, and configurations
  • 🐳 Docker Support - Dockerfile, docker-compose.yml, and production-ready containers
  • πŸ“Š API Documentation - Swagger/OpenAPI integration with interactive docs
  • πŸ”§ Buildly Core Integration - Pre-configured for seamless service discovery
  • ⚑ Health Checks - Built-in health monitoring endpoints
  • πŸ”’ Security - JWT authentication, CORS, and permission handling
  • πŸ“ CI/CD Ready - Travis CI configuration and Docker registry support
  • πŸ› οΈ Development Tools - Gunicorn, static files handling, and environment configs

πŸš€ Quick Start

Prerequisites

  • Docker and docker-compose
  • 2GB+ available disk space
  • Internet connection for downloading dependencies

Generate Your Service

# Clone or navigate to the django-service-wizard directory
cd django-service-wizard

# Run the interactive wizard
docker-compose run --rm django_service_wizard

# Follow the prompts:
# 1. Service name (e.g., "customer_service")  
# 2. Application name (e.g., "customer")
# 3. Docker support? (Y/n) 
# 4. Travis CI? (y/N)
# 5. Swagger docs? (Y/n)
# 6. Service display name (e.g., "Customer Management Service")
# 7. Service description

# Your new service is ready!

Example Interaction

Welcome to the Buildly Core (Micro)Service wizard!
 _           _ _     _ _
| |__  _   _(_) | __| | |_   _  
| '_ \| | | | | |/ _` | | | | |
| |_) | |_| | | | (_| | | |_| |
|_.__/ \__,_|_|_|\__,_|_|\__, |
                         |___/

Type in the name of your service (e.g.: appointments_service): customer_service
βœ… The Django project "customer_service" was successfully created

Type in the name of your application (e.g.: appointment): customer  
βœ… Django application "customer" was successfully created

Add Docker support? (y/N): y
βœ… Docker support added successfully

Add travis CI test support? (y/N): n

Add Swagger docs? (Y/n): y
Type in the displayed Name of your service: Customer Management Service
Type in the description of your service: A microservice for managing customer data and profiles

βœ… Great! Your new project "customer_service" is ready!

πŸ“ Generated Project Structure

customer_service/
β”œβ”€β”€ πŸ“„ README.md                    # Project documentation
β”œβ”€β”€ 🐳 Dockerfile                   # Production container
β”œβ”€β”€ 🐳 docker-compose.yml          # Development environment  
β”œβ”€β”€ βš™οΈ manage.py                    # Django management
β”œβ”€β”€ πŸ“‹ requirements/                # Dependencies
β”‚   β”œβ”€β”€ base.txt                   # Core requirements
β”‚   └── production.txt             # Production requirements
β”œβ”€β”€ πŸ“‚ customer/                    # Django application
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ admin.py                   # Django admin
β”‚   β”œβ”€β”€ apps.py                    # App configuration
β”‚   β”œβ”€β”€ models.py                  # Database models
β”‚   β”œβ”€β”€ serializers.py             # API serializers
β”‚   β”œβ”€β”€ views.py                   # API views
β”‚   β”œβ”€β”€ urls.py                    # URL routing
β”‚   └── migrations/                # Database migrations
β”œβ”€β”€ πŸ“‚ customer_service/            # Project configuration
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ permissions.py             # Custom permissions
β”‚   β”œβ”€β”€ gunicorn_conf.py          # Gunicorn configuration
β”‚   β”œβ”€β”€ urls.py                   # Main URL configuration
β”‚   β”œβ”€β”€ wsgi.py                   # WSGI application
β”‚   └── settings/                 # Settings modules
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ base.py              # Base settings
β”‚       └── production.py        # Production settings
β”œβ”€β”€ πŸ”§ scripts/                    # Utility scripts
β”‚   β”œβ”€β”€ run-collectstatic.sh      # Static files collection
β”‚   β”œβ”€β”€ run-tests.sh              # Test runner
β”‚   └── wait-for-it.sh            # Service dependency waiting
└── πŸ“Š .travis.yml                 # CI/CD configuration (optional)

πŸ”§ Features in Detail

πŸ—οΈ Django Best Practices

  • Modular Settings - Separate base and production configurations
  • Application Structure - Clean separation of concerns
  • Database Ready - PostgreSQL configuration with environment variables
  • Static Files - Proper handling for production deployment

🐳 Docker Integration

  • Multi-stage Build - Optimized container sizes
  • Development Mode - Hot reload and debugging support
  • Production Ready - Gunicorn, security headers, static files
  • Health Checks - Container health monitoring

πŸ“Š API Documentation

  • Swagger UI - Interactive API documentation at /swagger/
  • ReDoc - Alternative documentation view at /redoc/
  • Schema Generation - Automatic OpenAPI schema from Django models
  • Authentication - JWT token support in documentation

πŸ”’ Security & Authentication

  • Buildly Core Integration - Seamless JWT authentication
  • CORS Configuration - Cross-origin resource sharing setup
  • Permission Classes - Custom permission handling
  • Environment Variables - Secure configuration management

🚦 Usage Examples

Basic Service Creation

docker-compose run --rm django_service_wizard

# Minimal setup - just Django + Docker
Service name: inventory_service
App name: inventory  
Docker support: Y
Travis CI: N
Swagger docs: Y

Full-Featured Service

docker-compose run --rm django_service_wizard

# Complete setup with CI/CD
Service name: order_processing_service
App name: order
Docker support: Y
Travis CI: Y
Docker registry: Y
Registry domain: hub.docker.com
Registry folder: mycompany
Swagger docs: Y

Custom Volume Mounting

# Generate service in specific directory
docker-compose run --rm \
  -v "/path/to/output:/code" \
  django_service_wizard

πŸ› οΈ Development Workflow

1. Generate Service

docker-compose run --rm django_service_wizard

2. Start Development

cd your_service_name
docker-compose up -d

# Your service is now running at:
# - API: http://localhost:8000/
# - Swagger: http://localhost:8000/swagger/  
# - Admin: http://localhost:8000/admin/

3. Add Your Models

# your_service/your_app/models.py
from django.db import models

class Customer(models.Model):
    name = models.CharField(max_length=100)
    email = models.EmailField()
    created_at = models.DateTimeField(auto_now_add=True)

4. Create API Endpoints

# your_service/your_app/serializers.py  
from rest_framework import serializers
from .models import Customer

class CustomerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Customer
        fields = '__all__'

# your_service/your_app/views.py
from rest_framework import viewsets
from .models import Customer
from .serializers import CustomerSerializer

class CustomerViewSet(viewsets.ModelViewSet):
    queryset = Customer.objects.all()
    serializer_class = CustomerSerializer

5. Deploy to Buildly Core

The generated service is pre-configured to work with Buildly Core's service discovery and authentication.

πŸ§ͺ Testing

Run Tests Locally

# Inside your generated service directory
docker-compose exec web python manage.py test

# Or using the provided script
docker-compose exec web ./scripts/run-tests.sh

Test the Wizard Itself

# Test the wizard code
docker-compose run --entrypoint 'python -m unittest discover' --rm django_service_wizard

# Build and test
docker-compose build
docker-compose run --rm django_service_wizard --help

πŸ—οΈ Templates & Customization

Available Templates

  • Docker - Multi-stage Dockerfile with production optimizations
  • Settings - Django settings split for different environments
  • Scripts - Utility scripts for deployment and maintenance
  • CI/CD - Travis CI configuration with Docker registry support
  • Documentation - README template with service-specific content

Customizing Templates

Edit files in service_builder/templates/ to customize the generated output:

service_builder/templates/
β”œβ”€β”€ conf/gunicorn_conf.py          # Gunicorn configuration
β”œβ”€β”€ docker/Dockerfile              # Container definition
β”œβ”€β”€ readme/README.md               # Project documentation template  
β”œβ”€β”€ requirements/base.txt          # Python dependencies
β”œβ”€β”€ scripts/                       # Utility scripts
└── settings/                      # Django settings templates

πŸ”§ Configuration

Environment Variables (Generated Services)

# Database Configuration
DATABASE_ENGINE=django.db.backends.postgresql
DATABASE_NAME=your_service_db
DATABASE_USER=your_user
DATABASE_PASSWORD=your_password  
DATABASE_HOST=localhost
DATABASE_PORT=5432

# Buildly Core Integration
BUILDLY_CORE_URL=http://buildly-core:8080
JWT_SECRET_KEY=your-jwt-secret

# Django Configuration
DEBUG=False
SECRET_KEY=your-secret-key
ALLOWED_HOSTS=localhost,127.0.0.1

Docker Compose Override

# docker-compose.override.yml (in generated service)
version: '3.7'
services:
  web:
    environment:
      - DEBUG=True
    volumes:  
      - .:/code
    ports:
      - "8000:8000"

πŸš€ Production Deployment

Using Docker

# Build production image
docker build -t your-service:latest .

# Run in production
docker run -d \
  --name your-service \
  -p 8000:8000 \
  -e DATABASE_URL=postgresql://... \
  your-service:latest

Using Kubernetes

apiVersion: apps/v1
kind: Deployment
metadata:
  name: your-service
spec:
  replicas: 3
  selector:
    matchLabels:
      app: your-service
  template:
    metadata:
      labels:
        app: your-service
    spec:
      containers:
      - name: web
        image: your-service:latest
        ports:
        - containerPort: 8000

πŸ“š Documentation

🀝 Contributing

We welcome contributions! Here's how you can help:

  1. Report Bugs - Found an issue? Open a GitHub issue
  2. Improve Templates - Enhance the generated code templates
  3. Add Features - New wizard options or integrations
  4. Documentation - Help improve our guides and examples

Development Setup

# Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/django-service-wizard.git
cd django-service-wizard

# Make changes to templates or wizard code
# Test your changes
docker-compose build
docker-compose run --rm django_service_wizard

# Submit a Pull Request

πŸ“‹ Requirements

System Requirements

  • Docker 20.10+ and docker-compose 1.29+
  • Python 3.8+ (for development)
  • Git (for version control)

Generated Service Requirements

  • Django 4.2+ (specified in requirements/base.txt)
  • PostgreSQL 12+ (recommended database)
  • Redis (for caching, optional)

βš–οΈ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

  • Documentation - Check our docs folder for detailed guides
  • GitHub Issues - Report bugs and request features
  • Community - Join the Buildly Discord community
  • Professional Support - Contact enterprise@buildly.io

Ready to build your first microservice? Get started now! πŸš€

About

Django (Micro)Service wizard for the Buildly Core & CLI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5