@cubocicloide/stack-react-django 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +33 -0
- package/README.md +66 -0
- package/dist/commands/lint/checks/BE/001.d.ts +6 -0
- package/dist/commands/lint/checks/BE/001.js +94 -0
- package/dist/commands/lint/checks/BE/001.js.map +1 -0
- package/dist/commands/lint/checks/BE/002.d.ts +6 -0
- package/dist/commands/lint/checks/BE/002.js +136 -0
- package/dist/commands/lint/checks/BE/002.js.map +1 -0
- package/dist/commands/lint/checks/BE/003.d.ts +6 -0
- package/dist/commands/lint/checks/BE/003.js +89 -0
- package/dist/commands/lint/checks/BE/003.js.map +1 -0
- package/dist/commands/lint/checks/BE/004.d.ts +6 -0
- package/dist/commands/lint/checks/BE/004.js +68 -0
- package/dist/commands/lint/checks/BE/004.js.map +1 -0
- package/dist/commands/lint/checks/BE/005.d.ts +6 -0
- package/dist/commands/lint/checks/BE/005.js +55 -0
- package/dist/commands/lint/checks/BE/005.js.map +1 -0
- package/dist/commands/lint/checks/BE/006.d.ts +6 -0
- package/dist/commands/lint/checks/BE/006.js +95 -0
- package/dist/commands/lint/checks/BE/006.js.map +1 -0
- package/dist/commands/lint/checks/BE/007.d.ts +6 -0
- package/dist/commands/lint/checks/BE/007.js +53 -0
- package/dist/commands/lint/checks/BE/007.js.map +1 -0
- package/dist/commands/lint/checks/BE/008.d.ts +6 -0
- package/dist/commands/lint/checks/BE/008.js +70 -0
- package/dist/commands/lint/checks/BE/008.js.map +1 -0
- package/dist/commands/lint/checks/BE/009.d.ts +6 -0
- package/dist/commands/lint/checks/BE/009.js +112 -0
- package/dist/commands/lint/checks/BE/009.js.map +1 -0
- package/dist/commands/lint/checks/BE/010.d.ts +6 -0
- package/dist/commands/lint/checks/BE/010.js +76 -0
- package/dist/commands/lint/checks/BE/010.js.map +1 -0
- package/dist/commands/lint/checks/BE/011.d.ts +6 -0
- package/dist/commands/lint/checks/BE/011.js +76 -0
- package/dist/commands/lint/checks/BE/011.js.map +1 -0
- package/dist/commands/lint/checks/BE/012.d.ts +6 -0
- package/dist/commands/lint/checks/BE/012.js +61 -0
- package/dist/commands/lint/checks/BE/012.js.map +1 -0
- package/dist/commands/lint/checks/BE/013.d.ts +6 -0
- package/dist/commands/lint/checks/BE/013.js +98 -0
- package/dist/commands/lint/checks/BE/013.js.map +1 -0
- package/dist/commands/lint/checks/BE/014.d.ts +6 -0
- package/dist/commands/lint/checks/BE/014.js +64 -0
- package/dist/commands/lint/checks/BE/014.js.map +1 -0
- package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/001.js +35 -0
- package/dist/commands/lint/checks/E2E/001.js.map +1 -0
- package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/002.js +37 -0
- package/dist/commands/lint/checks/E2E/002.js.map +1 -0
- package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/003.js +42 -0
- package/dist/commands/lint/checks/E2E/003.js.map +1 -0
- package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/004.js +37 -0
- package/dist/commands/lint/checks/E2E/004.js.map +1 -0
- package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/005.js +47 -0
- package/dist/commands/lint/checks/E2E/005.js.map +1 -0
- package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/006.js +28 -0
- package/dist/commands/lint/checks/E2E/006.js.map +1 -0
- package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
- package/dist/commands/lint/checks/E2E/007.js +47 -0
- package/dist/commands/lint/checks/E2E/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/001.d.ts +6 -0
- package/dist/commands/lint/checks/FE/001.js +56 -0
- package/dist/commands/lint/checks/FE/001.js.map +1 -0
- package/dist/commands/lint/checks/FE/002.d.ts +6 -0
- package/dist/commands/lint/checks/FE/002.js +80 -0
- package/dist/commands/lint/checks/FE/002.js.map +1 -0
- package/dist/commands/lint/checks/FE/003.d.ts +6 -0
- package/dist/commands/lint/checks/FE/003.js +65 -0
- package/dist/commands/lint/checks/FE/003.js.map +1 -0
- package/dist/commands/lint/checks/FE/004.d.ts +6 -0
- package/dist/commands/lint/checks/FE/004.js +72 -0
- package/dist/commands/lint/checks/FE/004.js.map +1 -0
- package/dist/commands/lint/checks/FE/005.d.ts +6 -0
- package/dist/commands/lint/checks/FE/005.js +103 -0
- package/dist/commands/lint/checks/FE/005.js.map +1 -0
- package/dist/commands/lint/checks/FE/006.d.ts +6 -0
- package/dist/commands/lint/checks/FE/006.js +102 -0
- package/dist/commands/lint/checks/FE/006.js.map +1 -0
- package/dist/commands/lint/checks/FE/007.d.ts +6 -0
- package/dist/commands/lint/checks/FE/007.js +60 -0
- package/dist/commands/lint/checks/FE/007.js.map +1 -0
- package/dist/commands/lint/checks/FE/008.d.ts +6 -0
- package/dist/commands/lint/checks/FE/008.js +115 -0
- package/dist/commands/lint/checks/FE/008.js.map +1 -0
- package/dist/commands/lint/checks/FE/009.d.ts +6 -0
- package/dist/commands/lint/checks/FE/009.js +83 -0
- package/dist/commands/lint/checks/FE/009.js.map +1 -0
- package/dist/commands/lint/checks/FE/010.d.ts +6 -0
- package/dist/commands/lint/checks/FE/010.js +105 -0
- package/dist/commands/lint/checks/FE/010.js.map +1 -0
- package/dist/commands/lint/checks/FE/011.d.ts +6 -0
- package/dist/commands/lint/checks/FE/011.js +43 -0
- package/dist/commands/lint/checks/FE/011.js.map +1 -0
- package/dist/commands/lint/checks/FE/012.d.ts +6 -0
- package/dist/commands/lint/checks/FE/012.js +150 -0
- package/dist/commands/lint/checks/FE/012.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3436 -0
- package/dist/index.js.map +1 -0
- package/dude.stack.json +13 -0
- package/package.json +43 -0
- package/templates/aws-ecs/backend/Dockerfile.prod +34 -0
- package/templates/aws-ecs/docs/docs/deploy.md.hbs +54 -0
- package/templates/aws-ecs/frontend/Dockerfile.prod +28 -0
- package/templates/aws-ecs/frontend/nginx.conf +21 -0
- package/templates/aws-ecs/iac/README.md.hbs +75 -0
- package/templates/aws-ecs/iac/_gitignore +14 -0
- package/templates/aws-ecs/iac/runner/Dockerfile +35 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/main.tf.hbs +102 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/outputs.tf +19 -0
- package/templates/aws-ecs/iac/terraform/bootstrap/variables.tf.hbs +17 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
- package/templates/aws-ecs/iac/terraform/environments/dev/terraform.tfvars.hbs +43 -0
- package/templates/aws-ecs/iac/terraform/main.tf.hbs +949 -0
- package/templates/aws-ecs/iac/terraform/outputs.tf.hbs +71 -0
- package/templates/aws-ecs/iac/terraform/providers.tf +19 -0
- package/templates/aws-ecs/iac/terraform/variables.tf.hbs +113 -0
- package/templates/aws-ecs/iac/terraform/versions.tf +19 -0
- package/templates/base/.claude/agents/issue-fixer.md +190 -0
- package/templates/base/.claude/agents/security-fixer.md +250 -0
- package/templates/base/.claude/rules/BE/001.md +19 -0
- package/templates/base/.claude/rules/BE/002.md +21 -0
- package/templates/base/.claude/rules/BE/003.md +19 -0
- package/templates/base/.claude/rules/BE/004.md +16 -0
- package/templates/base/.claude/rules/BE/005.md +23 -0
- package/templates/base/.claude/rules/BE/006.md +13 -0
- package/templates/base/.claude/rules/BE/007.md +24 -0
- package/templates/base/.claude/rules/BE/008.md +19 -0
- package/templates/base/.claude/rules/BE/009.md +18 -0
- package/templates/base/.claude/rules/BE/010.md +15 -0
- package/templates/base/.claude/rules/BE/011.md +17 -0
- package/templates/base/.claude/rules/BE/012.md +18 -0
- package/templates/base/.claude/rules/BE/013.md +22 -0
- package/templates/base/.claude/rules/BE/014.md +15 -0
- package/templates/base/.claude/rules/E2E/001.md +13 -0
- package/templates/base/.claude/rules/E2E/002.md +14 -0
- package/templates/base/.claude/rules/E2E/003.md +10 -0
- package/templates/base/.claude/rules/E2E/004.md +23 -0
- package/templates/base/.claude/rules/E2E/005.md +15 -0
- package/templates/base/.claude/rules/E2E/006.md +13 -0
- package/templates/base/.claude/rules/E2E/007.md +18 -0
- package/templates/base/.claude/rules/FE/001.md +22 -0
- package/templates/base/.claude/rules/FE/002.md +39 -0
- package/templates/base/.claude/rules/FE/003.md +19 -0
- package/templates/base/.claude/rules/FE/004.md +21 -0
- package/templates/base/.claude/rules/FE/005.md +33 -0
- package/templates/base/.claude/rules/FE/006.md +24 -0
- package/templates/base/.claude/rules/FE/007.md +19 -0
- package/templates/base/.claude/rules/FE/008.md +26 -0
- package/templates/base/.claude/rules/FE/009.md +30 -0
- package/templates/base/.claude/rules/FE/010.md +25 -0
- package/templates/base/.claude/rules/FE/011.md +22 -0
- package/templates/base/.claude/rules/FE/012.md +32 -0
- package/templates/base/.claude/settings.json +53 -0
- package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
- package/templates/base/.claude/skills/create/SKILL.md +47 -0
- package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
- package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
- package/templates/base/.claude/skills/create-route/SKILL.md +156 -0
- package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
- package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
- package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
- package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
- package/templates/base/.dude/commands/README.md +85 -0
- package/templates/base/.dude/commands/hello.ts +34 -0
- package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
- package/templates/base/.dude/lint/checks/README.md +69 -0
- package/templates/base/.vscode/tasks.json +44 -0
- package/templates/base/.worktreeinclude +2 -0
- package/templates/base/CLAUDE.md.hbs +391 -0
- package/templates/base/README.md.hbs +188 -0
- package/templates/base/_env.example.hbs +39 -0
- package/templates/base/_env.hbs +35 -0
- package/templates/base/_gitignore +31 -0
- package/templates/base/_npmrc +2 -0
- package/templates/base/backend/Dockerfile +16 -0
- package/templates/base/backend/README.md.hbs +90 -0
- package/templates/base/backend/_dockerignore +12 -0
- package/templates/base/backend/apps/__init__.py +0 -0
- package/templates/base/backend/apps/core/__init__.py +0 -0
- package/templates/base/backend/apps/core/apps.py +6 -0
- package/templates/base/backend/apps/core/serializers.py +7 -0
- package/templates/base/backend/apps/core/tests/__init__.py +0 -0
- package/templates/base/backend/apps/core/tests/test_views.py +16 -0
- package/templates/base/backend/apps/core/urls.py +9 -0
- package/templates/base/backend/apps/core/views.py +24 -0
- package/templates/base/backend/apps/users/__init__.py +0 -0
- package/templates/base/backend/apps/users/admin.py +6 -0
- package/templates/base/backend/apps/users/apps.py +6 -0
- package/templates/base/backend/apps/users/migrations/0001_initial.py +41 -0
- package/templates/base/backend/apps/users/migrations/__init__.py +0 -0
- package/templates/base/backend/apps/users/models.py +15 -0
- package/templates/base/backend/apps/users/serializers.py +16 -0
- package/templates/base/backend/apps/users/services.py +25 -0
- package/templates/base/backend/apps/users/tests/__init__.py +0 -0
- package/templates/base/backend/apps/users/tests/test_models.py +30 -0
- package/templates/base/backend/apps/users/tests/test_views.py +55 -0
- package/templates/base/backend/apps/users/urls.py +10 -0
- package/templates/base/backend/apps/users/views.py +20 -0
- package/templates/base/backend/config/__init__.py.hbs +5 -0
- package/templates/base/backend/config/asgi.py +9 -0
- package/templates/base/backend/config/settings/__init__.py +0 -0
- package/templates/base/backend/config/settings/base.py.hbs +197 -0
- package/templates/base/backend/config/settings/local.py +31 -0
- package/templates/base/backend/config/settings/production.py.hbs +37 -0
- package/templates/base/backend/config/urls.py.hbs +22 -0
- package/templates/base/backend/config/wsgi.py +9 -0
- package/templates/base/backend/manage.py +23 -0
- package/templates/base/backend/pyproject.toml.hbs +48 -0
- package/templates/base/backend/start.sh +5 -0
- package/templates/base/docker-compose.yml.hbs +196 -0
- package/templates/base/docs/docs/api.md +21 -0
- package/templates/base/docs/docs/dude.md.hbs +305 -0
- package/templates/base/docs/docs/index.md.hbs +92 -0
- package/templates/base/docs/docs/mkdocs.md +231 -0
- package/templates/base/docs/mkdocs.yml.hbs +52 -0
- package/templates/base/e2e/.prettierrc.json +1 -0
- package/templates/base/e2e/_prettierignore +3 -0
- package/templates/base/e2e/cucumber.js +21 -0
- package/templates/base/e2e/eslint.config.mjs +14 -0
- package/templates/base/e2e/features/example.feature +13 -0
- package/templates/base/e2e/package.json.hbs +30 -0
- package/templates/base/e2e/pages/ExamplePage.ts +16 -0
- package/templates/base/e2e/playwright.config.ts +27 -0
- package/templates/base/e2e/steps/common.steps.ts +32 -0
- package/templates/base/e2e/steps/example.steps.ts +4 -0
- package/templates/base/e2e/support/hooks.ts +72 -0
- package/templates/base/e2e/support/world.ts +24 -0
- package/templates/base/e2e/tsconfig.json +22 -0
- package/templates/base/frontend/.prettierrc.json +6 -0
- package/templates/base/frontend/Dockerfile +10 -0
- package/templates/base/frontend/_dockerignore +4 -0
- package/templates/base/frontend/eslint.config.js +32 -0
- package/templates/base/frontend/index.html.hbs +13 -0
- package/templates/base/frontend/package.json.hbs +38 -0
- package/templates/base/frontend/public/favicon.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
- package/templates/base/frontend/src/$components/Layout/constants.tsx +8 -0
- package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
- package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
- package/templates/base/frontend/src/$components/index.tsx +1 -0
- package/templates/base/frontend/src/$hooks/index.tsx +2 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
- package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
- package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
- package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
- package/templates/base/frontend/src/App.tsx +36 -0
- package/templates/base/frontend/src/main.tsx +10 -0
- package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +129 -0
- package/templates/base/frontend/src/pages/constants.tsx +31 -0
- package/templates/base/frontend/src/pages/index.tsx +192 -0
- package/templates/base/frontend/src/pages/types.tsx +6 -0
- package/templates/base/frontend/src/pages/users/[id]/index.tsx +53 -0
- package/templates/base/frontend/src/pages/users/index.tsx +57 -0
- package/templates/base/frontend/src/pages/users/types.tsx +4 -0
- package/templates/base/frontend/src/styles.module.css +7 -0
- package/templates/base/frontend/src/utils/constants.tsx +11 -0
- package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
- package/templates/base/frontend/src/utils/functions.tsx +70 -0
- package/templates/base/frontend/src/utils/index.tsx +3 -0
- package/templates/base/frontend/tsconfig.json +24 -0
- package/templates/base/frontend/vite.config.ts +20 -0
- package/templates/base/package.json.hbs +11 -0
- package/templates/base/security/baseline.json +4 -0
- package/templates/celery/backend/apps/core/tasks.py +14 -0
- package/templates/celery/backend/apps/core/tests/test_tasks.py +6 -0
- package/templates/celery/backend/config/celery.py.hbs +26 -0
- package/templates/celerybeat/backend/apps/core/tasks_scheduled.py +18 -0
- package/templates/celerybeat/backend/apps/core/tests/test_tasks_scheduled.py +6 -0
- package/templates/postgres/.dude/commands/reset.ts +83 -0
- package/templates/s3/backend/apps/files/__init__.py +0 -0
- package/templates/s3/backend/apps/files/admin.py +9 -0
- package/templates/s3/backend/apps/files/apps.py +6 -0
- package/templates/s3/backend/apps/files/migrations/0001_initial.py +29 -0
- package/templates/s3/backend/apps/files/migrations/__init__.py +0 -0
- package/templates/s3/backend/apps/files/models.py +21 -0
- package/templates/s3/backend/apps/files/serializers.py +27 -0
- package/templates/s3/backend/apps/files/services.py +19 -0
- package/templates/s3/backend/apps/files/tests/__init__.py +0 -0
- package/templates/s3/backend/apps/files/tests/test_models.py +10 -0
- package/templates/s3/backend/apps/files/tests/test_views.py +32 -0
- package/templates/s3/backend/apps/files/urls.py +10 -0
- package/templates/s3/backend/apps/files/views.py +29 -0
- package/templates/s3/frontend/src/openapi/utils/openapi.yaml.hbs +253 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# ── App ───────────────────────────────────────────────────────────────────────
|
|
2
|
+
APP_TITLE={{projectName}}
|
|
3
|
+
DJANGO_DEBUG=true
|
|
4
|
+
DJANGO_SETTINGS_MODULE=config.settings.local
|
|
5
|
+
|
|
6
|
+
# ── Frontend (baked in at Docker build time by Vite) ─────────────────────────
|
|
7
|
+
VITE_APP_TITLE={{projectName}}
|
|
8
|
+
# Set to "true" to enable React Query DevTools in the browser
|
|
9
|
+
VITE_REACT_QUERY_DEVTOOLS=true
|
|
10
|
+
{{#if withPostgres}}
|
|
11
|
+
|
|
12
|
+
# ── Database ──────────────────────────────────────────────────────────────────
|
|
13
|
+
DATABASE_URL=postgres://postgres:postgres@postgres:5432/app
|
|
14
|
+
POSTGRES_USER=postgres
|
|
15
|
+
POSTGRES_PASSWORD=postgres
|
|
16
|
+
POSTGRES_DB=app
|
|
17
|
+
POSTGRES_HOST=postgres
|
|
18
|
+
POSTGRES_PORT=5432
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#if withS3}}
|
|
21
|
+
|
|
22
|
+
# ── Object storage (MinIO locally, S3 in production) ─────────────────────────
|
|
23
|
+
AWS_ACCESS_KEY_ID=minioadmin
|
|
24
|
+
AWS_SECRET_ACCESS_KEY=minioadmin
|
|
25
|
+
AWS_STORAGE_BUCKET_NAME={{projectName}}-media
|
|
26
|
+
AWS_S3_ENDPOINT_URL=http://minio:9000
|
|
27
|
+
AWS_S3_REGION_NAME=us-east-1
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#if withRedis}}
|
|
30
|
+
|
|
31
|
+
# ── Redis / Celery ────────────────────────────────────────────────────────────
|
|
32
|
+
REDIS_URL=redis://redis:6379/0
|
|
33
|
+
CELERY_BROKER_URL=redis://redis:6379/0
|
|
34
|
+
CELERY_RESULT_BACKEND=redis://redis:6379/0
|
|
35
|
+
{{/if}}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
.venv/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.pyc
|
|
6
|
+
|
|
7
|
+
# Build
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
|
|
12
|
+
# Env
|
|
13
|
+
.env
|
|
14
|
+
.env.local
|
|
15
|
+
|
|
16
|
+
# Editor / OS
|
|
17
|
+
.DS_Store
|
|
18
|
+
.idea/
|
|
19
|
+
.vscode/
|
|
20
|
+
|
|
21
|
+
# Logs
|
|
22
|
+
*.log
|
|
23
|
+
|
|
24
|
+
# E2E test reports
|
|
25
|
+
e2e/reports/
|
|
26
|
+
|
|
27
|
+
# Private / ephemeral workspace (reports, local overrides, scratch files)
|
|
28
|
+
private/
|
|
29
|
+
|
|
30
|
+
# Generated API reference — rebuilt from the live command catalog by `dude docs`
|
|
31
|
+
docs/docs/api.md
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
FROM python:3.13-slim
|
|
2
|
+
WORKDIR /app
|
|
3
|
+
|
|
4
|
+
# Install uv (fast Python package manager)
|
|
5
|
+
RUN pip install --no-cache-dir uv
|
|
6
|
+
|
|
7
|
+
# Install all dependencies (including dev: pytest, ruff …)
|
|
8
|
+
COPY pyproject.toml .
|
|
9
|
+
RUN uv sync --no-cache
|
|
10
|
+
|
|
11
|
+
# Copy start script (applies migrations, starts the dev server)
|
|
12
|
+
COPY start.sh /start.sh
|
|
13
|
+
RUN chmod +x /start.sh
|
|
14
|
+
|
|
15
|
+
EXPOSE 8000
|
|
16
|
+
CMD ["/start.sh"]
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Backend
|
|
2
|
+
|
|
3
|
+
Django + Django REST Framework service for `{{projectName}}`.
|
|
4
|
+
|
|
5
|
+
## App structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
backend/
|
|
9
|
+
├── manage.py # Django CLI entry point
|
|
10
|
+
├── config/ # project package
|
|
11
|
+
│ ├── settings/
|
|
12
|
+
│ │ ├── base.py # shared settings (apps, DRF, storage, logging)
|
|
13
|
+
│ │ ├── local.py # development — DEBUG, dev SECRET_KEY fallback
|
|
14
|
+
│ │ └── production.py # deployed — everything from the environment
|
|
15
|
+
│ ├── urls.py # root URLconf — mounts every app under api/
|
|
16
|
+
{{#if withCelery}}
|
|
17
|
+
│ ├── celery.py # Celery application (worker/beat entry point)
|
|
18
|
+
{{/if}}
|
|
19
|
+
│ ├── wsgi.py # gunicorn entry point
|
|
20
|
+
│ └── asgi.py
|
|
21
|
+
└── apps/ # one Django app per domain
|
|
22
|
+
├── core/ # health endpoint, shared plumbing
|
|
23
|
+
├── users/ # custom User model (AUTH_USER_MODEL) + read-only API
|
|
24
|
+
{{#if withS3}}
|
|
25
|
+
├── files/ # file uploads stored on S3 / MinIO
|
|
26
|
+
{{/if}}
|
|
27
|
+
└── <your-app>/ # models.py, serializers.py, services.py, views.py,
|
|
28
|
+
# urls.py, admin.py, migrations/, tests/
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Conventions enforced by `dude lint` (see `.claude/rules/BE/` at the project
|
|
32
|
+
root): explicit serializer `fields`, explicit `permission_classes` on every
|
|
33
|
+
view, ORM **writes only in `services.py`**, every app has migrations and a
|
|
34
|
+
`tests/` package, models define `__str__` + `Meta.ordering`.
|
|
35
|
+
|
|
36
|
+
## Requirements
|
|
37
|
+
|
|
38
|
+
- Python 3.13+
|
|
39
|
+
- [uv](https://docs.astral.sh/uv/) (recommended)
|
|
40
|
+
- Docker (recommended for full-stack dev)
|
|
41
|
+
{{#if withPostgres}}
|
|
42
|
+
- PostgreSQL 17 (SQLite is used when `DATABASE_URL` is unset)
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#if withCelery}}
|
|
45
|
+
- Redis 7
|
|
46
|
+
{{/if}}
|
|
47
|
+
|
|
48
|
+
## Run with Docker
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
docker compose up --build
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Migrations run automatically on container start via `start.sh`.
|
|
55
|
+
|
|
56
|
+
After changing a model:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
dude db makemigration --message "describe change"
|
|
60
|
+
dude db migrate
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Create an admin account for <http://localhost:8000/admin/>:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
dude db superuser
|
|
67
|
+
```
|
|
68
|
+
{{#if withCelery}}
|
|
69
|
+
|
|
70
|
+
Celery worker{{#if withCeleryBeat}}, beat scheduler{{/if}} and Flower monitor are started automatically by docker compose.
|
|
71
|
+
Flower UI: <http://localhost:5555>
|
|
72
|
+
{{/if}}
|
|
73
|
+
|
|
74
|
+
## Run locally (without Docker)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
uv sync
|
|
78
|
+
uv run python manage.py migrate
|
|
79
|
+
uv run python manage.py runserver 0.0.0.0:8000
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then open <http://localhost:8000/api/health/> — interactive API docs live at
|
|
83
|
+
<http://localhost:8000/api/docs/> (Swagger UI, served by drf-spectacular) and
|
|
84
|
+
the raw OpenAPI schema at <http://localhost:8000/api/schema/>.
|
|
85
|
+
|
|
86
|
+
## Tests
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run pytest # or `dude test --backend` from the project root
|
|
90
|
+
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from rest_framework.test import APIClient
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_health_returns_ok() -> None:
|
|
5
|
+
"""GET /api/health/ is public and returns the ok payload."""
|
|
6
|
+
response = APIClient().get("/api/health/")
|
|
7
|
+
|
|
8
|
+
assert response.status_code == 200
|
|
9
|
+
assert response.json() == {"status": "ok"}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_health_rejects_post() -> None:
|
|
13
|
+
"""Only GET is exposed on the health endpoint."""
|
|
14
|
+
response = APIClient().post("/api/health/", {})
|
|
15
|
+
|
|
16
|
+
assert response.status_code == 405
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from drf_spectacular.utils import extend_schema
|
|
2
|
+
from rest_framework.permissions import AllowAny
|
|
3
|
+
from rest_framework.request import Request
|
|
4
|
+
from rest_framework.response import Response
|
|
5
|
+
from rest_framework.views import APIView
|
|
6
|
+
|
|
7
|
+
from apps.core.serializers import HealthSerializer
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class HealthView(APIView):
|
|
11
|
+
"""Health-check endpoint used by the frontend and by container probes."""
|
|
12
|
+
|
|
13
|
+
permission_classes = [AllowAny]
|
|
14
|
+
|
|
15
|
+
@extend_schema(
|
|
16
|
+
operation_id="health_retrieve",
|
|
17
|
+
description="Health-check endpoint.",
|
|
18
|
+
responses=HealthSerializer,
|
|
19
|
+
tags=["health"],
|
|
20
|
+
auth=[],
|
|
21
|
+
)
|
|
22
|
+
def get(self, request: Request) -> Response:
|
|
23
|
+
serializer = HealthSerializer({"status": "ok"})
|
|
24
|
+
return Response(serializer.data)
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import django.contrib.auth.models
|
|
2
|
+
import django.contrib.auth.validators
|
|
3
|
+
import django.utils.timezone
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
initial = True
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
("auth", "0012_alter_user_first_name_max_length"),
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
operations = [
|
|
16
|
+
migrations.CreateModel(
|
|
17
|
+
name="User",
|
|
18
|
+
fields=[
|
|
19
|
+
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
|
20
|
+
("password", models.CharField(max_length=128, verbose_name="password")),
|
|
21
|
+
("last_login", models.DateTimeField(blank=True, null=True, verbose_name="last login")),
|
|
22
|
+
("is_superuser", models.BooleanField(default=False, help_text="Designates that this user has all permissions without explicitly assigning them.", verbose_name="superuser status")),
|
|
23
|
+
("username", models.CharField(error_messages={"unique": "A user with that username already exists."}, help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.", max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name="username")),
|
|
24
|
+
("first_name", models.CharField(blank=True, max_length=150, verbose_name="first name")),
|
|
25
|
+
("last_name", models.CharField(blank=True, max_length=150, verbose_name="last name")),
|
|
26
|
+
("email", models.EmailField(blank=True, max_length=254, verbose_name="email address")),
|
|
27
|
+
("is_staff", models.BooleanField(default=False, help_text="Designates whether the user can log into this admin site.", verbose_name="staff status")),
|
|
28
|
+
("is_active", models.BooleanField(default=True, help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.", verbose_name="active")),
|
|
29
|
+
("date_joined", models.DateTimeField(default=django.utils.timezone.now, verbose_name="date joined")),
|
|
30
|
+
("groups", models.ManyToManyField(blank=True, help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.", related_name="user_set", related_query_name="user", to="auth.group", verbose_name="groups")),
|
|
31
|
+
("user_permissions", models.ManyToManyField(blank=True, help_text="Specific permissions for this user.", related_name="user_set", related_query_name="user", to="auth.permission", verbose_name="user permissions")),
|
|
32
|
+
],
|
|
33
|
+
options={
|
|
34
|
+
"ordering": ["id"],
|
|
35
|
+
"abstract": False,
|
|
36
|
+
},
|
|
37
|
+
managers=[
|
|
38
|
+
("objects", django.contrib.auth.models.UserManager()),
|
|
39
|
+
],
|
|
40
|
+
),
|
|
41
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from django.contrib.auth.models import AbstractUser
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class User(AbstractUser):
|
|
5
|
+
"""Project user (custom model — extend with profile fields as needed).
|
|
6
|
+
|
|
7
|
+
Referenced everywhere via ``settings.AUTH_USER_MODEL`` /
|
|
8
|
+
``django.contrib.auth.get_user_model()``.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
class Meta:
|
|
12
|
+
ordering = ["id"]
|
|
13
|
+
|
|
14
|
+
def __str__(self) -> str:
|
|
15
|
+
return self.username
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from rest_framework import serializers
|
|
2
|
+
|
|
3
|
+
from apps.users.models import User
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UserSerializer(serializers.ModelSerializer):
|
|
7
|
+
"""Public representation of a user.
|
|
8
|
+
|
|
9
|
+
Fields are always listed explicitly (never ``"__all__"``, lint rule BE002)
|
|
10
|
+
so adding a sensitive column to the model can never leak it by accident.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
class Meta:
|
|
14
|
+
model = User
|
|
15
|
+
fields = ("id", "username", "email", "first_name", "last_name", "date_joined")
|
|
16
|
+
read_only_fields = ("id", "date_joined")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Write operations for the users app.
|
|
2
|
+
|
|
3
|
+
All ORM writes live in service functions — never in views (lint rule BE005).
|
|
4
|
+
Views stay thin; business rules live here, in one importable, testable place.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from apps.users.models import User
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def create_user(
|
|
13
|
+
*,
|
|
14
|
+
username: str,
|
|
15
|
+
email: str = "",
|
|
16
|
+
password: str | None = None,
|
|
17
|
+
**extra_fields: Any,
|
|
18
|
+
) -> User:
|
|
19
|
+
"""Create a user with a properly hashed password."""
|
|
20
|
+
return User.objects.create_user(
|
|
21
|
+
username=username,
|
|
22
|
+
email=email,
|
|
23
|
+
password=password,
|
|
24
|
+
**extra_fields,
|
|
25
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from apps.users.models import User
|
|
4
|
+
from apps.users.services import create_user
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@pytest.mark.django_db
|
|
8
|
+
def test_create_user_hashes_password() -> None:
|
|
9
|
+
user = create_user(username="alice", email="alice@example.com", password="s3cret-pass!")
|
|
10
|
+
|
|
11
|
+
assert user.pk is not None
|
|
12
|
+
assert user.password != "s3cret-pass!"
|
|
13
|
+
assert user.check_password("s3cret-pass!")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.django_db
|
|
17
|
+
def test_str_returns_username() -> None:
|
|
18
|
+
user = create_user(username="bob")
|
|
19
|
+
|
|
20
|
+
assert str(user) == "bob"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.mark.django_db
|
|
24
|
+
def test_default_ordering_is_by_id() -> None:
|
|
25
|
+
create_user(username="zoe")
|
|
26
|
+
create_user(username="adam")
|
|
27
|
+
|
|
28
|
+
ids = [user.pk for user in User.objects.all()]
|
|
29
|
+
|
|
30
|
+
assert ids == sorted(ids)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from rest_framework.test import APIClient
|
|
3
|
+
|
|
4
|
+
from apps.users.services import create_user
|
|
5
|
+
|
|
6
|
+
EXPECTED_FIELDS = {"id", "username", "email", "first_name", "last_name", "date_joined"}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.mark.django_db
|
|
10
|
+
def test_list_users_is_paginated() -> None:
|
|
11
|
+
create_user(username="alice", email="alice@example.com")
|
|
12
|
+
create_user(username="bob", email="bob@example.com")
|
|
13
|
+
|
|
14
|
+
response = APIClient().get("/api/users/")
|
|
15
|
+
|
|
16
|
+
assert response.status_code == 200
|
|
17
|
+
payload = response.json()
|
|
18
|
+
assert payload["count"] == 2
|
|
19
|
+
assert [item["username"] for item in payload["results"]] == ["alice", "bob"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.django_db
|
|
23
|
+
def test_list_users_exposes_only_declared_fields() -> None:
|
|
24
|
+
create_user(username="alice", email="alice@example.com")
|
|
25
|
+
|
|
26
|
+
payload = APIClient().get("/api/users/").json()
|
|
27
|
+
|
|
28
|
+
assert set(payload["results"][0]) == EXPECTED_FIELDS
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.django_db
|
|
32
|
+
def test_retrieve_user_by_id() -> None:
|
|
33
|
+
user = create_user(username="alice", email="alice@example.com", first_name="Alice")
|
|
34
|
+
|
|
35
|
+
response = APIClient().get(f"/api/users/{user.pk}/")
|
|
36
|
+
|
|
37
|
+
assert response.status_code == 200
|
|
38
|
+
body = response.json()
|
|
39
|
+
assert body["id"] == user.pk
|
|
40
|
+
assert body["username"] == "alice"
|
|
41
|
+
assert body["first_name"] == "Alice"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@pytest.mark.django_db
|
|
45
|
+
def test_retrieve_unknown_user_returns_404() -> None:
|
|
46
|
+
response = APIClient().get("/api/users/9999/")
|
|
47
|
+
|
|
48
|
+
assert response.status_code == 404
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.django_db
|
|
52
|
+
def test_users_are_read_only_over_the_api() -> None:
|
|
53
|
+
response = APIClient().post("/api/users/", {"username": "mallory"})
|
|
54
|
+
|
|
55
|
+
assert response.status_code == 405
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from rest_framework.permissions import AllowAny
|
|
2
|
+
from rest_framework.viewsets import ReadOnlyModelViewSet
|
|
3
|
+
|
|
4
|
+
from apps.users.models import User
|
|
5
|
+
from apps.users.serializers import UserSerializer
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UserViewSet(ReadOnlyModelViewSet):
|
|
9
|
+
"""List (paginated) and retrieve users.
|
|
10
|
+
|
|
11
|
+
Write operations belong in ``apps.users.services`` (see ``create_user``) —
|
|
12
|
+
views never touch the ORM for writes (lint rule BE005).
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
queryset = User.objects.all()
|
|
16
|
+
serializer_class = UserSerializer
|
|
17
|
+
# Demo endpoint: AllowAny so the scaffold works out of the box. Tighten to
|
|
18
|
+
# IsAuthenticated before exposing real user data — but keep the declaration
|
|
19
|
+
# explicit: every view must declare permission_classes (lint rule BE003).
|
|
20
|
+
permission_classes = [AllowAny]
|
|
File without changes
|