# CRM Backend Django + Django REST Framework backend scaffold. ## Local setup ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt cp .env.example .env python manage.py migrate python manage.py runserver ``` Health check: ```bash curl http://127.0.0.1:8000/api/health/ ``` Generate an Excel report: ```bash curl -X POST http://127.0.0.1:8000/api/reports/generate/ \ -H "Content-Type: application/json" \ -o user-report.xlsx \ -d '{ "report_type": "user", "filters": { "status": "active" } }' ``` Supported report types: - `user` - `tickets` ## Settings The project defaults to `config.settings.local` for development. Environment variables are read from `.env` when it exists. Use `config.settings.production` in production: ```bash export DJANGO_SETTINGS_MODULE=config.settings.production ``` Important variables: - `SECRET_KEY`: Django secret key. Required in production. - `DEBUG`: `True` for local development, `False` otherwise. - `ALLOWED_HOSTS`: comma-separated host names. - `DATABASE_URL`: database connection URL. Defaults to local SQLite. - `CORS_ALLOWED_ORIGINS`: comma-separated frontend origins. - `CSRF_TRUSTED_ORIGINS`: comma-separated trusted origins for unsafe requests. - `SERVICE_REQUEST_TIMEOUT`: timeout in seconds for downstream service calls. - `OAUTH2_PROVIDER_PUBLIC_URL`: public OAuth2 issuer/provider URL. - `OAUTH2_PROVIDER_PRIVATE_URL`: private OAuth2 provider URL used by the backend. - `OAUTH2_CLIENT_ID`: OAuth2 client credentials ID. - `OAUTH2_CLIENT_SECRET`: OAuth2 client credentials secret. - `OAUTH2_SCOPES`: space-separated OAuth2 scopes. The service client currently builds the client-credentials token endpoint as: ```text {OAUTH2_PROVIDER_PRIVATE_URL}/oauth2/token ```