Skip to content

Commit ca7b207

Browse files
heysamtexasclaude
andcommitted
build: migrate from flit_core to hatchling and requirements.txt to pyproject.toml
- Replace flit_core with hatchling build backend for better plugin support - Move dependencies from requirements.txt to pyproject.toml [project.dependencies] - Add dev dependencies to [project.optional-dependencies.dev] - Update Dockerfile to use uv for dependency management instead of pip - Update documentation (README.md, CLAUDE.md, getting_started.md) to reflect changes - Add GitHub Actions release workflow with manual trigger and semantic versioning - Update commitizen configuration for proper tag format (v$version) - Add uv badge to README and update Django version badge to 5.2.3 - Incorporate latest dependabot dependency updates (certifi, typing_extensions, urllib3, ruff) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent af58215 commit ca7b207

File tree

9 files changed

+856
-32
lines changed

9 files changed

+856
-32
lines changed

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Release type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
permissions:
17+
contents: write
18+
id-token: write
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v4
32+
with:
33+
version: "latest"
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: "3.12"
39+
40+
- name: Install dependencies
41+
run: uv sync --extra dev
42+
43+
- name: Run linting
44+
run: uv run ruff check .
45+
46+
- name: Run formatting check
47+
run: uv run ruff format --check .
48+
49+
- name: Run tests
50+
run: uv run src/manage.py test
51+
52+
- name: Configure Git
53+
run: |
54+
git config user.name "github-actions[bot]"
55+
git config user.email "github-actions[bot]@users.noreply.github.com"
56+
57+
- name: Bump version and create changelog
58+
run: |
59+
uv run cz bump --increment ${{ inputs.release_type }} --yes
60+
echo "NEW_VERSION=$(uv run cz version --project)" >> $GITHUB_ENV
61+
62+
- name: Push changes and tags
63+
run: |
64+
git push origin master
65+
git push origin --tags
66+
67+
- name: Generate release notes
68+
run: |
69+
uv run cz changelog --dry-run --incremental > RELEASE_NOTES.md
70+
71+
- name: Create GitHub Release
72+
uses: softprops/action-gh-release@v2
73+
with:
74+
tag_name: v${{ env.NEW_VERSION }}
75+
body_path: RELEASE_NOTES.md
76+
generate_release_notes: true
77+
draft: false
78+
prerelease: false
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Release summary
83+
run: |
84+
echo "🚀 Release v${{ env.NEW_VERSION }} completed successfully!"
85+
echo "📝 Release notes: https://github.com/${{ github.repository }}/releases/tag/v${{ env.NEW_VERSION }}"

