Technology Stack
Full stack detail — backend, frontend, infrastructure, and key architectural decisions.

Backend

LayerTechnologyRationale
LanguagePython 3.12Founder has prior expertise; strong data/ML ecosystem for CQI Phase 3
FrameworkDjango 5 DRFRapid development, strong ORM, excellent admin panel for early-stage data management
Identity / SSOdjango-oauth-toolkitOAuth2 + OIDC server; custom claims for cannabis license identity
Task queueCelery RedisCQI async scoring, COA PDF parsing, menu sync, notifications
DatabasePostgreSQL 16 PostGISPostGIS for ICC Maps geospatial queries; strong relational model for orders/compliance
COA parsingpdfplumberLab test PDF extraction; supplemented by LLM prompt for unstructured layouts
API docsdrf-spectacularAuto-generated OpenAPI/Swagger UI at /api/docs/
Linting / formatruff blackEnforced on save in Cursor dev container
Testingpytest factory_boyTest factories for all models; fixtures for auth, business, lot, order scenarios

Django App Structure

AppKey modelsResponsibilities
identityUser, BusinessProfile, BusinessLicense, BusinessMemberSSO token authority, KYB, role-based access
ccxLot, CertificateOfAnalysis, Offer, OrderTrading lifecycle, offline payment state machine, COA upload
cqiScoringConfig, CQIScoreScoring engine, Celery tasks, config management
coreShared admin registrations, utilities, base permissions

Frontend

LayerTechnologyNotes
FrameworkReact 18 TypeScript ViteTwo web apps: CCX (port 3000) and BMC (port 3001)
StylingTailwind CSSCustom design system with ICC brand palette; dark mode implemented
Server stateTanStack QueryAPI data fetching, caching, optimistic updates
Client stateZustandAuth store with hasProduct() and isRole() helpers; persisted to localStorage
FormsReact Hook Form ZodSchema validation on all inputs; resolver pattern
HTTP clientAxiosInterceptors for Bearer token injection and transparent refresh-on-401 with queue
RoutingReact Router v6Protected routes with RequireAuth guard component
Mobile (Phase 4)React Native~70–80% code reuse from web; three apps: CCX, Maps, Social

Infrastructure

Celery task queues

QueueTasks
cqiscore_lot, rescore_all_active_lots
defaultCOA PDF parsing, notifications, order status updates
notificationsEmail OTP, license expiry alerts, payment confirmation

AWS S3 storage

PathContents
coas/Certificate of Analysis PDFs
lot_photos/Product images
licenses/Business license documents (KYB)
proof_of_funds/Buyer proof-of-funds uploads
staticfiles/Production static assets (prod only)

Key Architectural Decisions

Why Django over FastAPI / Node?

Founder has Django expertise. FastAPI would offer better raw throughput for high-concurrency trading, but the productivity cost of switching stacks outweighs the benefit at this stage. The CCX trading engine can be extracted to a FastAPI microservice in Phase 2 if volume justifies it.

Why custom SSO over Auth0/Okta?

Cannabis license number and business type must be first-class identity attributes — not custom claims. Cross-product SSO requires a token authority we control. Long-term, the SSO becomes a distribution moat as new ICC products are added.

Why offline payment settlement?

Cannabis banking is restricted under federal law. Phase 1 uses dual in-app confirmation of offline payments (wire, check). Data model pre-stubs escrow fields for future in-app payments when regulations allow. Eliminates the banking partner dependency at launch.

Why rule-based CQI in Phase 1?

ML models require training data that doesn't exist yet. The weighted rule-based model produces scores immediately and generates the labeled dataset (lots + clearing prices) needed to train an XGBoost/LightGBM model in Phase 3.