ixg_platform/SESSION_CHECKPOINT.md

99 lines
4.3 KiB
Markdown

# IXG Platform — Mission Complete Summary
## VPS
- **IP**: 194.164.95.50
- **OS**: Ubuntu 26.04
- **Project**: /root/work/ixg_platform/
## Services Running
| Container | Port | Notes |
|-----------|------|-------|
| ixg-platform-app | 8000 | Django + Gunicorn |
| ixg-platform-db | 5433 | PostgreSQL 15 |
| ixg-platform-redis | 6379 | Redis 7 |
| ixg-platform-celery-worker | — | Celery worker |
| ixg-platform-celery-beat | — | Celery beat scheduler |
## Nginx (Host)
- **Config**: /etc/nginx/sites-enabled/ixg
- **Proxied routes** → Django on port 8000:
- /admin/ — Django Admin (Grappelli)
- /oidc/ — OIDC auth flow
- /ops/ — Ops Portal
- /portal/ — Buyer Portal
- /static/ — Static files
- /grappelli/ — Grappelli admin theme
- /platform/ — Legacy Django root
## Authentication
- **Provider**: Keycloak 26.6.1 (realm: ixg) on port 8443
- **Admin console**: https://auth.veripath.co.uk/admin/veripath/console/
- **Keycloak admin**: admin / test123
- **OIDC Client**: ixg-platform (secret: VGEvBE7M7AaNKde8F5t0zAXWMpgnCYCX)
- **Django superuser**: admin@ixg.local / Admin123!
- **Test user**: testuser / Test123! (test@ixg.local)
- **Matthew**: mstickels@yahoo.co.uk (role=admin)
## What Was Built
### Phase 1 — Foundation
- Django project (5.2) with 12 models across 9 apps
- Docker Compose orchestration (app, Celery worker/beat, PostgreSQL, Redis)
- Keycloak OIDC integration (mozilla-django-oidc)
- Grappelli-themed Django admin
- Custom User model (email-based, UUID PK, roles: buyer/ops/admin)
- RBAC middleware for role-based route access
### Phase 2 — REST API
- DRF serializers, viewsets, and URLs for all models
- Pagination (20/page), filtering (django-filter), search, ordering
- QC auto-CAPA logic: QC fail auto-creates CAPA record
- Token + Session authentication
### Phase 3 — Ops Portal (/ops/)
- Dashboard with key metrics (batches by status, QC pass/fail, active shipments, open CAPAs)
- List/detail views for Batches, QC Results, Shipments, CAPA Records, Documents, ESG Reports
- Search, filter, pagination on all list views
- Related data displayed on detail pages
### Phase 4 — Buyer Portal (/portal/)
- Buyer-facing dashboard (batch count, active shipments, recent documents, subscription)
- Batches list/detail with shipments, documents, ESG reports
- Documents list (buyer-visible only, by visibility field)
- Subscription status view
### Phase 5 — AI Chatbot
- AgentConfig model with encrypted API key storage (django-encrypted-model-fields)
- Agent admin UI at /admin/ai/agentconfig/
- Agent service with provider dispatch: OpenAI, DeepSeek, Google Gemini, Ollama, Custom
- Default agent IXG Assistant configured with DeepSeek API
- Chat API: POST /api/ai-interactions/chat/
- Standalone chat page: /portal/chat/
- Embeddable widget: /portal/chat/embed/
- Chat history tracked per user/session via AIInteraction model
## API Endpoints
| Endpoint | Methods | Purpose |
|----------|---------|---------|
| /api/auth/ | POST | Get auth token |
| /api/users/ | GET/POST/PUT/DELETE | User management |
| /api/subscriptions/ | GET/POST/PUT/DELETE | Subscriptions |
| /api/batches/ | GET/POST/PUT/DELETE | Processing batches |
| /api/qc-results/ | GET/POST/PUT/DELETE | QC results |
| /api/shipments/ | GET/POST/PUT/DELETE | Shipments |
| /api/documents/ | GET/POST/PUT/DELETE | Documents |
| /api/capa-records/ | GET/POST/PUT/DELETE | CAPA records |
| /api/esg-reports/ | GET/POST/PUT/DELETE | ESG reports |
| /api/ai-interactions/ | GET | Chat history |
| /api/ai-interactions/chat/ | POST | Send chat message |
| /api/agents/ | GET/POST/PUT/DELETE | Agent configs |
## Outstanding Tasks
1. **Chat UI debugging** — JS fetch to chat API needs session cookie auth to work in browser; works with token auth
2. **Email notifications** — SMTP outgoing (QC fail alerts, shipment updates, CAPA assignments) + IMAP incoming (certificate PDF auto-import). Requires domain + Fasthosts mail hosting or transactional API (SendGrid/Mailgun)
3. **Compliance automation** — CoA auto-generation, EUDR due diligence checks. Needs domain expertise
4. **Polish** — UI refinement, form validation, error handling, loading states across both portals
## Reference Documents
- This document: /root/work/ixg_platform/SESSION_CHECKPOINT.md
- Wiki development plan: http://194.164.95.50/en/home/development/plan