Architecture Diagrams¶
Visual documentation of the Freeze Design webshop architecture, components, and workflows.
Color Legend¶
| Color | Meaning |
|---|---|
| ๐ฆ Blue | Frontend (Next.js/React) |
| ๐ฉ Green | Backend (Django/DRF) |
| ๐ง Orange | External Services |
| ๐ช Purple | Database/Storage |
| โฌ Gray | Users/Actors |
1. System Context Diagram¶
High-level overview showing the system and its external interactions.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#0d9488', 'primaryTextColor': '#fff', 'primaryBorderColor': '#0f766e', 'lineColor': '#64748b', 'secondaryColor': '#f1f5f9', 'tertiaryColor': '#fff'}}}%%
flowchart TB
subgraph users[" ๐ฅ Users "]
customer["๐ Customer<br/><small>Browse, Design, Order</small>"]
teamManager["๐ Team Manager<br/><small>Bulk Orders</small>"]
admin["โ๏ธ Admin<br/><small>Manage Catalog</small>"]
end
subgraph system["๐ช Freeze Design Webshop"]
frontend["๐ฅ๏ธ Frontend<br/><small>Next.js 16</small>"]
backend["โก Backend API<br/><small>Django REST</small>"]
end
subgraph external[" โ๏ธ External Services "]
posthog["๐ PostHog<br/><small>Analytics</small>"]
sentry["๐ Sentry<br/><small>Error Tracking</small>"]
s3["๐ฆ S3 Storage<br/><small>Media Files</small>"]
email["๐ง Email Service<br/><small>Notifications</small>"]
end
subgraph data[" ๐พ Data Stores "]
postgres[("๐ PostgreSQL<br/><small>Primary DB</small>")]
redis[("โก Redis<br/><small>Cache & Queue</small>")]
end
customer --> frontend
teamManager --> frontend
admin --> frontend
frontend <--> backend
frontend --> posthog
frontend --> sentry
backend --> sentry
backend --> s3
backend --> email
backend <--> postgres
backend <--> redis
style frontend fill:#3b82f6,stroke:#1d4ed8,color:#fff
style backend fill:#10b981,stroke:#059669,color:#fff
style postgres fill:#8b5cf6,stroke:#7c3aed,color:#fff
style redis fill:#8b5cf6,stroke:#7c3aed,color:#fff
style posthog fill:#f97316,stroke:#ea580c,color:#fff
style sentry fill:#f97316,stroke:#ea580c,color:#fff
style s3 fill:#f97316,stroke:#ea580c,color:#fff
style email fill:#f97316,stroke:#ea580c,color:#fff
style customer fill:#6b7280,stroke:#4b5563,color:#fff
style teamManager fill:#6b7280,stroke:#4b5563,color:#fff
style admin fill:#6b7280,stroke:#4b5563,color:#fff
2. Container Diagram¶
Services, applications, and their communication patterns.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#0d9488'}}}%%
flowchart TB
subgraph browser["๐ Browser"]
spa["๐ฑ Single Page App<br/><small>React 19 + Next.js 16</small><br/><small>TypeScript, Tailwind CSS</small>"]
designer["๐จ Design Editor<br/><small>Fabric.js Canvas</small>"]
end
subgraph frontend_server["๐ฅ๏ธ Frontend Server :3000"]
nextjs["โ๏ธ Next.js Server<br/><small>SSR + API Routes</small>"]
end
subgraph backend_server["โก Backend Server :8000"]
django["๐ Django API<br/><small>REST Framework</small><br/><small>drf-spectacular</small>"]
celery["โฐ Celery Worker<br/><small>Async Tasks</small>"]
end
subgraph data_layer["๐พ Data Layer"]
pg[("๐ PostgreSQL 15<br/><small>Primary Database</small>")]
redis_cache[("โก Redis 7<br/><small>Cache</small>")]
redis_queue[("โก Redis 7<br/><small>Task Queue</small>")]
end
subgraph storage["๐ฆ File Storage"]
media["๐ผ๏ธ Media Storage<br/><small>Product Images</small><br/><small>Design Previews</small>"]
prints["๐ Print Files<br/><small>Production Ready</small>"]
end
spa --> nextjs
designer --> nextjs
nextjs <-->|"REST API<br/>JSON + CSRF"| django
django --> pg
django --> redis_cache
django --> celery
celery --> redis_queue
celery --> media
celery --> prints
django --> media
style spa fill:#3b82f6,stroke:#1d4ed8,color:#fff
style designer fill:#3b82f6,stroke:#1d4ed8,color:#fff
style nextjs fill:#3b82f6,stroke:#1d4ed8,color:#fff
style django fill:#10b981,stroke:#059669,color:#fff
style celery fill:#10b981,stroke:#059669,color:#fff
style pg fill:#8b5cf6,stroke:#7c3aed,color:#fff
style redis_cache fill:#8b5cf6,stroke:#7c3aed,color:#fff
style redis_queue fill:#8b5cf6,stroke:#7c3aed,color:#fff
style media fill:#f97316,stroke:#ea580c,color:#fff
style prints fill:#f97316,stroke:#ea580c,color:#fff
3. Frontend Architecture¶
Next.js application structure with providers, contexts, and components.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#3b82f6'}}}%%
flowchart TB
subgraph layout["๐ Root Layout"]
subgraph providers["๐ Providers Stack"]
sentry_p["๐ SentryProvider"]
posthog_p["๐ PostHogProvider"]
query_p["๐ QueryProvider<br/><small>TanStack Query</small>"]
theme_p["๐จ ThemeProvider"]
auth_p["๐ AuthProvider"]
cart_p["๐ CartProvider"]
team_p["๐ฅ TeamOrderProvider"]
end
end
subgraph pages["๐ Pages (App Router)"]
home["๐ / <br/><small>Homepage</small>"]
products["๐ฆ /products<br/><small>Product List</small>"]
detail["๐ /products/[slug]<br/><small>Product Detail</small>"]
designer_page["๐จ /designer<br/><small>Design Editor</small>"]
cart_page["๐ /cart<br/><small>Shopping Cart</small>"]
checkout["๐ณ /checkout<br/><small>Checkout</small>"]
team["๐ฅ /team-order<br/><small>Team Orders</small>"]
orders["๐ /orders<br/><small>Order History</small>"]
end
subgraph components["๐งฉ Components (71 total)"]
nav["๐งญ Navigation"]
product_comp["๐ฆ ProductCard<br/>ProductGrid"]
designer_comp["๐จ Designer<br/><small>Fabric.js Canvas</small>"]
cart_comp["๐ CartItem<br/>CartSummary"]
form_comp["๐ Forms<br/>Inputs"]
end
subgraph hooks["๐ช Custom Hooks"]
useProducts["useProducts"]
useCart["useCart"]
useDesign["useDesign"]
useAuth["useAuth"]
end
subgraph api_client["๐ก API Client"]
axios_client["Axios Instance<br/><small>CSRF + Credentials</small>"]
end
sentry_p --> posthog_p --> query_p --> theme_p --> auth_p --> cart_p --> team_p
team_p --> pages
pages --> components
components --> hooks
hooks --> api_client
api_client -->|"HTTP"| backend_api["โก Backend API"]
style sentry_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style posthog_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style query_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style theme_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style auth_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style cart_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style team_p fill:#3b82f6,stroke:#1d4ed8,color:#fff
style home fill:#60a5fa,stroke:#3b82f6,color:#fff
style products fill:#60a5fa,stroke:#3b82f6,color:#fff
style detail fill:#60a5fa,stroke:#3b82f6,color:#fff
style designer_page fill:#60a5fa,stroke:#3b82f6,color:#fff
style cart_page fill:#60a5fa,stroke:#3b82f6,color:#fff
style checkout fill:#60a5fa,stroke:#3b82f6,color:#fff
style team fill:#60a5fa,stroke:#3b82f6,color:#fff
style orders fill:#60a5fa,stroke:#3b82f6,color:#fff
style backend_api fill:#10b981,stroke:#059669,color:#fff
4. Backend Architecture¶
Django application structure with apps and their responsibilities.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#10b981'}}}%%
flowchart TB
subgraph api_layer["๐ API Layer"]
drf["Django REST Framework<br/><small>Serializers + Views</small>"]
spectacular["drf-spectacular<br/><small>OpenAPI Docs</small>"]
end
subgraph apps["๐ฆ Django Apps"]
users_app["๐ค users<br/><small>Authentication</small><br/><small>User Profiles</small>"]
products_app["๐ฆ products<br/><small>Catalog</small><br/><small>Categories, Variants</small>"]
designs_app["๐จ designs<br/><small>Custom Designs</small><br/><small>Templates, Fonts</small>"]
orders_app["๐ orders<br/><small>Cart & Orders</small><br/><small>Order Items</small>"]
pricing_app["๐ฐ pricing<br/><small>Discounts</small><br/><small>Volume Pricing</small>"]
clipart_app["๐ผ๏ธ clipart<br/><small>Design Assets</small>"]
core_app["โ๏ธ core<br/><small>Site Settings</small><br/><small>Pages</small>"]
payments_app["๐ณ payments<br/><small>Payment Processing</small>"]
end
subgraph services["โก Services Layer"]
design_service["Design Service<br/><small>Cost Calculation</small>"]
order_service["Order Service<br/><small>Checkout Logic</small>"]
pricing_service["Pricing Service<br/><small>Discount Rules</small>"]
end
subgraph tasks["โฐ Celery Tasks"]
preview_task["Generate Preview<br/><small>Image Processing</small>"]
print_task["Generate Print File<br/><small>Production Ready</small>"]
export_task["Catalog Export<br/><small>Backup/Migration</small>"]
end
drf --> apps
spectacular --> drf
apps --> services
services --> tasks
designs_app --> design_service
orders_app --> order_service
pricing_app --> pricing_service
style drf fill:#10b981,stroke:#059669,color:#fff
style spectacular fill:#10b981,stroke:#059669,color:#fff
style users_app fill:#34d399,stroke:#10b981,color:#000
style products_app fill:#34d399,stroke:#10b981,color:#000
style designs_app fill:#34d399,stroke:#10b981,color:#000
style orders_app fill:#34d399,stroke:#10b981,color:#000
style pricing_app fill:#34d399,stroke:#10b981,color:#000
style clipart_app fill:#34d399,stroke:#10b981,color:#000
style core_app fill:#34d399,stroke:#10b981,color:#000
style payments_app fill:#34d399,stroke:#10b981,color:#000
style design_service fill:#10b981,stroke:#059669,color:#fff
style order_service fill:#10b981,stroke:#059669,color:#fff
style pricing_service fill:#10b981,stroke:#059669,color:#fff
style preview_task fill:#f97316,stroke:#ea580c,color:#fff
style print_task fill:#f97316,stroke:#ea580c,color:#fff
style export_task fill:#f97316,stroke:#ea580c,color:#fff
5. Data Model Overview¶
Core database entities and their relationships.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8b5cf6'}}}%%
erDiagram
User ||--o| UserProfile : has
User ||--o{ CustomDesign : creates
User ||--o| ShoppingCart : has
User ||--o{ Order : places
Category ||--o{ Category : parent
Category ||--o{ Product : contains
Brand ||--o{ Product : owns
Product ||--o{ ProductVariant : has
Product }o--o{ Color : available_in
Product }o--o{ Size : available_in
ProductVariant ||--|| Product : belongs_to
ProductVariant ||--|| Color : has
ProductVariant ||--|| Size : has
Color ||--o{ ProductColorImage : has_images
CustomDesign ||--o| Product : for_product
CustomDesign ||--o| ProductVariant : for_variant
CustomDesign ||--o{ TeamNameList : has_members
ShoppingCart ||--o{ CartItem : contains
CartItem ||--o| ProductVariant : references
CartItem ||--o| CustomDesign : has_design
Order ||--o{ OrderItem : contains
OrderItem ||--o| ProductVariant : references
OrderItem ||--o| CustomDesign : has_design
DiscountCode }o--o{ Order : applied_to
VolumeDiscount ||--o| Product : for_product
TeamDiscount ||--o{ Order : applied_to
User {
int id PK
string email
string password
datetime created
}
Product {
int id PK
string sku
string name
string slug
decimal base_price
json print_positions
}
ProductVariant {
int id PK
string sku
int stock_quantity
decimal price_adjustment
boolean is_active
}
CustomDesign {
int id PK
json design_json_front
json design_json_back
string status
decimal calculated_cost
}
Order {
int id PK
string order_number
string status
decimal total
datetime created
}
6. User Flow: Browse โ Design โ Checkout¶
Complete customer journey from browsing to order completion.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#0d9488'}}}%%
sequenceDiagram
autonumber
participant U as ๐ค Customer
participant F as ๐ฅ๏ธ Frontend
participant B as โก Backend
participant DB as ๐พ Database
participant C as โฐ Celery
rect rgb(59, 130, 246, 0.1)
Note over U,DB: 1๏ธโฃ Browse Products
U->>F: Visit /products
F->>B: GET /api/products/
B->>DB: Query products
DB-->>B: Product list
B-->>F: JSON response
F-->>U: Display product grid
end
rect rgb(16, 185, 129, 0.1)
Note over U,DB: 2๏ธโฃ View Product Details
U->>F: Click product card
F->>B: GET /api/products/{slug}/
B->>DB: Query product + variants
DB-->>B: Product details
B-->>F: Product with colors, sizes
F-->>U: Show product page
end
rect rgb(139, 92, 246, 0.1)
Note over U,C: 3๏ธโฃ Create Design
U->>F: Click "Start ontwerpen"
F-->>U: Open Fabric.js canvas
U->>F: Add text, images, colors
F->>F: Local canvas editing
U->>F: Click "Save Design"
F->>B: POST /api/designs/
B->>DB: Store design JSON
B->>C: Generate preview task
C->>DB: Store preview image
B-->>F: Design ID + preview URL
F-->>U: Show saved design
end
rect rgb(249, 115, 22, 0.1)
Note over U,DB: 4๏ธโฃ Add to Cart
U->>F: Select size, quantity
U->>F: Click "Add to cart"
F->>B: POST /api/cart/add/
B->>B: Calculate design cost
B->>DB: Add CartItem
DB-->>B: Updated cart
B-->>F: Cart with totals
F-->>U: Show cart badge
end
rect rgb(236, 72, 153, 0.1)
Note over U,DB: 5๏ธโฃ Checkout
U->>F: Go to /checkout
F->>B: GET /api/cart/
B-->>F: Cart items + totals
U->>F: Enter shipping info
U->>F: Click "Place Order"
F->>B: POST /api/orders/checkout/
B->>B: Validate cart
B->>B: Apply discounts
B->>DB: Create Order + OrderItems
B->>DB: Clear cart
B-->>F: Order confirmation
F-->>U: Show order success
end
7. Design Cost Calculation Flow¶
How design pricing is calculated based on elements and colors.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8b5cf6'}}}%%
flowchart TB
subgraph input["๐ฅ Design Input"]
design["CustomDesign<br/><small>Fabric.js JSON</small>"]
end
subgraph parse["๐ Parse Design"]
front["Front View<br/><small>design_json_front</small>"]
back["Back View<br/><small>design_json_back</small>"]
left["Left View<br/><small>design_json_left</small>"]
right["Right View<br/><small>design_json_right</small>"]
end
subgraph count["๐ Count Elements"]
text_count["Text Elements<br/><small>i-text, textbox</small>"]
image_count["Image Elements<br/><small>image, clipart</small>"]
end
subgraph colors["๐จ Color Analysis"]
extract["Extract Unique Colors<br/><small>from text fills</small>"]
lookup["Lookup TextColor<br/><small>price_modifier</small>"]
surcharge["Color Surcharges<br/><small>special colors extra</small>"]
end
subgraph pricing["๐ฐ Calculate Cost"]
text_cost["Text Cost<br/><small>count ร design_text_price</small>"]
image_cost["Image Cost<br/><small>count ร design_image_price</small>"]
color_cost["Color Cost<br/><small>ฮฃ surcharges</small>"]
end
subgraph total["๐ Total Design Cost"]
sum["total = text_cost<br/>+ image_cost<br/>+ color_surcharges"]
end
design --> front & back & left & right
front & back & left & right --> text_count & image_count
front & back & left & right --> extract
extract --> lookup --> surcharge
text_count --> text_cost
image_count --> image_cost
surcharge --> color_cost
text_cost & image_cost & color_cost --> sum
style design fill:#8b5cf6,stroke:#7c3aed,color:#fff
style sum fill:#10b981,stroke:#059669,color:#fff
style text_cost fill:#3b82f6,stroke:#1d4ed8,color:#fff
style image_cost fill:#3b82f6,stroke:#1d4ed8,color:#fff
style color_cost fill:#f97316,stroke:#ea580c,color:#fff
8. Team Order Flow¶
Bulk ordering workflow for teams and organizations.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#0d9488'}}}%%
sequenceDiagram
autonumber
participant TM as ๐ Team Manager
participant F as ๐ฅ๏ธ Frontend
participant B as โก Backend
participant DB as ๐พ Database
rect rgb(59, 130, 246, 0.1)
Note over TM,DB: 1๏ธโฃ Create Team Design Template
TM->>F: Design team jersey template
F->>B: POST /api/designs/
B->>DB: Save template design
B-->>F: Design ID
end
rect rgb(16, 185, 129, 0.1)
Note over TM,DB: 2๏ธโฃ Add Team Members
TM->>F: Enter team roster
Note right of F: Name, Number, Size<br/>per team member
F->>B: POST /api/designs/{id}/add_team_names/
B->>DB: Create TeamNameList entries
B-->>F: Team roster saved
end
rect rgb(139, 92, 246, 0.1)
Note over TM,DB: 3๏ธโฃ Add All to Cart
TM->>F: Click "Add team to cart"
F->>B: POST /api/cart/add/ (bulk)
loop For each team member
B->>B: Calculate individual cost
B->>DB: Create CartItem
end
B->>B: Check TeamDiscount eligibility
B->>B: Apply volume discount
B-->>F: Cart with team items
F-->>TM: Show team order summary
end
rect rgb(249, 115, 22, 0.1)
Note over TM,DB: 4๏ธโฃ Checkout with Discount
TM->>F: Proceed to checkout
F->>B: POST /api/orders/checkout/
B->>B: Apply TeamDiscount
B->>DB: Create Order with all items
B-->>F: Order with bulk pricing
F-->>TM: Order confirmation
end
9. CI/CD Pipeline¶
GitHub Actions workflow for testing, building, and deploying.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#0d9488'}}}%%
flowchart TB
subgraph trigger["๐ฏ Triggers"]
push["Push to main/develop"]
pr["Pull Request"]
tag["Version Tag (v*)"]
end
subgraph ci["๐งช CI Pipeline (ci.yml)"]
subgraph backend_test["๐ Backend Tests"]
py_setup["Setup Python 3.12"]
pg_redis["Start PostgreSQL + Redis"]
lint_be["Lint (flake8)"]
migrate["Run Migrations"]
pytest["pytest + Coverage"]
end
subgraph frontend_test["โ๏ธ Frontend Tests"]
node_setup["Setup Node.js 20"]
lint_fe["Lint (ESLint)"]
jest["Jest Unit Tests"]
playwright["Playwright E2E"]
end
subgraph docs_test["๐ Docs Tests"]
mkdocs_build["Build MkDocs"]
end
end
subgraph deploy_prod["๐ Deploy Production (deploy-production.yml)"]
docker_build["๐ณ Build Docker Images"]
ghcr_push["๐ฆ Push to GHCR"]
ssh_deploy["๐ SSH Deploy"]
health_check["โค๏ธ Health Checks"]
discord["๐ข Discord Notify"]
end
subgraph docs_deploy["๐ Docs Deploy (docs.yml)"]
build_mkdocs["Build MkDocs"]
build_openapi["Build OpenAPI/Swagger"]
build_storybook["Build Storybook"]
build_typedoc["Build TypeDoc"]
combine["Combine All Docs"]
cloudflare["Deploy to Cloudflare Pages"]
end
push --> ci
pr --> ci
push --> docs_deploy
tag --> deploy_prod
ci --> backend_test & frontend_test & docs_test
py_setup --> pg_redis --> lint_be --> migrate --> pytest
node_setup --> lint_fe --> jest --> playwright
docker_build --> ghcr_push --> ssh_deploy --> health_check --> discord
build_mkdocs & build_openapi & build_storybook & build_typedoc --> combine --> cloudflare
style push fill:#6b7280,stroke:#4b5563,color:#fff
style pr fill:#6b7280,stroke:#4b5563,color:#fff
style tag fill:#f97316,stroke:#ea580c,color:#fff
style pytest fill:#10b981,stroke:#059669,color:#fff
style playwright fill:#3b82f6,stroke:#1d4ed8,color:#fff
style docker_build fill:#0ea5e9,stroke:#0284c7,color:#fff
style cloudflare fill:#f97316,stroke:#ea580c,color:#fff
style discord fill:#5865f2,stroke:#4752c4,color:#fff
10. Deployment Architecture¶
Production environment topology.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#0d9488'}}}%%
flowchart TB
subgraph internet["๐ Internet"]
users["๐ฅ Users"]
cdn["โ๏ธ Cloudflare<br/><small>CDN + WAF</small>"]
end
subgraph github["๐ฆ GitHub"]
repo["Repository"]
ghcr["Container Registry<br/><small>GHCR</small>"]
actions["GitHub Actions"]
end
subgraph server["๐ฅ๏ธ Production Server"]
subgraph docker["๐ณ Docker Compose"]
nginx["๐ Nginx<br/><small>Reverse Proxy</small><br/><small>:80, :443</small>"]
frontend_c["โ๏ธ Frontend<br/><small>Next.js</small><br/><small>:3000</small>"]
backend_c["๐ Backend<br/><small>Django + Gunicorn</small><br/><small>:8000</small>"]
celery_c["โฐ Celery<br/><small>Worker</small>"]
postgres_c[("๐ PostgreSQL<br/><small>:5432</small>")]
redis_c[("โก Redis<br/><small>:6379</small>")]
end
volumes["๐ Volumes<br/><small>Media, Static, Logs</small>"]
end
subgraph external["โ๏ธ External"]
s3_ext["๐ฆ S3 Backup"]
sentry_ext["๐ Sentry"]
posthog_ext["๐ PostHog"]
end
users --> cdn --> nginx
nginx --> frontend_c
nginx --> backend_c
frontend_c <--> backend_c
backend_c --> postgres_c
backend_c --> redis_c
backend_c --> celery_c
celery_c --> redis_c
backend_c --> volumes
celery_c --> volumes
actions --> ghcr
ghcr --> docker
backend_c --> sentry_ext
frontend_c --> sentry_ext
frontend_c --> posthog_ext
backend_c --> s3_ext
style users fill:#6b7280,stroke:#4b5563,color:#fff
style cdn fill:#f97316,stroke:#ea580c,color:#fff
style nginx fill:#009639,stroke:#007a2f,color:#fff
style frontend_c fill:#3b82f6,stroke:#1d4ed8,color:#fff
style backend_c fill:#10b981,stroke:#059669,color:#fff
style celery_c fill:#10b981,stroke:#059669,color:#fff
style postgres_c fill:#8b5cf6,stroke:#7c3aed,color:#fff
style redis_c fill:#dc2626,stroke:#b91c1c,color:#fff
style ghcr fill:#6b7280,stroke:#4b5563,color:#fff
11. API Endpoint Map¶
REST API organized by resource.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#10b981'}}}%%
flowchart LR
subgraph api["โก /api"]
subgraph products_api["๐ฆ Products"]
p1["GET /products/"]
p2["GET /products/{id}/"]
p3["GET /categories/"]
p4["GET /categories/tree/"]
p5["GET /colors/"]
p6["GET /sizes/"]
p7["GET /variants/"]
end
subgraph designs_api["๐จ Designs"]
d1["GET /designs/"]
d2["POST /designs/"]
d3["GET /designs/{id}/"]
d4["PATCH /designs/{id}/"]
d5["DELETE /designs/{id}/"]
d6["POST /designs/{id}/add_team_names/"]
d7["POST /designs/{id}/generate_preview/"]
d8["PATCH /designs/{id}/finalize/"]
end
subgraph cart_api["๐ Cart"]
c1["GET /cart/"]
c2["POST /cart/add/"]
c3["PATCH /cart/items/{id}/"]
c4["DELETE /cart/items/{id}/"]
c5["POST /cart/clear/"]
end
subgraph orders_api["๐ Orders"]
o1["GET /orders/"]
o2["GET /orders/{id}/"]
o3["POST /orders/checkout/"]
end
subgraph auth_api["๐ Auth"]
a1["POST /auth/register/"]
a2["POST /auth/login/"]
a3["POST /auth/logout/"]
a4["GET /auth/me/"]
a5["GET /auth/profile/"]
a6["PATCH /auth/profile/"]
end
subgraph docs_api["๐ Docs"]
doc1["GET /schema/"]
doc2["GET /docs/"]
doc3["GET /redoc/"]
end
end
style p1 fill:#3b82f6,stroke:#1d4ed8,color:#fff
style d2 fill:#10b981,stroke:#059669,color:#fff
style c2 fill:#10b981,stroke:#059669,color:#fff
style o3 fill:#10b981,stroke:#059669,color:#fff
style a2 fill:#10b981,stroke:#059669,color:#fff
12. State Management¶
How application state flows through the frontend.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#3b82f6'}}}%%
flowchart TB
subgraph global["๐ Global State (React Context)"]
auth_state["๐ AuthContext<br/><small>user, loading</small><br/><small>login(), logout()</small>"]
cart_state["๐ CartContext<br/><small>cart, items</small><br/><small>add(), remove()</small>"]
team_state["๐ฅ TeamOrderContext<br/><small>members, design</small>"]
theme_state["๐จ ThemeContext<br/><small>theme: light/dark</small>"]
end
subgraph server["๐ก Server State (TanStack Query)"]
products_query["useQuery: products"]
design_query["useQuery: designs"]
order_query["useQuery: orders"]
mutation["useMutation:<br/><small>create, update, delete</small>"]
end
subgraph local["๐ Local State (useState/Zustand)"]
form_state["Form inputs"]
modal_state["Modal visibility"]
canvas_state["๐จ Fabric.js Canvas<br/><small>Design editor state</small>"]
end
subgraph cache["๐พ Cache Layer"]
query_cache["React Query Cache<br/><small>5 min stale time</small>"]
local_storage["localStorage<br/><small>Theme, preferences</small>"]
end
auth_state --> cart_state
cart_state --> team_state
products_query --> query_cache
design_query --> query_cache
order_query --> query_cache
theme_state --> local_storage
canvas_state --> mutation --> design_query
style auth_state fill:#3b82f6,stroke:#1d4ed8,color:#fff
style cart_state fill:#3b82f6,stroke:#1d4ed8,color:#fff
style team_state fill:#3b82f6,stroke:#1d4ed8,color:#fff
style theme_state fill:#3b82f6,stroke:#1d4ed8,color:#fff
style canvas_state fill:#8b5cf6,stroke:#7c3aed,color:#fff
style query_cache fill:#10b981,stroke:#059669,color:#fff
Quick Reference¶
| Diagram | Purpose |
|---|---|
| System Context | High-level system overview |
| Container | Services and communication |
| Frontend | Next.js structure |
| Backend | Django apps |
| Data Model | Database entities |
| User Flow | Customer journey |
| Design Cost | Pricing logic |
| Team Order | Bulk ordering |
| CI/CD | Deployment pipeline |
| Deployment | Production topology |
| API Map | REST endpoints |
| State | Frontend state flow |