# munnahosain/mcu architecture

> Architecture diagram of the GitHub repository munnahosain/mcu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/munnahosain/mcu
- Repository: https://github.com/munnahosain/mcu

## Overview

This repository is a creative-production SaaS with user accounts, AI-assisted image and metadata workflows, subscription credits, and administrative/support capabilities. A central workflow is a signed-in user submitting an image for AI metadata generation: the API checks identity and feature access, prepares the image, reserves credits, calls a vision provider, and can refund credits after failure. The tree also shows distinct design tools and account-management areas. Several UI-to-API and unsampled subsystem connections are not evidenced in the excerpts, so those links are omitted.

Main entry points: [`src/app/api/generate/route.ts`](https://github.com/munnahosain/mcu/blob/main/src/app/api/generate/route.ts) (AI generation API), [`src/server/services/feature-flag-service.ts`](https://github.com/munnahosain/mcu/blob/main/src/server/services/feature-flag-service.ts) (Feature access), [`src/server/services/credit-service.ts`](https://github.com/munnahosain/mcu/blob/main/src/server/services/credit-service.ts) (Credit accounting), [`src/server/db/mongodb.ts`](https://github.com/munnahosain/mcu/blob/main/src/server/db/mongodb.ts) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_creation["Creative tools"]
  node_dashboard["Creator dashboard"]
  node_iconstudio["3D icon studio<br/>[IconStudio.tsx]"]
  node_svgstudio["SVG motion studio"]
  node_gridtool["Grid generator<br/>[engine.ts]"]
  node_typeboxtool["Typebox studio<br/>[engine.ts]"]
  node_splitter["Vector sheet splitter<br/>[epsParser.ts]"]
end

subgraph group_api["Application workflows"]
  node_generate["AI generation API<br/>[route.ts]"]
  node_billing["Billing and plans API<br/>[route.ts]"]
  node_payments["Payments API<br/>[route.ts]"]
  node_supportapi["Support API<br/>[route.ts]"]
end

subgraph group_services["Platform services"]
  node_auth["Request authentication<br/>[request-auth.ts]"]
  node_ratelimit["Rate limiting<br/>[rate-limit.ts]"]
  node_flags["Feature access"]
  node_vision["Vision providers<br/>[vision-service.ts]"]
  node_credits["Credit accounting<br/>[credit-service.ts]"]
  node_vectorpreview["Vector preview<br/>[vector-preview.ts]"]
  node_paymentservice["Payment service<br/>[payment-service.ts]"]
  node_supportservice["Support service<br/>[support-service.ts]"]
end

subgraph group_persistence["Persistence"]
  node_database[("Database access<br/>[mongodb.ts]")]
  node_users[("User records<br/>[User.ts]")]
  node_plans[("Plan records<br/>[Plan.ts]")]
  node_subscriptions[("Subscription records<br/>[Subscription.ts]")]
  node_ledger[("Credit ledger<br/>[CreditLedger.ts]")]
  node_providerkeys[("Provider keys<br/>[ProviderKey.ts]")]
end

node_user(("User"))
node_ai_provider["AI provider"]

node_generate -->|"authenticates"| node_auth
node_generate -->|"limits requests"| node_ratelimit
node_generate -->|"checks access"| node_flags
node_generate -->|"prepares vectors"| node_vectorpreview
node_generate -->|"prepares and calls"| node_vision
node_generate -->|"reserves and refunds"| node_credits
node_vision -->|"loads provider keys"| node_database
node_vision -->|"reads keys"| node_providerkeys
node_generate -.->|"requests generation"| node_ai_provider
node_credits -->|"connects to"| node_database
node_credits -->|"updates balances"| node_users
node_credits -->|"records transactions"| node_ledger
node_flags -->|"connects to"| node_database
node_flags -->|"checks plan"| node_users
node_flags -->|"looks up plans"| node_plans
node_flags -->|"checks subscription"| node_subscriptions
node_billing -->|"authorizes account"| node_auth
node_payments -->|"uses payment logic"| node_paymentservice
node_paymentservice -->|"connects to"| node_database
node_supportapi -.->|"dispatches support"| node_supportservice
node_user -.->|"uses"| node_dashboard

click node_dashboard "https://github.com/munnahosain/mcu/tree/main/src/app/dashboard"
click node_iconstudio "https://github.com/munnahosain/mcu/blob/main/src/components/IconStudio/IconStudio.tsx"
click node_svgstudio "https://github.com/munnahosain/mcu/blob/main/src/components/SvgMotionStudio/SvgMotionStudio.tsx"
click node_gridtool "https://github.com/munnahosain/mcu/blob/main/src/lib/grid/engine.ts"
click node_typeboxtool "https://github.com/munnahosain/mcu/blob/main/src/lib/typebox/engine.ts"
click node_splitter "https://github.com/munnahosain/mcu/blob/main/src/services/epsParser.ts"
click node_generate "https://github.com/munnahosain/mcu/blob/main/src/app/api/generate/route.ts"
click node_billing "https://github.com/munnahosain/mcu/blob/main/src/app/api/account/billing/route.ts"
click node_payments "https://github.com/munnahosain/mcu/blob/main/src/app/api/payments/route.ts"
click node_supportapi "https://github.com/munnahosain/mcu/blob/main/src/app/api/support/tickets/route.ts"
click node_auth "https://github.com/munnahosain/mcu/blob/main/src/server/auth/request-auth.ts"
click node_ratelimit "https://github.com/munnahosain/mcu/blob/main/src/server/auth/rate-limit.ts"
click node_flags "https://github.com/munnahosain/mcu/blob/main/src/server/services/feature-flag-service.ts"
click node_vision "https://github.com/munnahosain/mcu/blob/main/src/server/services/vision-service.ts"
click node_credits "https://github.com/munnahosain/mcu/blob/main/src/server/services/credit-service.ts"
click node_vectorpreview "https://github.com/munnahosain/mcu/blob/main/src/server/services/vector-preview.ts"
click node_paymentservice "https://github.com/munnahosain/mcu/blob/main/src/server/services/payment-service.ts"
click node_supportservice "https://github.com/munnahosain/mcu/blob/main/src/server/services/support-service.ts"
click node_database "https://github.com/munnahosain/mcu/blob/main/src/server/db/mongodb.ts"
click node_users "https://github.com/munnahosain/mcu/blob/main/src/server/models/User.ts"
click node_plans "https://github.com/munnahosain/mcu/blob/main/src/server/models/Plan.ts"
click node_subscriptions "https://github.com/munnahosain/mcu/blob/main/src/server/models/Subscription.ts"
click node_ledger "https://github.com/munnahosain/mcu/blob/main/src/server/models/CreditLedger.ts"
click node_providerkeys "https://github.com/munnahosain/mcu/blob/main/src/server/models/ProviderKey.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_iconstudio,node_svgstudio,node_gridtool,node_typeboxtool,node_splitter,node_user toneBlue
class node_generate,node_billing,node_payments,node_supportapi toneAmber
class node_auth,node_ratelimit,node_flags,node_vision,node_credits,node_vectorpreview,node_paymentservice,node_supportservice toneMint
class node_database,node_users,node_plans,node_subscriptions,node_ledger,node_providerkeys toneRose
class node_ai_provider toneIndigo
```

## Components

### Creative tools

- [Creator dashboard](https://github.com/munnahosain/mcu/tree/main/src/app/dashboard): `src/app/dashboard`
- [3D icon studio](https://github.com/munnahosain/mcu/blob/main/src/components/IconStudio/IconStudio.tsx): `src/components/IconStudio/IconStudio.tsx`
- [SVG motion studio](https://github.com/munnahosain/mcu/blob/main/src/components/SvgMotionStudio/SvgMotionStudio.tsx): `src/components/SvgMotionStudio/SvgMotionStudio.tsx`
- [Grid generator](https://github.com/munnahosain/mcu/blob/main/src/lib/grid/engine.ts): `src/lib/grid/engine.ts`
- [Typebox studio](https://github.com/munnahosain/mcu/blob/main/src/lib/typebox/engine.ts): `src/lib/typebox/engine.ts`
- [Vector sheet splitter](https://github.com/munnahosain/mcu/blob/main/src/services/epsParser.ts): `src/services/epsParser.ts`

### Application workflows

- [AI generation API](https://github.com/munnahosain/mcu/blob/main/src/app/api/generate/route.ts): `src/app/api/generate/route.ts`
- [Billing and plans API](https://github.com/munnahosain/mcu/blob/main/src/app/api/account/billing/route.ts): `src/app/api/account/billing/route.ts`
- [Payments API](https://github.com/munnahosain/mcu/blob/main/src/app/api/payments/route.ts): `src/app/api/payments/route.ts`
- [Support API](https://github.com/munnahosain/mcu/blob/main/src/app/api/support/tickets/route.ts): `src/app/api/support/tickets/route.ts`

### Platform services

- [Request authentication](https://github.com/munnahosain/mcu/blob/main/src/server/auth/request-auth.ts): `src/server/auth/request-auth.ts`
- [Rate limiting](https://github.com/munnahosain/mcu/blob/main/src/server/auth/rate-limit.ts): `src/server/auth/rate-limit.ts`
- [Feature access](https://github.com/munnahosain/mcu/blob/main/src/server/services/feature-flag-service.ts): `src/server/services/feature-flag-service.ts`
- [Vision providers](https://github.com/munnahosain/mcu/blob/main/src/server/services/vision-service.ts): `src/server/services/vision-service.ts`
- [Credit accounting](https://github.com/munnahosain/mcu/blob/main/src/server/services/credit-service.ts): `src/server/services/credit-service.ts`
- [Vector preview](https://github.com/munnahosain/mcu/blob/main/src/server/services/vector-preview.ts): `src/server/services/vector-preview.ts`
- [Payment service](https://github.com/munnahosain/mcu/blob/main/src/server/services/payment-service.ts): `src/server/services/payment-service.ts`
- [Support service](https://github.com/munnahosain/mcu/blob/main/src/server/services/support-service.ts): `src/server/services/support-service.ts`

### Persistence

- [Database access](https://github.com/munnahosain/mcu/blob/main/src/server/db/mongodb.ts): `src/server/db/mongodb.ts`
- [User records](https://github.com/munnahosain/mcu/blob/main/src/server/models/User.ts): `src/server/models/User.ts`
- [Plan records](https://github.com/munnahosain/mcu/blob/main/src/server/models/Plan.ts): `src/server/models/Plan.ts`
- [Subscription records](https://github.com/munnahosain/mcu/blob/main/src/server/models/Subscription.ts): `src/server/models/Subscription.ts`
- [Credit ledger](https://github.com/munnahosain/mcu/blob/main/src/server/models/CreditLedger.ts): `src/server/models/CreditLedger.ts`
- [Provider keys](https://github.com/munnahosain/mcu/blob/main/src/server/models/ProviderKey.ts): `src/server/models/ProviderKey.ts`

### Other components

- **User**
- **AI provider**

## Connections

- AI generation API → Request authentication: authenticates (evidence: `src/app/api/generate/route.ts`)
- AI generation API → Rate limiting: limits requests (evidence: `src/app/api/generate/route.ts`)
- AI generation API → Feature access: checks access (evidence: `src/app/api/generate/route.ts`)
- AI generation API → Vector preview: prepares vectors (evidence: `src/app/api/generate/route.ts`)
- AI generation API → Vision providers: prepares and calls (evidence: `src/app/api/generate/route.ts`)
- AI generation API → Credit accounting: reserves and refunds (evidence: `src/app/api/generate/route.ts`)
- Vision providers → Database access: loads provider keys (evidence: `src/server/services/vision-service.ts`)
- Vision providers → Provider keys: reads keys (evidence: `src/server/services/vision-service.ts`)
- AI generation API → AI provider: requests generation
- Credit accounting → Database access: connects to (evidence: `src/server/services/credit-service.ts`)
- Credit accounting → User records: updates balances (evidence: `src/server/services/credit-service.ts`)
- Credit accounting → Credit ledger: records transactions (evidence: `src/server/services/credit-service.ts`)
- Feature access → Database access: connects to (evidence: `src/server/services/feature-flag-service.ts`)
- Feature access → User records: checks plan (evidence: `src/server/services/feature-flag-service.ts`)
- Feature access → Plan records: looks up plans (evidence: `src/server/services/feature-flag-service.ts`)
- Feature access → Subscription records: checks subscription (evidence: `src/server/services/feature-flag-service.ts`)
- Billing and plans API → Request authentication: authorizes account (evidence: `src/app/api/account/billing/route.ts`)
- Payments API → Payment service: uses payment logic (evidence: `src/app/api/payments/route.ts`)
- Payment service → Database access: connects to (evidence: `src/server/services/payment-service.ts`)
- Support API → Support service: dispatches support
- User → Creator dashboard: uses
