The user wants an architecture for a "multi-tenant design review portal."
Key features required:
- Multi-tenancy: The system must isolate data and access for different organizations (tenants).
- Design Review Status: Showing the current state of a review (e.g., Pending, Approved, Rejected).
- Blockers: Highlighting issues preventing approval.
- Component Adoption Metrics: Analytics on how often specific design components (UI patterns, libraries) are used across the tenant's designs.
High-Level Architecture Pattern:
Microservices or Modular Monolith. Given the distinct domains (Reviews, Metrics/Analytics, Users/Tenants), a microservices approach (or a well-structured modular monolith) is appropriate. Let's lean towards a logical microservices view for clarity in separation of concerns.
Core Components:
- Frontend (Portal): Single Page Application (SPA). Needs to handle tenant context (subdomain or path).
- API Gateway: Entry point, handles routing, authentication/authorization, and tenant resolution.
- Identity & Access Management (IAM): Authentication (AuthN) and Authorization (AuthZ). Must support roles scoped to tenants (e.g., Tenant Admin, Reviewer, Designer).
- Review Service: Manages the lifecycle of design artifacts, reviews, comments, and blockers.
- Metrics/Analytics Service: Ingests usage data and aggregates component adoption stats.
- Tenant Management Service: Onboarding, configuration, billing (optional but likely needed).
- Storage:
- Relational DB (Transactional data).
- Object Storage (Design files/images).
- Time-series or OLAP DB (Metrics).
Multi-Tenancy Strategy:
- Isolation Level: Shared database with tenant IDs (discriminator column) is usually the most cost-effective and easiest to manage for SaaS. Siloed databases are more secure but harder to maintain. Let's propose a "Shared Service, Shared Database with Row-Level Security" model for efficiency, with options for siloed DBs for enterprise tenants.
- Resolution: Subdomains (e.g.,
tenantA.portal.com).
Detailed Design - Feature by Feature:
-
Status & Blockers (The "Review" Domain):
- Entities:
Design, Review, Comment, ChecklistItem (the blockers).
- Workflow: Upload Design -> Reviewer checks -> Adds Blockers -> Status moves to "Changes Requested".
-
Component Adoption Metrics (The "Analytics" Domain):
- How is data collected? Metadata attached to designs? Or scanning Figma/Code?
- Let's assume metadata attached to the design upload or a plugin that pushes data.
- Aggregation: Count usage of
Button, Modal, Form components.
Data Model (Conceptual):
Tenants (id, name, slug, settings)
Users (id, tenant_id, email, role)
Designs (id, tenant_id, title, file_url, status)
Reviews (id, design_id, reviewer_id, status, blockers_json)
ComponentUsage (tenant_id, component_name, count, timestamp)
Technology Stack (Suggestion):
- Frontend: React/Next.js + Tailwind (good for UI/UX focus).
- Backend: Node.js/Go/Java.
- DB: PostgreSQL (Robust, RLS support).
- Cache: Redis.
- Queue: Kafka/RabbitMQ (for async metric processing).
Security Considerations:
- Row-Level Security (RLS) is crucial if using a shared DB.
- RBAC: Global Admin vs Tenant Admin vs Tenant Reviewer.
Structuring the Answer:
- High-Level Architecture Diagram (Text description): Visualizing the flow.
- Multi-Tenancy Strategy: How isolation is achieved.
- Key Services & APIs: Breaking down the backend.
- Data Model: The schema.
- The Metrics Pipeline: Specifically addressing "Component Adoption".
- Security: RLS and RBAC.
- UX/UI: How the user interacts with the portal.
Let's refine the "Component Adoption" part. It sounds like a "Design System" compliance tool.
- The portal probably integrates with a design tool (Figma) or a code repo.
- When a design is submitted, it lists the components used.
- The metrics service aggregates: "Tenant A uses 'PrimaryButton' 500 times, but 'DeprecatedButton' 5 times."
Let's create a structured, professional architectural proposal.
Self-Correction during thought process:
Initially, I thought about just one database. However, for the metrics, a standard Postgres DB might get bogged down if we track every single instance of a button click or view.
Correction: The metrics should likely be pre-aggregated or stored in a columnar store/Time Series DB, or simply stored as aggregate snapshots in a document store (Mongo/Elasticsearch) for fast querying. Let's stick to Postgres for the MVP architecture for simplicity but mention event sourcing for the metrics pipeline to allow scaling.
Outline:
- System Overview
- Multi-Tenancy Architecture (The Core)
- Service Decomposition
- Data Architecture (Schema & Isolation)
- Workflow: Review & Blockers
- Workflow: Component Adoption Analytics
- Tech Stack Recommendation
Let's write it out.
This architecture outlines a scalable, secure, and highly available Design Review Portal (DRP). The system is designed as a SaaS platform serving multiple organizations (Tenants), enabling them to manage design lifecycles, identify bottlenecks, and track component library usage.
1. High-Level Architecture (The 10,000ft View)
We will utilize a Multi-Tenant Cloud-Native Architecture.
- Tenancy Model: Pool Model. All tenants share the same infrastructure and database, but logical isolation is enforced at the application and database layers via
tenant_id. This ensures cost-efficiency and simplified maintenance.
- Frontend: Single Page Application (SPA) with a Micro-frontend shell (to allow independent deployment of the "Dashboard" vs. the "Review Canvas").
- Backend: REST/GraphQL API Gateway routing to Domain-Driven Microservices.
- Data: A polyglot persistence strategy (Relational for ACID transactions, Document store for flexible design metadata, Time-series for metrics).
2. Core Components
A. Identity & Access Management (IAM)
- Provider: Auth0 or AWS Cognito.
- Role: Handles authentication.
- Tenant Resolution: Issues JWTs containing
tenant_id, user_role (Admin, Reviewer, Viewer), and permissions.
- Isolation: The frontend and backend rely on this token to scope all data requests.
B. The API Gateway (The Entry Point)
- Responsibility: Routes traffic, enforces rate limits (per tenant), and validates JWTs.
- Tenant Context Injection: Strips the subdomain (e.g.,
acme.portal.com), resolves it to a tenant_id, and adds it to the request header for downstream services.
C. Domain Services
- Review Service: Manages the lifecycle of a design review (Draft -> Pending -> Approved/Rejected). Handles comments, annotations, and versioning.
- Blocker Service: Manages impediments. Tracks dependencies (e.g., "Waiting on API spec from Team B").
- Metrics Service: Ingests usage data and aggregates component adoption statistics.
3. Data Architecture
We use a "Shared Database" approach with strict Row-Level Security (RLS).
Database Schema (PostgreSQL with RLS enabled):
tenants: id, name, slug, plan_tier.
users: id, tenant_id, email, role.
design_reviews: id, tenant_id, title, status (enum), figma_link, created_at.
blockers: id, review_id (FK), tenant_id, severity, reason, status (Open/Closed).
component_usage (Optimized for Analytics):
id, tenant_id, component_name (e.g., "PrimaryButton"), count, date_recorded.
Row-Level Security (RLS) Policy Example:
-- Ensure a user can only select rows where their tenant_id matches the row's tenant_id
CREATE POLICY tenant_isolation_policy ON design_reviews
USING (tenant_id = current_setting('app.current_tenant'));
4. Feature Deep Dive
A. Status & Workflow
- Mechanism: State Machine (e.g., XState) in the backend.
- Flow:
Draft -> Ready for Review -> In Review -> Changes Requested (Blocker created here) -> Approved.
- Audit Trail: Every status change is recorded in an immutable event log table (
review_history) for compliance.
B. Blockers Management
- Data Structure: Blockers are distinct entities linked to a Review ID.
- Attributes:
Reason (e.g., "Accessibility Fail", "Brand Mismatch"), Owner, Due Date.
- UI: A Kanban board view grouping reviews by their blocker status.
C. Component Adoption Metrics (The Innovation)
This feature tracks which design system components are actually being used in the designs uploaded/linked to the portal.
- Ingestion Pipeline:
- User links a Figma file.
- System triggers a Metadata Analyzer (Lambda function).
- Analyzer calls Figma API to fetch the node tree.
- Analyzer identifies components (e.g.,
DS-Button, DS-Modal) and counts instances.
- Data is pushed to a Time-Series DB (Amazon Timestream or InfluxDB).
- Visualization:
- Adoption Rate: % of designs using the latest version of the Design System.
- Custom Components: Alerts when teams create "one-off" components instead of using the library.
5. Infrastructure & DevOps (AWS Example)
- DNS: Route53 (Maps
*.portal.com to Load Balancer).
- Compute: Kubernetes (EKS) for complex orchestration OR AWS Fargate (Serverless Containers) for easier management.
- Storage: S3 for image assets (Design thumbnails). Enable S3 Access Points to ensure tenant isolation at the storage layer if necessary.
- Caching: Redis (ElastiCache). Keys are namespaced by tenant (e.g.,
tenant:acme:review:123).
6. API Design (GraphQL Recommended)
GraphQL is ideal here because the Dashboard needs a composite view (Review details + Blocker count + Metrics), while the Review Detail page needs deep data on comments.
Schema Snippet:
type Review {
id: ID!
title: String!
status: ReviewStatus!
blockers: [Blocker!]!
metrics: ComponentMetrics
}
type ComponentMetrics {
totalComponents: Int
libraryAdoptionPercentage: Float
deprecatedComponentsFound: [String]
}
type Query {
# The resolver extracts tenant_id from the auth token automatically
getReview(id: ID!): Review
listReviews(filter: ReviewFilter): [Review!]!
}
7. Security Considerations
- Tenant Context Propagation: Use a middleware chain to ensure the
tenant_id from the JWT is propagated to every database query to prevent data leakage.
- Storage Isolation: While S3 buckets can be shared, use pre-signed URLs scoped to the tenant for uploading/accessing design files.
- Rate Limiting: Implement tiered rate limiting (e.g., Free tier = 100 req/min, Enterprise = 1000 req/min) based on the Tenant ID.
8. The Dashboard (User Experience)
The portal entry point is a unified dashboard exposing the requested metrics:
- Left Rail: Navigation (Projects, Components, Settings).
- Main View:
- Status Widget: Donut chart showing Reviews by State (12 In Review, 5 Approved).
- Blockers List: High-priority list of open impediments.
- Adoption Graph: Line chart showing "Design System Usage" over time. Anomaly detection highlights projects dropping in adoption score.
Summary of Tech Stack
- Frontend: React/Next.js, Tailwind CSS, Chart.js/Recharts.
- Backend: Node.js (NestJS) or Go.
- Database: PostgreSQL (RDS) + Redis.
- Analytics: InfluxDB or ClickHouse.
- Deployment: Docker + Kubernetes (EKS/GKE).