# cunlim/embed architecture

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

- Interactive diagram: https://gitdiagram.com/cunlim/embed
- Repository: https://github.com/cunlim/embed

## Overview

CL Embed recommends multilingual product categories by embedding input text and ranking category vectors with cosine similarity. Users also manage category hierarchies and run a five-stage translation/embedding workflow; API clients can search with keys, rate limits, and quotas. The graph preserves authentication, administration, and usage-dashboard capabilities documented in the README. Some backend stages and UI/API wiring are unsampled, so only documented or indexed relationships are shown; uncertain links are omitted.

Main entry points: [`laravel/app/Http/Controllers/Api/CategoryController.php`](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/CategoryController.php) (Category API), [`laravel/app/Http/Controllers/Api/AuthController.php`](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/AuthController.php) (Authentication), [`laravel/app/Models/Category.php`](https://github.com/cunlim/embed/blob/main/laravel/app/Models/Category.php) (Categories and vectors), [`laravel/app/Http/Controllers/Api/ApiController.php`](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/ApiController.php) (External search API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_embed_ui["Recommendation UI"]
  node_category_ui["Category management<br/>[useCategories.ts]"]
  node_admin_ui["Admin panel"]
  node_mypage_ui["Usage dashboard<br/>[page-content.tsx]"]
  node_login_ui["Login UI<br/>[auth-buttons.tsx]"]
end

subgraph group_api["API and domain"]
  node_category_api["Category API"]
  node_auth_api["Authentication<br/>[AuthController.php]"]
  node_api_search["External search API<br/>[ApiController.php]"]
  node_api_security["API key controls<br/>[ApiKeyAuth.php]"]
  node_api_usage["API usage and quotas"]
  node_category_query["Category filtering"]
  node_hierarchy["Hierarchy and folders"]
end

subgraph group_ai["AI processing"]
  node_processing["Translation and embeddings"]
  node_recommendation["Similarity ranking"]
  node_embedding_cache["Query embedding cache"]
  node_settings["Provider settings"]
end

subgraph group_state["Data and integrations"]
  node_category_store[("Categories and vectors<br/>[Category.php]")]
  node_search_store[("Search history<br/>[SearchLog.php]")]
  node_ai_provider{{"AI providers"}}
  node_oauth_provider{{"OAuth providers"}}
end

node_user(("User"))
node_api_client(("API client"))

node_user -->|"enters text"| node_embed_ui
node_embed_ui -->|"requests API"| node_category_api
node_category_api -->|"builds listing"| node_category_query
node_category_api -->|"ranks matches"| node_recommendation
node_category_api -->|"runs steps"| node_processing
node_category_api -->|"reads categories"| node_category_store
node_category_api -->|"manages hierarchy"| node_hierarchy
node_category_api -->|"uses cached vectors"| node_embedding_cache
node_recommendation -.->|"searches vectors"| node_category_store
node_user -->|"manages categories"| node_category_ui
node_category_ui -.->|"requests API"| node_category_api
node_user -->|"signs in"| node_login_ui
node_login_ui -.->|"authenticates"| node_auth_api
node_auth_api -->|"reads quota settings"| node_settings
node_auth_api -.->|"supports OAuth"| node_oauth_provider
node_auth_api -->|"creates user"| node_category_store
node_api_client -->|"submits search"| node_api_search
node_api_search -.->|"checks API key"| node_api_security
node_api_search -.->|"records usage"| node_api_usage
node_user -->|"administers system"| node_admin_ui
node_admin_ui -.->|"changes providers"| node_settings
node_user -->|"checks usage"| node_mypage_ui
node_embedding_cache -->|"reads and writes"| node_search_store
node_embedding_cache -.->|"generates vector"| node_ai_provider
node_processing -.->|"translates and embeds"| node_ai_provider
node_settings -->|"selects provider"| node_ai_provider
node_category_query -->|"queries categories"| node_category_store

click node_embed_ui "https://github.com/cunlim/embed/blob/main/nextjs/app/embed/embed-page-inner.tsx"
click node_category_ui "https://github.com/cunlim/embed/blob/main/nextjs/hooks/useCategories.ts"
click node_admin_ui "https://github.com/cunlim/embed/blob/main/nextjs/app/admin/admin-layout-client.tsx"
click node_mypage_ui "https://github.com/cunlim/embed/blob/main/nextjs/app/mypage/page-content.tsx"
click node_login_ui "https://github.com/cunlim/embed/blob/main/nextjs/components/auth-buttons.tsx"
click node_category_api "https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/CategoryController.php"
click node_auth_api "https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/AuthController.php"
click node_api_search "https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/ApiController.php"
click node_api_security "https://github.com/cunlim/embed/blob/main/laravel/app/Http/Middleware/ApiKeyAuth.php"
click node_api_usage "https://github.com/cunlim/embed/blob/main/laravel/app/Services/ApiUsageService.php"
click node_category_query "https://github.com/cunlim/embed/blob/main/laravel/app/Services/CategoryQueryService.php"
click node_hierarchy "https://github.com/cunlim/embed/blob/main/laravel/app/Services/CategoryHierarchyService.php"
click node_processing "https://github.com/cunlim/embed/blob/main/laravel/app/Services/CategoryProcessingService.php"
click node_recommendation "https://github.com/cunlim/embed/blob/main/laravel/app/Services/RecommendationService.php"
click node_embedding_cache "https://github.com/cunlim/embed/blob/main/laravel/app/Services/EmbeddingCacheService.php"
click node_settings "https://github.com/cunlim/embed/blob/main/laravel/app/Services/SettingsService.php"
click node_category_store "https://github.com/cunlim/embed/blob/main/laravel/app/Models/Category.php"
click node_search_store "https://github.com/cunlim/embed/blob/main/laravel/app/Models/SearchLog.php"
click node_ai_provider "https://github.com/cunlim/embed/tree/main/laravel/app/Services/Providers"

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_embed_ui,node_category_ui,node_admin_ui,node_mypage_ui,node_login_ui,node_user,node_api_client toneBlue
class node_category_api,node_auth_api,node_api_search,node_api_security,node_api_usage,node_category_query,node_hierarchy toneAmber
class node_processing,node_recommendation,node_embedding_cache,node_settings toneMint
class node_category_store,node_search_store,node_ai_provider,node_oauth_provider toneRose
```

## Components

### User experience

- [Recommendation UI](https://github.com/cunlim/embed/blob/main/nextjs/app/embed/embed-page-inner.tsx): `nextjs/app/embed/embed-page-inner.tsx`
- [Category management](https://github.com/cunlim/embed/blob/main/nextjs/hooks/useCategories.ts): `nextjs/hooks/useCategories.ts`
- [Admin panel](https://github.com/cunlim/embed/blob/main/nextjs/app/admin/admin-layout-client.tsx): `nextjs/app/admin/admin-layout-client.tsx`
- [Usage dashboard](https://github.com/cunlim/embed/blob/main/nextjs/app/mypage/page-content.tsx): `nextjs/app/mypage/page-content.tsx`
- [Login UI](https://github.com/cunlim/embed/blob/main/nextjs/components/auth-buttons.tsx): `nextjs/components/auth-buttons.tsx`

### API and domain

- [Category API](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/CategoryController.php): `laravel/app/Http/Controllers/Api/CategoryController.php`
- [Authentication](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/AuthController.php): `laravel/app/Http/Controllers/Api/AuthController.php`
- [External search API](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Controllers/Api/ApiController.php): `laravel/app/Http/Controllers/Api/ApiController.php`
- [API key controls](https://github.com/cunlim/embed/blob/main/laravel/app/Http/Middleware/ApiKeyAuth.php): `laravel/app/Http/Middleware/ApiKeyAuth.php`
- [API usage and quotas](https://github.com/cunlim/embed/blob/main/laravel/app/Services/ApiUsageService.php): `laravel/app/Services/ApiUsageService.php`
- [Category filtering](https://github.com/cunlim/embed/blob/main/laravel/app/Services/CategoryQueryService.php): `laravel/app/Services/CategoryQueryService.php`
- [Hierarchy and folders](https://github.com/cunlim/embed/blob/main/laravel/app/Services/CategoryHierarchyService.php): `laravel/app/Services/CategoryHierarchyService.php`

### AI processing

- [Translation and embeddings](https://github.com/cunlim/embed/blob/main/laravel/app/Services/CategoryProcessingService.php): `laravel/app/Services/CategoryProcessingService.php`
- [Similarity ranking](https://github.com/cunlim/embed/blob/main/laravel/app/Services/RecommendationService.php): `laravel/app/Services/RecommendationService.php`
- [Query embedding cache](https://github.com/cunlim/embed/blob/main/laravel/app/Services/EmbeddingCacheService.php): `laravel/app/Services/EmbeddingCacheService.php`
- [Provider settings](https://github.com/cunlim/embed/blob/main/laravel/app/Services/SettingsService.php): `laravel/app/Services/SettingsService.php`

### Data and integrations

- [Categories and vectors](https://github.com/cunlim/embed/blob/main/laravel/app/Models/Category.php): `laravel/app/Models/Category.php`
- [Search history](https://github.com/cunlim/embed/blob/main/laravel/app/Models/SearchLog.php): `laravel/app/Models/SearchLog.php`
- [AI providers](https://github.com/cunlim/embed/tree/main/laravel/app/Services/Providers): `laravel/app/Services/Providers`
- **OAuth providers**

### Other components

- **User**
- **API client**

## Connections

- User → Recommendation UI: enters text (evidence: `README.md`)
- Recommendation UI → Category API: requests API (evidence: `README.md`)
- Category API → Category filtering: builds listing (evidence: `laravel/app/Http/Controllers/Api/CategoryController.php`)
- Category API → Similarity ranking: ranks matches (evidence: `laravel/app/Http/Controllers/Api/CategoryController.php`)
- Category API → Translation and embeddings: runs steps (evidence: `laravel/app/Http/Controllers/Api/CategoryController.php`)
- Category API → Categories and vectors: reads categories (evidence: `laravel/app/Http/Controllers/Api/CategoryController.php`)
- Category API → Hierarchy and folders: manages hierarchy (evidence: `laravel/app/Http/Controllers/Api/CategoryController.php`)
- Category API → Query embedding cache: uses cached vectors (evidence: `laravel/app/Http/Controllers/Api/CategoryController.php`)
- Similarity ranking → Categories and vectors: searches vectors (evidence: `README.md`)
- User → Category management: manages categories (evidence: `README.md`)
- Category management → Category API: requests API
- User → Login UI: signs in (evidence: `README.md`)
- Login UI → Authentication: authenticates
- Authentication → Provider settings: reads quota settings (evidence: `laravel/app/Http/Controllers/Api/AuthController.php`)
- Authentication → OAuth providers: supports OAuth (evidence: `README.md`)
- Authentication → Categories and vectors: creates user (evidence: `laravel/app/Http/Controllers/Api/AuthController.php`)
- API client → External search API: submits search (evidence: `README.md`)
- External search API → API key controls: checks API key
- External search API → API usage and quotas: records usage
- User → Admin panel: administers system (evidence: `README.md`)
- Admin panel → Provider settings: changes providers (evidence: `README.md`)
- User → Usage dashboard: checks usage (evidence: `README.md`)
- Query embedding cache → Search history: reads and writes (evidence: `laravel/app/Services/EmbeddingCacheService.php`)
- Query embedding cache → AI providers: generates vector
- Translation and embeddings → AI providers: translates and embeds (evidence: `README.md`)
- Provider settings → AI providers: selects provider
- Category filtering → Categories and vectors: queries categories (evidence: `laravel/app/Services/CategoryQueryService.php`)
