Django REST Framework backend for the Baker Street Assessment Platform, a professional clinical assessment solution for therapists and psychologists.
This is the backend API powering Baker Street Assessment Platform. It handles user authentication, client management, assessment delivery, automated scoring, and secure token-based respondent invitations.
- JWT Authentication - Secure token-based auth with refresh tokens
- Multi-Tenant Architecture - Complete data isolation per clinician account
- Respondent Link System - Cryptographically signed tokens with usage limits and expiration
- Automated Scoring Engine - Real-time calculation for clinical frameworks (ABA, EFA, etc.)
- Email Delivery - Scheduled and immediate assessment invitations
- QR Code Generation - Visual respondent link sharing
- Cloudflare Turnstile Integration - Bot protection on signup/login
- Admin Access Middleware - IP-based and token-based admin route protection
- CORS Configuration - Secure cross-origin resource sharing
- Environment-based Secrets - No hardcoded credentials
- Sentry Integration - Real-time error reporting and performance monitoring
- Structured Logging - Comprehensive request/response logging
- Python 3.10+
- Django 5.2
- Django REST Framework with SimpleJWT
- PostgreSQL (production database; SQLite for local development)
- Resend (transactional email)
- Gunicorn (WSGI server)
- WhiteNoise (static files)
Scheduled invites are sent by handing Resend a scheduled_at timestamp, so there
is no Celery or Redis in this project.
bakerbackend/
├── accounts/ # User authentication, 2FA, password reset, admin approval
├── clients/ # Client records and client groups
├── assessments/ # Assessment models, scoring, and respondent links
├── notifications/ # In-app notification feed
├── status/ # Health check endpoints
├── bakerapi/ # Project settings, middleware, admin site
├── manage.py # Django management script
└── requirements.txt # Python dependencies
- Python 3.10+
- PostgreSQL (production only; local development defaults to SQLite)
- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables (create
.envfile):
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql://user:password@localhost:5432/bakerstreet
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:5173
TURNSTILE_SECRET_KEY=your-turnstile-secret
SENTRY_DSN=your-sentry-dsn- Run migrations:
python manage.py migrate- Create superuser:
python manage.py createsuperuser- Start development server:
python manage.py runserverPOST /api/auth/signup/- Start registration (sends an email verification code)POST /api/auth/signup/verify/- Confirm the code and create the accountPOST /api/auth/login/- User login (returns tokens, or a 2FA challenge)POST /api/auth/2fa/verify/- Complete a two-factor challengePOST /api/auth/token/refresh/- Refresh JWT tokenPOST /api/auth/logout/- Revoke a refresh tokenGET|PATCH /api/auth/profile/- Read or update the signed-in profilePOST /api/auth/password/reset/request|validate|complete/- Password reset
Superuser only: pending-users/, approve-user/, reject-user/, all-users/,
toggle-user-active/, delete-user/.
GET|POST /api/assessments/- List or create assessmentsGET|PUT /api/assessments/{slug}/- Retrieve or update an assessmentGET /api/assessments/published/- Published assessments onlyGET|POST /api/assessment-responses/- List or record responsesGET /api/assessment-categories/,GET /api/assessment-tags/- Taxonomy
Creating and updating assessments requires a staff or superuser account.
POST /api/respondent-links/issue/- Generate a respondent link tokenPOST /api/respondent-links/email/- Issue a link and email it to the clientPOST /api/respondent-links/schedule/- Schedule recurring invitationsGET /api/respondent-links/schedule/runs/- List scheduled or sent runsDELETE /api/respondent-links/schedule/{reference}/- Cancel a schedule
Public (no authentication, token-gated):
POST /api/respondent-links/resolve/- Resolve a tokenPOST /api/respondent-links/client/- Capture client details for a new respondentPOST /api/respondent-links/assessment/- Fetch an invited assessmentPOST /api/respondent-links/assessment-response/- Submit answers
GET|POST /api/clients/- List or create clientsGET|PATCH|DELETE /api/clients/{slug}/- Retrieve, update or delete a clientPOST /api/clients/import/- Bulk import from CSV rowsGET|POST /api/client-groups/- List or create client groups
GET /api/notifications/- Notification feed for the signed-in userGET /api/health/- Public uptime checkGET /api/health/full/- Detailed service checks (staff or admin IP/token)
- Connect GitHub repository to Render
- Set environment variables in Render dashboard
- Deploy using Render's auto-deploy or manual deploy
# Install Render CLI
npm install -g @render/cli
# Login to Render
render login
# Deploy
render deploys create --service-id your-service-id# Using Render shell
render shell your-service-id
python manage.py migrateIf neither ADMIN_ALLOWED_IPS nor ADMIN_ACCESS_TOKEN is set in production, the
Django admin is reachable from any address at whatever DJANGO_ADMIN_URL is set
to. Set at least one.
python manage.py testTests run against a throwaway database, so they never touch the configured one.
Email sending is mocked; a test must never call Resend for real. Test cases that
hit rate-limited endpoints should extend bakerapi.test_utils.ThrottledAPITestCase
so throttle counters reset between tests.
# Create migrations
python manage.py makemigrations
# Apply migrations
python manage.py migrate
# Create database backup
pg_dump $DATABASE_URL > backup.sqlThis is a private project. For access or collaboration inquiries, contact the repository owner.
Proprietary - All rights reserved
For issues or questions, open a GitHub issue or contact the maintainer.
Live API: https://bakerbackend-enjy.onrender.com
Frontend: https://www.bakerstreetassessment.com (Vercel project bakers-street)
Repository: https://github.com/soulhacker010/bakerbackend
