## Summary Closes #5. - Composer can **Send now** without a schedule time (Schedule and Save draft still available) - Account names wrap and show the platform id so a bad OAuth label is still readable - Social accounts page can rename the display name; re-auth keeps a custom name instead of overwriting it with a placeholder - Worker polls `dispatch_due` every 15s so scheduled campaigns and social posts fire without a manual command; local `docker compose up` now starts the worker ## Test plan - [ ] Open Social → Compose: confirm **Send now**, **Schedule**, and **Save draft** buttons (no combined Save / publish) - [ ] Send now with a connected account and caption → post queues immediately, no datetime required - [ ] Schedule with a datetime → post is scheduled; Schedule with a blank time → validation error - [ ] Composer account list shows full name plus external id, wrapping if the name is long - [ ] Social accounts → rename a messy label → new name shows in composer without reconnecting - [ ] Re-authorize an account that was renamed → custom name is kept - [ ] Rebuild and start compose (`docker compose up --build`) so the **worker** service is running - [ ] Schedule a social post ~2 minutes ahead → after due time, worker logs `Enqueued N due item(s).` and the post leaves Scheduled (published or failed) - [ ] `docker compose logs -f worker` shows `Polling due scheduled work every 15s.` Reviewed-on: #6
94 lines
2.9 KiB
Markdown
94 lines
2.9 KiB
Markdown
# monica_site
|
|
|
|
Django 6 marketing platform for Monica Dhillon / MKDRealtor.com — public site, realtor
|
|
portal, multi-channel outreach (email + SMS via SMTP2GO, postcards via PCM Integrations), and social
|
|
scheduling (Facebook / Instagram / LinkedIn) with Ollama-assisted drafting.
|
|
|
|
## Stack
|
|
|
|
- Django 6 + `uv`
|
|
- Postgres (prod/beta); SQLite locally when `DATABASE_URL` unset
|
|
- **dj-queue** (Django Tasks backend, Postgres queue, no Redis/Celery)
|
|
- Docker; deploy via `server-infra` Ansible pipeline
|
|
|
|
## Environments
|
|
|
|
| Env | Domain | Port (host) | Gate |
|
|
|-----|--------|-------------|------|
|
|
| prod | `mkdrealtor.com` | 8004 | `SITE_UNDER_CONSTRUCTION=true` (holding page) |
|
|
| beta | `monica-preview.aimloperations.com` | 8014 | full app (`SITE_UNDER_CONSTRUCTION=false`) |
|
|
|
|
## Local development
|
|
|
|
```bash
|
|
uv sync
|
|
cd site
|
|
uv run python manage.py migrate
|
|
uv run python manage.py runserver
|
|
# optional: docker compose up # web + postgres + worker (hot reload)
|
|
```
|
|
|
|
Docker compose mounts `./site` into the container and runs Django `runserver` when
|
|
`DJANGO_ENV=dev` (the default). The **worker** service polls `dispatch_due` every 15s so
|
|
scheduled campaigns and social posts fire without a manual command. Edit Python/templates
|
|
→ auto-reload; no image rebuild.
|
|
Rebuild only when Dockerfile, entrypoint scripts, or deps (`pyproject.toml`, `uv.lock`) change:
|
|
|
|
```bash
|
|
docker compose up --build
|
|
```
|
|
|
|
### Local secrets (SMTP2GO, etc.)
|
|
|
|
Copy `.env.example` → `.env` (gitignored). Compose reads `.env` for email vars.
|
|
|
|
```bash
|
|
cp .env.example .env
|
|
# fill EMAIL_HOST_USER / EMAIL_HOST_PASSWORD
|
|
# for real delivery (not console logs):
|
|
# EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
|
|
docker compose up
|
|
```
|
|
|
|
Without `EMAIL_BACKEND=…smtp…`, mail prints to the web container logs (console backend).
|
|
|
|
### SMTP2GO delivery webhooks
|
|
|
|
See [`site/messaging/README.md`](site/messaging/README.md) for SMTP2GO email/SMS webhooks
|
|
and PCM Integrations postcard designer + webhook setup (Bearer auth, events).
|
|
|
|
Prod compose (`docker-compose.prod.yml`) still uses gunicorn with baked-in image code.
|
|
|
|
## Secret env files (control node)
|
|
|
|
Create on the deploy host:
|
|
|
|
```text
|
|
~/Documents/secrets/monica_site/monica_site_prod.env
|
|
~/Documents/secrets/monica_site/monica_site_beta.env
|
|
```
|
|
|
|
Templates: `.env.prod.example` (full var list). Validate with:
|
|
|
|
```bash
|
|
./scripts/validate-env.sh ~/Documents/secrets/monica_site/monica_site_prod.env
|
|
```
|
|
|
|
## Deploy
|
|
|
|
CI on merge to `main` → tests → `server-infra/scripts/deploy.sh --app monica_site --env prod --ref <sha>`.
|
|
|
|
Start the **dj-queue worker on exactly one host**:
|
|
|
|
```bash
|
|
docker compose -f docker-compose.prod.yml --profile worker up -d
|
|
```
|
|
|
|
## Apps
|
|
|
|
`public` · `accounts` · `dashboard` · `leads` · `contacts` · `analytics` · `messaging` · `social`
|
|
|
|
Social AI drafts: `POST /portal/social/api/generate/` → Ollama at `OLLAMA_BASE_URL` (default `http://10.0.0.128:11434`).
|
|
|
|
See [`docs/monica-site-design.md`](docs/monica-site-design.md) for architecture.
|