CLAUDE.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Django Reference Implementation - a production-ready Django SaaS template with organizations, invitations, and authentication. It follows a pragmatic approach to building multi-tenant applications with minimal dependencies.
8+
9+
## Architecture
10+
11+
### Core Apps Structure
12+
- **config/**: Django project configuration (settings, URLs, WSGI/ASGI)
13+
- **myapp/**: Base application with site configuration models, templates, and management commands
14+
- **organizations/**: Complete multi-tenant organization system with invitations and user management
15+
16+
### Key Components
17+
- **Authentication**: Uses django-allauth with 2FA support
18+
- **Async Processing**: Custom worker pattern using Django management commands with PostgreSQL as task queue
19+
- **Multi-tenancy**: Organization-based tenancy with invitation system
20+
- **Templates**: Bootstrap 5 UI with dark mode support
21+
22+
## Common Commands
23+
24+
### Development Environment
25+
```bash
26+
# Bootstrap development environment
27+
make dev-bootstrap
28+
29+
# Start development services
30+
make dev-start
31+
32+
# Stop development services
33+
make dev-stop
34+
35+
# Restart Django service
36+
make dev-restart-django
37+
```
38+
39+
### Database Operations
40+
```bash
41+
# Run migrations
42+
make migrate
43+
44+
# Create superuser
45+
make superuser
46+
47+
# Database snapshot and restore
48+
make snapshot-local-db
49+
make restore-local-db
50+
```
51+
52+
### Django Management Commands
53+
```bash
54+
# Run with uv (uses local virtual environment)
55+
uv run src/manage.py <command>
56+
57+
# Key management commands:
58+
uv run src/manage.py migrate
59+
uv run src/manage.py createsuperuser
60+
uv run src/manage.py simple_async_worker
61+
uv run src/manage.py send_email_confirmation
62+
uv run src/manage.py send_email_invite
63+
```
64+
65+
### Code Quality
66+
```bash
67+
# Run linting (uses ruff)
68+
uv run ruff check .
69+
70+
# Run formatting
71+
uv run ruff format .
72+
73+
# Run tests
74+
uv run src/manage.py test
75+
```
76+
77+
## Development Workflow
78+
79+
### Local Development
80+
- Uses Docker Compose for services (PostgreSQL, Mailpit, S3Proxy)
81+
- Django can run locally or in Docker
82+
- Environment variables configured in `env` file (copy from `env.sample`)
83+
84+
### Testing
85+
- Tests located in `*/tests/` directories
86+
- Run with `uv run src/manage.py test`
87+
- Covers models, views, and forms
88+
89+
### Worker System
90+
- Custom async worker pattern using Django management commands
91+
- Workers defined in `*/management/commands/`
92+
- Uses PostgreSQL for task queue (no Redis/Celery required)
93+
- Configure workers in `docker-compose.yml`
94+
95+
## Important Files
96+
97+
### Configuration
98+
- `src/config/settings.py`: Main Django settings
99+
- `pyproject.toml`: Project metadata and tool configuration (ruff, bandit)
100+
- `docker-compose.yml`: Development services
101+
- `Makefile`: Development automation commands
102+
103+
### Models
104+
- `myapp/models/`: Site configuration and worker models
105+
- `organizations/models.py`: Organization and invitation models
106+
107+
### Templates
108+
- `templates/`: Global templates (base, auth, pages)
109+
- `myapp/templates/`: App-specific templates
110+
- `organizations/templates/`: Organization management templates
111+
112+
## Code Standards
113+
114+
### Linting
115+
- Uses ruff with strict settings (line length: 120)
116+
- Excludes tests and migrations from most checks
117+
- Full rule set in `pyproject.toml`
118+
119+
### File Organization
120+
- Apps follow Django conventions
121+
- Models in `models/` directory (may be split into multiple files)
122+
- Views in `views/` directory
123+
- Management commands in `management/commands/`
124+
- Templates in `templates/` with app namespacing
125+
126+
## Dependencies
127+
128+
### Dependency Management
129+
- Uses `pyproject.toml` for dependency specification
130+
- Production dependencies in `[project.dependencies]`
131+
- Development dependencies in `[project.optional-dependencies.dev]`
132+
- Install with `uv sync` or `uv sync --extra dev`
133+
134+
### Core Dependencies
135+
- Django 5.2.3
136+
- Python 3.12
137+
- PostgreSQL 16
138+
- django-allauth (authentication)
139+
- django-bootstrap5 (UI)
140+
- django-storages (S3 support)
141+
142+
### Development Dependencies
143+
- ruff (linting/formatting)
144+
- pre-commit (hooks)
145+
146+
## Environment Variables
147+
148+
Key environment variables (defined in `env` file):
149+
- `DEBUG`: Development mode flag
150+
- `SECRET_KEY`: Django secret key
151+
- `BASE_URL`: Application base URL
152+
- `DATABASE_URL`: PostgreSQL connection
153+
- `AWS_*`: S3 configuration
154+
- Email settings for django-allauth
155+
156+
## Deployment
157+
158+
- Docker-based deployment
159+
- Heroku/Dokku ready with `Procfile`
160+
- Static files served by Django or S3
161+
- Uses environment variables for configuration

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
FROM python:3.12-slim
22

3-
COPY requirements.txt /
4-
RUN pip install --no-cache-dir --upgrade pip
5-
RUN pip install --no-cache-dir -r /requirements.txt
3+
# Install uv
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
5+
6+
# Copy dependency files and required files for hatchling
7+
COPY pyproject.toml uv.lock LICENSE README.md ./
8+
9+
# Install dependencies
10+
RUN uv sync --frozen --no-cache
11+
612
RUN mkdir /app
713
COPY src/ app/
814

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
<div style="text-align: center;">
44

5-
![Django](https://img.shields.io/badge/Django-5.1-green.svg)
5+
![Django](https://img.shields.io/badge/Django-5.2.3-green.svg)
66
![Python](https://img.shields.io/badge/Python-3.12-blue.svg)
77
![PostgreSQL](https://img.shields.io/badge/PostgreSQL-16-blue.svg)
88
![License](https://img.shields.io/badge/License-MIT-yellow.svg)
99
![Tests](https://img.shields.io/badge/Tests-Passing-brightgreen.svg)
1010
![Ruff](https://img.shields.io/badge/Linting-Ruff-purple.svg)
11+
![uv](https://img.shields.io/badge/Dependencies-uv-orange.svg)
1112

1213
**Production-ready Django SaaS template with organizations, invitations, and solid authentication built-in.**
1314

docs/getting_started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Ok, lets get started. You're gonna need the usual things to get started:
66

77
* Docker
88
* Python 3.12
9+
* uv (for Python dependency management)
910
* PostgreSQL
1011
* S3 Buckets (Provider of choice, we use Backblaze for production and
1112
S3Proxy[^1] for dev)
@@ -41,6 +42,7 @@ make bootstrap-dev
4142
It will :
4243
- pull containers
4344
- build the django container
45+
- install Python dependencies with uv
4446
- migrate the initial database
4547
- prompt you to create a superuser.
4648

pyproject.toml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,46 @@
11
[build-system]
2-
requires = ["flit_core >=3.2,<4"]
3-
build-backend = "flit_core.buildapi"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
6-
name = "django_reference_implemetation"
6+
name = "django_reference_implementation"
77
authors = [{name = "SimpleCTO", email = "[email protected]"}]
88
readme = "README.md"
99
license = {file = "LICENSE"}
1010
classifiers = ["License :: OSI Approved :: MIT License"]
1111
description = "Django Reference Implementation, a boilerplate Django project."
1212
version = "0.1.0"
13+
requires-python = ">=3.12"
14+
dependencies = [
15+
"asgiref==3.8.1",
16+
"certifi==2025.6.15",
17+
"charset-normalizer==3.4.2",
18+
"django-environ==0.12.0",
19+
"Django==5.2.3",
20+
"django-allauth[mfa]==65.9.0",
21+
"django-bootstrap5==25.1",
22+
"django-solo==2.4.0",
23+
"gunicorn==23.0.0",
24+
"idna==3.10",
25+
"packaging==25.0",
26+
"psycopg2-binary==2.9.10",
27+
"pytz==2025.2",
28+
"requests==2.32.4",
29+
"sqlparse==0.5.3",
30+
"typing_extensions==4.14.0",
31+
"urllib3==2.5.0",
32+
"whitenoise==6.9.0",
33+
"PyJWT==2.10.1",
34+
]
35+
36+
[project.optional-dependencies]
37+
dev = [
38+
"ruff==0.12.0",
39+
"pre-commit==4.2.0",
40+
]
41+
42+
[tool.hatch.build.targets.wheel]
43+
packages = ["src"]
1344

1445
[project.urls]
1546
Home = "https://github.com/simplecto/django-reference-implementation"
@@ -51,12 +82,12 @@ skips = ["B106"]
5182
[tool.commitizen]
5283
name = "cz_conventional_commits"
5384
version = "0.1.0"
54-
tag_format = "$version"
85+
tag_format = "v$version"
5586
bump_message = "bump: version $current_version → $new_version"
5687
update_changelog_on_bump = true
5788
changelog_file = "CHANGELOG.md"
5889
changelog_incremental = true
5990
version_files = [
60-
"pyproject.toml:^version",
91+
"pyproject.toml:version",
6192
"Dockerfile:VERSION",
6293
]

requirements-dev.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)