Architecture Overview
High-level architecture of the ReUp cannabis platform.
System Diagram
┌─────────────────────────────────────┐
│ ReUp Platform │
┌─────────────────┐ │ │
│ Web Browser │◄──────────►│ ┌─────────────┐ ┌─────────────┐ │
│ (Next.js) │ HTTPS │ │ Frontend │ │ Backend │ │
└─────────────────┘ │ │ Next.js 15 │◄►│ FastAPI │ │
│ └─────────────┘ └──────┬──────┘ │
│ │ │
│ ┌─────▼─────┐ │
│ │ MySQL │ │
│ │ Database │ │
│ └───────────┘ │
└─────────────────────────────────────┘
│
┌─────────────────────────┼─────────────────────────┐
│ │ │
┌─────▼─────┐ ┌──────▼──────┐ ┌─────▼─────┐
│ Dutchie │ │ METRC │ │ Fleetbase │
│ POS API │ │ State API │ │ Logistics │
└───────────┘ └─────────────┘ └───────────┘
Core Components
Frontend (Next.js 15)
The frontend is a modern React application built with:
- Next.js 15: App router, server components, streaming
- React 19: Latest React features
- TypeScript: Full type safety
- Tailwind CSS: Utility-first styling
- Radix UI: Accessible component primitives
- Zustand: Lightweight state management
- SWR: Data fetching and caching
Key directories:
frontend/
├── src/
│ ├── app/ # Next.js App Router pages
│ ├── components/ # Reusable UI components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utilities and API clients
│ ├── services/ # API service functions
│ └── types/ # TypeScript definitions
Backend API (FastAPI)
The backend is a Python FastAPI application providing:
- REST API: Full CRUD operations
- Authentication: JWT-based auth with MFA
- Database ORM: SQLAlchemy with MySQL
- Background Tasks: Celery for async processing
- Caching: Redis for session and cache
Key directories:
backend_api/
├── routes/ # API endpoint handlers
├── models/ # Database models
├── services/ # Business logic
├── middleware/ # Auth, CORS, rate limiting
├── utils/ # Helper functions
└── migrations/ # Alembic migrations
Database (MySQL)
The database stores:
- User accounts and authentication
- Entity (business) information
- Product catalogs
- Inventory levels
- Orders and transactions
- Audit logs
Integrations
External service connections:
- Dutchie POS: Inventory sync, sales data
- METRC: Compliance reporting
- Fleetbase: Delivery logistics
Data Flow
Inventory Sync Flow
Dutchie POS → Webhook/Poll → Backend API → Database → Frontend
↓
METRC Report
Order Flow
Retailer (Frontend) → Create Order → Backend API → Database
↓
Wholesaler (Frontend) ← Notification ← WebSocket
↓
Accept → Fulfill → Ship → Deliver
↓
METRC Manifest
Security
Authentication
- JWT tokens with short expiry (1 hour)
- Refresh tokens for session continuation
- Multi-factor authentication (TOTP)
- Role-based access control (RBAC)
Data Protection
- HTTPS everywhere
- Encrypted database connections
- Encrypted at-rest (sensitive fields)
- Audit logging for all changes
Scalability
Current Architecture
- Single region deployment
- Horizontal scaling via load balancer
- Database read replicas available
Future Considerations
- Multi-region deployment
- Microservices extraction
- Event-driven architecture