Skip to content
Go back

Django + Next.js SaaS Starter Template with AI Agents

I’ve built the same Django + Next.js boilerplate 47 times. Authentication, Docker, TypeScript, API endpoints, deployment scripts. Over and over.

Last month I finally snapped and built an open source starter template that includes everything. Plus seven Claude Code agents that actually understand your codebase.

This Django Next.js tutorial shows you how to bootstrap a full-stack SaaS app in 2025.

Table of contents

Open Table of contents

Why Another Django Next.js Boilerplate?

I tried several Django Next.js starter templates and cookiecutters on the internet. Most boilerplates fall apart when you need:

This Django Next.js starter template is different. It’s what I actually use to ship production SaaS apps. I’ll admit it’s fairly opinionated but it works great for me. Hope it’s useful to you too.

Key features of this open source boilerplate:

The Stack That Actually Ships

Django Next.js Example: From Zero to Running App

1. Clone and Setup

# Clone the template
gh repo create my-ai-app --template code-geek/ai-project-template --public
cd my-ai-app

# Run the setup script (installs everything)
./scripts/setup-dev.sh

That’s it. The setup script:

2. Start Development

# Using Docker (recommended)
docker-compose up

# Or run separately
cd backend && uv run python manage.py runserver
cd frontend && npm run dev

Your app is now running:

3. See It Work

The template includes a working example API. Try it:

# Health check
curl http://localhost:8000/api/health

# Example endpoint
curl http://localhost:8000/api/example/hello/world

Why This Template Is Different

1. AI-Optimized from Day One

Every file has purpose-built instructions for Claude:

# backend/CLAUDE.md
- Models live in `apps/*/models.py`
- API endpoints use Django Ninja in `apps/*/api.py`
- Business logic goes in `apps/*/services.py`
- Always run tests after changes

2. Specialized AI Agents

Seven Claude agents that activate automatically:

Example: Just ask “review this code” and the code-reviewer agent activates.

3. Production-Structured, Not a Toy

# docker-compose.yml includes:
- PostgreSQL 16 with health checks
- Redis for caching
- Celery infrastructure included (configuration coming soon)
- Proper networking and volumes

4. Modern Python with uv

Forget pip. Forget poetry. Forget waiting.

# Old way (30 seconds)
pip install django djangorestframework pytest ...

# New way (0.3 seconds)
uv sync

Your CI builds just got 10x faster.

5. Django Ninja > Django REST Framework

Django Ninja gives you FastAPI-style development with Django’s stability:

# Django REST Framework way (verbose)
class TaskSerializer(serializers.ModelSerializer):
    class Meta:
        model = Task
        fields = ['id', 'title', 'completed']

class TaskViewSet(viewsets.ModelViewSet):
    queryset = Task.objects.all()
    serializer_class = TaskSerializer

# Django Ninja way (clean)
@router.get("/tasks", response=List[TaskSchema])
def list_tasks(request):
    return Task.objects.all()

Django Ninja provides FastAPI-style development with Django’s stability. It offers high performance through Pydantic and async support, with automatic OpenAPI docs and type hints built-in.

Django Next.js Tutorial: Build Your First Feature

Let’s add a simple task tracker API:

1. Create the Model

# backend/apps/tasks/models.py
from django.db import models

class Task(models.Model):
    title = models.CharField(max_length=200)
    completed = models.BooleanField(default=False)
    created = models.DateTimeField(auto_now_add=True)

2. Add the API Endpoint

# backend/apps/tasks/api.py
from ninja import Router
from .models import Task

router = Router()

@router.get("/tasks")
def list_tasks(request):
    return list(Task.objects.values())

@router.post("/tasks")
def create_task(request, title: str):
    task = Task.objects.create(title=title)
    return {"id": task.id, "title": task.title}

3. Frontend Component

// frontend/src/components/features/TaskList.tsx
export function TaskList() {
  const { data: tasks } = useSWR('/api/tasks')
  
  return (
    <div className="space-y-2">
      {tasks?.map(task => (
        <div key={task.id} className="p-4 border rounded">
          {task.title}
        </div>
      ))}
    </div>
  )
}

That’s a full-stack feature in your Django Next.js boilerplate. No configuration needed. This starter template handles all the setup complexity.

Deploy to Production

Option 1: Docker Anywhere

# Build production images
docker-compose -f docker-compose.prod.yml build

# Deploy to your server
docker-compose -f docker-compose.prod.yml up -d

Option 2: AWS (ECS/EC2)

The template includes a deployment script with AWS placeholders:

# Configure AWS credentials
aws configure

# Deploy script included (customize for your AWS setup)
./scripts/deploy.sh production

Option 3: Vercel + Railway

What You Get Out of the Box

Authentication Structure: User models and auth setup (JWT coming soon)
Type Safety: TypeScript + mypy + strict mode
Code Quality: Pre-commit hooks for Python + JS
Testing: pytest + Playwright configured
API Docs: Auto-generated OpenAPI specs
Admin Panel: Django admin pre-configured
Hot Reload: Both frontend and backend

Common Customizations

Remove What You Don’t Need

# Don't need Celery?
# Delete from docker-compose.yml:
- celery
- celery-beat
- redis

# Don't need authentication?
# Remove backend/apps/users/

Add Your Preferred Tools

# Want GraphQL instead of REST?
cd backend && uv add strawberry-graphql

# Want Prisma instead of Django ORM?
cd backend && npm install prisma

Change the Database

# backend/config/settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',  # or mongodb
        # ...
    }
}

The Fast Path to Shipping

  1. Clone the template → 30 seconds
  2. Run setup script → 2-3 minutes
  3. Start coding features → Immediately
  4. Deploy to production → Varies by platform

If you have suggestions, please open an issue or better yet, send a PR!

I’ve built and deployed several SaaS apps in 1-2 days using this Django Next.js starter template. You can too.

Get the open source boilerplate: github.com/code-geek/ai-project-template

Now go build something.


Share this post on:

Previous Post
Restore PyCharm Scratch Files After Upgrading Versions
Next Post
Ship Your Developer Blog in 30 Minutes with Cloudflare and Astro