You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kitions is a comprehensive B2B platform that connects distributors and retailers in a streamlined marketplace. The platform consists of two main applications:
Public App (localhost:3000 / kitions.com): Marketing website with user registration and authentication
Dashboard App (localhost:3001 / dashboard.kitions.com): Business management interface for distributors and retailers
Key Features
Multi-tenant Architecture: Separate interfaces for distributors and retailers
Product Management: Comprehensive inventory and catalog management
Order Management: End-to-end order processing workflow
User Authentication: Secure signup, login, and email verification
Real-time Updates: Live inventory tracking and order status updates
Responsive Design: Mobile-first approach with Tailwind CSS
Architecture Overview
graph TB
subgraph "Client Layer"
PA[Public App<br/>Next.js 15]
DA[Dashboard App<br/>Next.js 15]
end
subgraph "Authentication Layer"
AUTH[Supabase Auth<br/>JWT + RLS]
end
subgraph "API Layer"
SUPA[Supabase API<br/>PostgreSQL + REST]
EDGE[Edge Functions<br/>Serverless]
end
subgraph "Storage Layer"
DB[(PostgreSQL<br/>Database)]
STORAGE[Supabase Storage<br/>File Management]
end
subgraph "External Services"
EMAIL[Resend<br/>Email Service]
MAPS[Mapbox<br/>Address Autocomplete]
end
PA --> AUTH
DA --> AUTH
PA --> SUPA
DA --> SUPA
AUTH --> DB
SUPA --> DB
EDGE --> DB
PA --> EMAIL
PA --> MAPS
SUPA --> STORAGE
Loading
Multi-Application Architecture
graph LR
subgraph "Public Domain (kitions.com)"
PUB[Public App<br/>Marketing & Auth]
end
subgraph "Dashboard Domain (dashboard.kitions.com)"
DASH[Dashboard App<br/>Business Management]
end
subgraph "Shared Infrastructure"
SUPABASE[Supabase Backend]
DB[(Shared Database)]
end
PUB --> SUPABASE
DASH --> SUPABASE
SUPABASE --> DB
PUB -.->|Redirect after signup| DASH
DASH -.->|Back to public| PUB
erDiagram
users ||--o{ retailers : "has"
users ||--o{ distributors : "has"
users ||--|| user_verification_statuses : "has"
distributors ||--o{ distributor_products : "owns"
distributors ||--o{ orders : "receives"
retailers ||--o{ orders : "places"
product_categories ||--o{ distributor_products : "categorizes"
distributor_products ||--o{ product_batches : "has"
distributor_products ||--o{ order_items : "included_in"
orders ||--o{ order_items : "contains"
users {
uuid id PK
string email
string first_name
string last_name
string phone
string business_name
string business_address
string business_type
string user_type
string profile_picture_url
timestamp created_at
timestamp updated_at
string unique_identifier
}
retailers {
uuid id PK
uuid user_id FK
string store_address
string store_type
string inventory_needs
timestamp created_at
timestamp updated_at
}
distributors {
uuid id PK
uuid user_id FK
decimal min_order_amount
timestamp created_at
timestamp updated_at
}
user_verification_statuses {
uuid id PK
uuid user_id FK
string status
timestamp updated_at
}
product_categories {
uuid id PK
string name
timestamp created_at
}
distributor_products {
uuid id PK
uuid distributor_id FK
uuid category_id FK
string name
text description
decimal price
string image_url
integer case_size
integer stock_quantity
string sku
string upc
timestamp created_at
timestamp updated_at
}
product_batches {
uuid id PK
uuid product_id FK
uuid distributor_id FK
string batch_number
integer quantity
integer remaining_quantity
timestamp received_date
timestamp expiration_date
timestamp created_at
}
orders {
uuid id PK
string order_number
uuid retailer_id FK
uuid distributor_id FK
string status
string payment_status
decimal subtotal
decimal tax
decimal discount
decimal total
text notes
timestamp created_at
timestamp updated_at
}
order_items {
uuid id PK
uuid order_id FK
uuid product_id FK
integer quantity
decimal unit_price
decimal total_price
}
Loading
Key Database Features
Row Level Security (RLS): Implemented on all tables to ensure data isolation
UUID Primary Keys: For better security and distributed systems
Audit Trails: Created/updated timestamps on all entities
Referential Integrity: Foreign key constraints maintain data consistency
Flexible Schema: Supports multiple business types and use cases
Authentication & Authorization
Authentication Flow
sequenceDiagram
participant U as User
participant PA as Public App
participant SA as Supabase Auth
participant DB as Database
participant DA as Dashboard App
U->>PA: 1. Sign up with email/password
PA->>SA: 2. Create auth user
SA->>U: 3. Send verification email
U->>SA: 4. Click verification link
SA->>PA: 5. Redirect with auth code
PA->>SA: 6. Exchange code for session
PA->>DB: 7. Create user profile
PA->>DA: 8. Redirect to dashboard
DA->>SA: 9. Validate session
SA->>DA: 10. Return user data
graph LR
subgraph "Client Side"
COMP[React Component]
HOOK[Custom Hook]
end
subgraph "Supabase Client"
CLIENT[Supabase Client]
AUTH[Auth Module]
DB[Database Module]
STORAGE[Storage Module]
end
subgraph "Backend"
POSTGRES[(PostgreSQL)]
RLS[Row Level Security]
TRIGGERS[Database Triggers]
end
COMP --> HOOK
HOOK --> CLIENT
CLIENT --> AUTH
CLIENT --> DB
CLIENT --> STORAGE
DB --> POSTGRES
AUTH --> RLS
POSTGRES --> TRIGGERS
Loading
Data Flow Patterns
Product Management Flow
sequenceDiagram
participant C as Component
participant S as Supabase Client
participant DB as Database
participant ST as Storage
C->>S: Create product with image
S->>ST: Upload product image
ST-->>S: Return image URL
S->>DB: Insert product record
DB-->>S: Return created product
S-->>C: Success response
C->>C: Update UI state
Loading
Order Processing Flow
sequenceDiagram
participant R as Retailer
participant D as Distributor
participant DB as Database
participant N as Notifications
R->>DB: Create order
DB->>N: Trigger order notification
N->>D: Notify new order
D->>DB: Update order status
DB->>N: Trigger status update
N->>R: Notify status change
# Public Appcd public-app
npm run dev # Development server (port 3000)
npm run build # Production build
npm run lint # ESLint check# Dashboard Appcd dashboard-app
npm run dev # Development server (port 3001)
npm run build # Production build
npm run lint # ESLint check
Key Technical Decisions
Architecture Decisions
Multi-App Architecture: Separate concerns and domains
Supabase Backend: Rapid development with built-in features
Next.js 15: Latest React features and performance
TypeScript: Type safety and developer experience
Tailwind CSS: Utility-first styling approach
Database Decisions
PostgreSQL: Robust relational database
UUID Primary Keys: Better security and distribution
Row Level Security: Database-level authorization
Audit Trails: Comprehensive change tracking
Frontend Decisions
Server Components: Better performance and SEO
Client Components: Interactive user interfaces
Custom Hooks: Reusable state logic
Component Libraries: Consistent UI patterns
Future Enhancements
Planned Features
Real-time Chat: Communication between distributors and retailers
Advanced Analytics: Business intelligence dashboard
Mobile Apps: Native iOS and Android applications
API Gateway: Public API for third-party integrations
Multi-language Support: Internationalization
Advanced Search: Elasticsearch integration
Payment Processing: Integrated payment solutions
Technical Improvements
Microservices: Break down into smaller services
Event Sourcing: Better audit trails and state management
GraphQL: More efficient data fetching
Redis Caching: Improved performance
Monitoring: Application performance monitoring
CI/CD Pipeline: Automated testing and deployment
This documentation is maintained by the development team and updated with each major release.
About
Kitions is a modern B2B platform that connects suppliers and retailers in one simple, efficient app. Retailers can easily discover new products, place bulk orders, and communicate directly with suppliers no middlemen, no confusion.