@@ -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:
11188uv run src/manage.py migrate
11289uv 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)
137116uv 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
232193Key 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
0 commit comments