Skip to content

Commit 071deaf

Browse files
Copilotheysamtexas
andcommitted
Revert repository to state at commit 91157cf
Co-authored-by: heysamtexas <[email protected]>
1 parent e4af507 commit 071deaf

File tree

115 files changed

+9746
-2239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+9746
-2239
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
venv/
22
__pycache__/
33
data/
4-
logs/
54

65
env
76
env.backup
@@ -11,7 +10,6 @@ config.mk
1110
*.db
1211

1312
src/staticfiles/*
14-
src/media/
1513
.idea/**
1614

1715

CLAUDE.md

Lines changed: 42 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,20 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
This is a **Data Room Application** - a secure file upload and management system for collecting customer data files for proof-of-concept development. Built on Django with django-allauth (2FA + SSO support), it enables internal teams to provision UUID-based upload endpoints for customers while maintaining complete privacy and audit trails.
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.
88

99
## Architecture
1010

1111
### Core Apps Structure
1212
- **config/**: Django project configuration (settings, URLs, WSGI/ASGI)
13-
- **myapp/**: Base application with site configuration models and templates
14-
- **dataroom/**: File upload system with customers, endpoints, and audit logging
15-
- **require2fa/**: Two-factor authentication enforcement middleware
13+
- **myapp/**: Base application with site configuration models, templates, and management commands
14+
- **organizations/**: Complete multi-tenant organization system with invitations and user management
1615

1716
### Key Components
18-
- **Authentication**: Uses django-allauth with 2FA support and SSO-ready (Okta)
19-
- **File Management**: Local filesystem storage with UUID-based endpoint privacy
20-
- **Admin Interface**: Django admin for internal team management of customers and endpoints
21-
- **Audit Logging**: Complete tracking of file uploads, deletions, and staff downloads
22-
- **UI Framework**: Tailwind CSS via Play CDN with dark mode support and Heroicons
23-
- **Templates**: Minimal, professional upload interface with responsive design
24-
25-
## Data Room Features
26-
27-
### Customer & Endpoint Management
28-
- **Customers**: Internal tracking of companies/projects receiving upload endpoints
29-
- **Data Endpoints**: UUID-based upload URLs that don't expose customer information
30-
- **Multiple Endpoints**: Each customer can have multiple endpoints for different POCs
31-
- **Status Control**: Endpoints can be active, disabled, or archived
32-
33-
### File Upload System
34-
- **Anonymous Upload**: Customers upload via UUID URL (no authentication required)
35-
- **Security**: Filename sanitization, path traversal prevention, duplicate handling
36-
- **Soft Delete**: Customers can request deletion (immediate with audit trail)
37-
- **File Listing**: Customers can view all files uploaded to their endpoint
38-
39-
### Staff Features (Django Admin)
40-
- **Customer Management**: Create customers with freeform notes
41-
- **Endpoint Creation**: Generate new upload endpoints with one-click URL copying
42-
- **File Downloads**: Secure download with automatic audit logging
43-
- **Audit Dashboard**: View all file downloads and deletion activity
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
4421

4522
## Git Workflow for Claude Code
4623

@@ -110,7 +87,9 @@ uv run src/manage.py <command>
11087
# Key management commands:
11188
uv run src/manage.py migrate
11289
uv run src/manage.py createsuperuser
113-
uv run src/manage.py test
90+
uv run src/manage.py simple_async_worker
91+
uv run src/manage.py send_email_confirmation
92+
uv run src/manage.py send_email_invite
11493
```
11594

11695
### Code Quality
@@ -137,48 +116,43 @@ uv run vulture src/ --min-confidence 80 # Find unused code (high confidence)
137116
uv run vulture src/ --min-confidence 60 # Find unused code (medium confidence)
138117

139118
# Type checking
140-
cd src && DJANGO_SETTINGS_MODULE=config.settings uv run mypy dataroom/ myapp/ config/ --ignore-missing-imports --disable-error-code=var-annotated
119+
cd src && DJANGO_SETTINGS_MODULE=config.settings uv run mypy organizations/ myapp/ config/ --ignore-missing-imports --disable-error-code=var-annotated
141120
```
142121

143122
## Development Workflow
144123

145124
### Local Development
146-
- Uses Docker Compose for PostgreSQL and Mailpit
147-
- Django runs locally or in Docker
125+
- Uses Docker Compose for services (PostgreSQL, Mailpit, S3Proxy)
126+
- Django can run locally or in Docker
148127
- Environment variables configured in `env` file (copy from `env.sample`)
149-
- File uploads stored in `src/media/uploads/{endpoint-uuid}/`
150128

151129
### Testing
152-
- Tests located in `*/tests.py` or `*/tests/` directories
130+
- Tests located in `*/tests/` directories
153131
- Run with `uv run src/manage.py test`
154-
- Covers models, views, upload/download functionality, and security
132+
- Covers models, views, and forms
155133

156-
### URL Structure
157-
- **Public (No Auth)**: `/upload/{uuid}/` - Customer upload page
158-
- **Admin Only**: `/admin/` - Django admin interface
159-
- **Staff Downloads**: Via Django admin actions (with audit logging)
134+
### Worker System
135+
- Custom async worker pattern using Django management commands
136+
- Workers defined in `*/management/commands/`
137+
- Uses PostgreSQL for task queue (no Redis/Celery required)
138+
- Configure workers in `docker-compose.yml`
160139

161140
## Important Files
162141

163142
### Configuration
164143
- `src/config/settings.py`: Main Django settings
165144
- `pyproject.toml`: Project metadata and tool configuration (ruff, bandit)
166-
- `docker-compose.yml`: Development services (PostgreSQL, Mailpit)
145+
- `docker-compose.yml`: Development services
167146
- `Makefile`: Development automation commands
168-
- `env`: Environment variables (copy from `env.sample`)
169147

170148
### Models
171-
- `dataroom/models.py`: Customer, DataEndpoint, UploadedFile, FileDownload
172-
- `myapp/models/`: Site configuration model
173-
- `require2fa/models.py`: Two-factor configuration model
174-
175-
### Views & Templates
176-
- `dataroom/views.py`: Upload page, file upload handler, delete handler
177-
- `dataroom/templates/dataroom/`: Upload page, disabled/archived templates
178-
- `dataroom/admin.py`: Complete admin configuration with download actions
149+
- `myapp/models/`: Site configuration and worker models
150+
- `organizations/models.py`: Organization and invitation models
179151

180-
### Tests
181-
- `dataroom/tests.py`: Comprehensive model and view tests
152+
### Templates
153+
- `templates/`: Global templates (base, auth, pages)
154+
- `myapp/templates/`: App-specific templates
155+
- `organizations/templates/`: Organization management templates
182156

183157
## Code Standards
184158

@@ -189,17 +163,10 @@ cd src && DJANGO_SETTINGS_MODULE=config.settings uv run mypy dataroom/ myapp/ co
189163

190164
### File Organization
191165
- Apps follow Django conventions
192-
- Models in `models.py` or `models/` directory
193-
- Views in `views.py` or `views/` directory
166+
- Models in `models/` directory (may be split into multiple files)
167+
- Views in `views/` directory
168+
- Management commands in `management/commands/`
194169
- Templates in `templates/` with app namespacing
195-
- Admin configurations in `admin.py`
196-
197-
### Security
198-
- **Filename Sanitization**: `sanitize_filename()` prevents path traversal
199-
- **UUID Endpoints**: No customer information exposed in URLs
200-
- **IP Tracking**: All uploads, deletes, and downloads log IP addresses
201-
- **Soft Deletes**: Files marked deleted but retained for audit
202-
- **Staff-Only Downloads**: File downloads only via authenticated admin
203170

204171
## Dependencies
205172

@@ -210,63 +177,30 @@ cd src && DJANGO_SETTINGS_MODULE=config.settings uv run mypy dataroom/ myapp/ co
210177
- Install with `uv sync` or `uv sync --extra dev`
211178

212179
### Core Dependencies
213-
- Django 5.2.5
180+
- Django 5.2.3
214181
- Python 3.12
215182
- PostgreSQL 16
216-
- django-allauth (authentication with MFA and SSO support)
217-
- django-allauth-require2fa (2FA enforcement)
218-
- django-solo (singleton models)
219-
- Tailwind CSS (via Play CDN - no build process required)
220-
- Heroicons (SVG icon library)
183+
- django-allauth (authentication)
184+
- django-bootstrap5 (UI)
185+
- django-storages (S3 support)
221186

222187
### Development Dependencies
223188
- ruff (linting/formatting)
224189
- pre-commit (hooks)
225-
- mypy + django-stubs (type checking)
226-
- bandit (security scanning)
227-
- radon (complexity analysis)
228-
- vulture (dead code detection)
229190

230191
## Environment Variables
231192

232193
Key environment variables (defined in `env` file):
233194
- `DEBUG`: Development mode flag
234195
- `SECRET_KEY`: Django secret key
235-
- `BASE_URL`: Application base URL (used for upload URL generation)
236-
- `DATABASE_URL`: PostgreSQL connection string
237-
- `EMAIL_URL`: Email backend configuration (console, SMTP, etc.)
238-
239-
## File Storage
240-
241-
### Structure
242-
```
243-
src/media/
244-
uploads/
245-
{endpoint-uuid}/
246-
filename.ext
247-
filename-20250117143022-1.ext # Duplicate with timestamp
248-
```
249-
250-
### Handling
251-
- Files stored in MEDIA_ROOT (`src/media/`)
252-
- Organized by endpoint UUID for isolation
253-
- Duplicate filenames auto-renamed with timestamp
254-
- Soft deletes keep files on disk for audit/recovery
196+
- `BASE_URL`: Application base URL
197+
- `DATABASE_URL`: PostgreSQL connection
198+
- `AWS_*`: S3 configuration
199+
- Email settings for django-allauth
255200

256201
## Deployment
257202

258-
- Docker-based deployment ready
259-
- Heroku/Dokku compatible with `Procfile`
260-
- Static files served via WhiteNoise
261-
- File uploads served securely via Django (for staff only)
262-
- Uses environment variables for all configuration
263-
- Database migrations handled via release phase
264-
265-
## Future Enhancements
266-
267-
- SSO integration with Okta (django-allauth is already SSO-ready)
268-
- File size limits and validation
269-
- Virus scanning integration
270-
- Automated file expiration/archival
271-
- Email notifications for uploads
272-
- Download links for customers (with expiration)
203+
- Docker-based deployment
204+
- Heroku/Dokku ready with `Procfile`
205+
- Static files served by Django or S3
206+
- Uses environment variables for configuration

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ snapshot-local-db: ## Create a snapshot of the local database
5959
restore-local-db: ## Restore the local database from a snapshot
6060
docker compose exec -T postgres pg_restore -U postgres -d django_reference < django_reference.dump
6161

62-
logs/:
63-
mkdir -p logs/
64-
65-
.PHONY: runserver
66-
runserver: logs/ ## Run Django development server with logging to logs/server.log
67-
@echo "Starting Django server on http://0.0.0.0:8008 (logs: logs/server.log)"
68-
uv run src/manage.py runserver 0.0.0.0:8008 2>&1 | tee logs/server.log
69-
7062
##########################################################################
7163
# DJANGO-ALLAUTH DEPENDENCY MANAGEMENT
7264
##########################################################################

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies = [
1717
"charset-normalizer==3.4.3",
1818
"django-environ==0.12.0",
1919
"Django==5.2.5",
20+
"django-bootstrap5==25.2",
2021
"django-solo==2.4.0",
2122
"gunicorn==23.0.0",
2223
"idna==3.10",

src/config/settings.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525

2626
CSRF_TRUSTED_ORIGINS = [BASE_URL]
2727

28+
# CONFIGURATION for django-storages
29+
AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID")
30+
AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY")
31+
AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME")
32+
AWS_S3_REGION_NAME = env("AWS_S3_REGION_NAME")
33+
AWS_S3_ENDPOINT_URL = env("AWS_S3_ENDPOINT_URL")
34+
AWS_S3_USE_SSL = env("AWS_S3_USE_SSL")
35+
2836
ALLOWED_HOSTS = ["*"]
2937

3038
INSTALLED_APPS = [
@@ -35,7 +43,8 @@
3543
"django.contrib.messages",
3644
"django.contrib.staticfiles",
3745
"django.contrib.sites",
38-
"dataroom",
46+
"django_bootstrap5",
47+
"organizations",
3948
"myapp",
4049
"require2fa",
4150
"allauth",
@@ -186,4 +195,4 @@
186195
},
187196
}
188197

189-
LOGIN_REDIRECT_URL = "/admin/"
198+
LOGIN_REDIRECT_URL = "/accounts/email/"

src/config/urls.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import myapp.views
1111

12+
# import urls from the organizations app
13+
1214
urlpatterns = [ # noqa: RUF005
1315
path(
1416
"robots.txt",
@@ -19,7 +21,10 @@
1921
path("accounts/", include("allauth.urls")),
2022
path("", myapp.views.index, name="home"),
2123
path("health-check/", myapp.views.health_check, name="health-check"),
22-
path("", include("dataroom.urls")),
24+
path(
25+
"organizations/",
26+
include(("organizations.urls", "organizations"), namespace="organizations"),
27+
),
2328
# add privacy policy and terms of service URLs here use TemplateView.as_view
2429
path("privacy/", TemplateView.as_view(template_name="privacy.html"), name="privacy"),
2530
path("terms/", TemplateView.as_view(template_name="terms.html"), name="terms"),

0 commit comments

Comments
 (0)