# deniweb/crm_nextjs architecture

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

- Interactive diagram: https://gitdiagram.com/deniweb/crm_nextjs
- Repository: https://github.com/deniweb/crm_nextjs

## Overview

This is a Next.js CRM for managing companies and their promotions, with an admin dashboard for sales, counts, and summary statistics. The main workflow is to browse companies, open a company record, and view its promotions or use the form routes to add records; dashboard routes fetch and present aggregate views. The API module connects these screens to MockAPI, while server-side query prefetching supports the company list and detail views. The README marks several management features as in development. Connections below rely on the README and SOURCE INDEX references; unsampled routes and components are not assumed to have unshown behavior.

Main entry points: [`src/lib/api.ts`](https://github.com/deniweb/crm_nextjs/blob/main/src/lib/api.ts) (CRM API client), [`src/app/components/company-form.tsx`](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-form.tsx) (Company form), [`src/app/components/promotion-form.tsx`](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/promotion-form.tsx) (Promotion form), [`src/app/(admin)/dashboard/@sales/page.tsx`](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40sales/page.tsx) (Sales summary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Admin navigation"]
  node_admin_shell["Admin shell<br/>[layout.tsx]"]
  node_dashboard_home["Dashboard page<br/>[page.tsx]"]
end

subgraph group_companies["Company management"]
  node_company_list["Company list route<br/>[page.tsx]"]
  node_company_table["Company table<br/>[company-table.tsx]"]
  node_company_detail["Company detail route<br/>[page.tsx]"]
  node_company_info["Company information<br/>[company-info.tsx]"]
  node_company_promotions["Company promotions"]
  node_company_form["Company form<br/>[company-form.tsx]"]
  node_promotion_form["Promotion form<br/>[promotion-form.tsx]"]
end

subgraph group_analytics["Dashboard analytics"]
  node_dashboard_sales["Sales summary<br/>[page.tsx]"]
  node_dashboard_promotions["Promotion summary<br/>[page.tsx]"]
  node_dashboard_countries["Country breakdown<br/>[page.tsx]"]
  node_dashboard_categories["Category breakdown<br/>[page.tsx]"]
  node_dashboard_stats["Summary statistics<br/>[page.tsx]"]
  node_dashboard_new_companies["New companies view<br/>[page.tsx]"]
end

subgraph group_shared["Shared UI and data"]
  node_sidebar["Sidebar navigation<br/>[sidebar.tsx]"]
  node_api["CRM API client<br/>[api.ts]"]
  node_query_cache["Query prefetch cache<br/>[getQueryClient.ts]"]
  node_count_helper["Count aggregation<br/>[getCountById.ts]"]
  node_header["Page header<br/>[header.tsx]"]
  node_toolbar["Toolbar and search<br/>[toolbar.tsx]"]
  node_search_input["Search input<br/>[search-input.tsx]"]
  node_buttons["Action buttons<br/>[button.tsx]"]
  node_form_controls["Form controls<br/>[input-field.tsx]"]
  node_logo_uploader["Logo uploader<br/>[logo-uploader.tsx]"]
  node_status_label["Status label<br/>[status-label.tsx]"]
  node_dashboard_card["Dashboard card<br/>[dashboard-card.tsx]"]
  node_stat_card["Stat card<br/>[stat-card.tsx]"]
  node_summary_table["Summary table<br/>[summary-table.tsx]"]
  node_summary_header["Summary table header"]
  node_summary_cell["Summary table cell"]
end

node_admin_user(("Admin user"))
node_mockapi[("MockAPI service")]

node_admin_user -.->|"opens admin"| node_admin_shell
node_admin_shell -->|"renders"| node_sidebar
node_admin_user -.->|"browses companies"| node_company_list
node_company_list -->|"renders"| node_company_table
node_company_list -->|"prefetches companies"| node_api
node_company_list -->|"gets query client"| node_query_cache
node_company_table -->|"loads company data"| node_api
node_admin_user -.->|"opens company"| node_company_detail
node_company_detail -->|"renders"| node_company_info
node_company_detail -->|"renders"| node_company_promotions
node_company_detail -->|"prefetches record and promotions"| node_api
node_company_detail -->|"gets query client"| node_query_cache
node_company_info -->|"loads company"| node_api
node_company_promotions -->|"loads promotions"| node_api
node_company_promotions -.->|"displays promotions"| node_promotion_form
node_admin_user -.->|"adds company"| node_company_form
node_company_form -->|"creates company"| node_api
node_company_form -->|"uses"| node_buttons
node_company_form -->|"uses"| node_form_controls
node_company_form -->|"uses"| node_logo_uploader
node_company_form -->|"uses"| node_status_label
node_admin_user -.->|"adds promotion"| node_promotion_form
node_promotion_form -->|"creates promotion"| node_api
node_promotion_form -->|"uses"| node_buttons
node_promotion_form -->|"uses"| node_form_controls
node_promotion_form -->|"uses"| node_logo_uploader
node_api -->|"sends HTTP requests"| node_mockapi
node_dashboard_home -->|"renders"| node_header
node_admin_user -.->|"views dashboard"| node_dashboard_home
node_dashboard_sales -->|"fetches sales"| node_api
node_dashboard_sales -->|"renders"| node_dashboard_card
node_dashboard_sales -->|"renders"| node_summary_table
node_dashboard_sales -->|"renders"| node_summary_header
node_dashboard_sales -->|"renders"| node_summary_cell
node_dashboard_promotions -->|"fetches promotions"| node_api
node_dashboard_promotions -->|"renders"| node_dashboard_card
node_dashboard_promotions -->|"renders"| node_summary_table
node_dashboard_promotions -->|"renders"| node_summary_header
node_dashboard_promotions -->|"renders"| node_summary_cell
node_dashboard_countries -->|"fetches country and company data"| node_api
node_dashboard_countries -->|"counts by country"| node_count_helper
node_dashboard_countries -->|"renders"| node_dashboard_card
node_dashboard_categories -->|"fetches category and company data"| node_api
node_dashboard_categories -->|"counts by category"| node_count_helper
node_dashboard_categories -->|"renders"| node_dashboard_card
node_dashboard_categories -->|"renders"| node_stat_card
node_dashboard_stats -.->|"fetches summary stats"| node_api
node_dashboard_new_companies -.->|"loads new companies"| node_api

click node_admin_shell "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/layout.tsx"
click node_sidebar "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/sidebar.tsx"
click node_dashboard_home "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/page.tsx"
click node_company_list "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/companies/page.tsx"
click node_company_table "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-table.tsx"
click node_company_detail "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/companies/%5Bid%5D/page.tsx"
click node_company_info "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-info.tsx"
click node_company_promotions "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-promotions.tsx"
click node_company_form "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-form.tsx"
click node_promotion_form "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/promotion-form.tsx"
click node_dashboard_sales "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40sales/page.tsx"
click node_dashboard_promotions "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40promotions/page.tsx"
click node_dashboard_countries "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40countries/page.tsx"
click node_dashboard_categories "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40categories/page.tsx"
click node_dashboard_stats "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40stats/page.tsx"
click node_dashboard_new_companies "https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/newCompanies/page.tsx"
click node_api "https://github.com/deniweb/crm_nextjs/blob/main/src/lib/api.ts"
click node_query_cache "https://github.com/deniweb/crm_nextjs/blob/main/src/lib/utils/getQueryClient.ts"
click node_count_helper "https://github.com/deniweb/crm_nextjs/blob/main/src/lib/utils/getCountById.ts"
click node_header "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/header.tsx"
click node_toolbar "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/toolbar.tsx"
click node_search_input "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/search-input.tsx"
click node_buttons "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/button.tsx"
click node_form_controls "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/input-field.tsx"
click node_logo_uploader "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/logo-uploader.tsx"
click node_status_label "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/status-label.tsx"
click node_dashboard_card "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/dashboard-card.tsx"
click node_stat_card "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/stat-card/stat-card.tsx"
click node_summary_table "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/summary-table.tsx"
click node_summary_header "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/summary-table-header.tsx"
click node_summary_cell "https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/summary-table-cell.tsx"

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_admin_shell,node_dashboard_home,node_admin_user toneBlue
class node_company_list,node_company_table,node_company_detail,node_company_info,node_company_promotions,node_company_form,node_promotion_form,node_mockapi toneAmber
class node_dashboard_sales,node_dashboard_promotions,node_dashboard_countries,node_dashboard_categories,node_dashboard_stats,node_dashboard_new_companies toneMint
class node_sidebar,node_api,node_query_cache,node_count_helper,node_header,node_toolbar,node_search_input,node_buttons,node_form_controls,node_logo_uploader,node_status_label,node_dashboard_card,node_stat_card,node_summary_table,node_summary_header,node_summary_cell toneRose
```

## Components

### Admin navigation

- [Admin shell](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/layout.tsx): `src/app/(admin)/layout.tsx`
- [Dashboard page](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/page.tsx): `src/app/(admin)/dashboard/page.tsx`

### Company management

- [Company list route](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/companies/page.tsx): `src/app/(admin)/companies/page.tsx`
- [Company table](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-table.tsx): `src/app/components/company-table.tsx`
- [Company detail route](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/companies/%5Bid%5D/page.tsx): `src/app/(admin)/companies/[id]/page.tsx`
- [Company information](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-info.tsx): `src/app/components/company-info.tsx`
- [Company promotions](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-promotions.tsx): `src/app/components/company-promotions.tsx`
- [Company form](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/company-form.tsx): `src/app/components/company-form.tsx`
- [Promotion form](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/promotion-form.tsx): `src/app/components/promotion-form.tsx`

### Dashboard analytics

- [Sales summary](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40sales/page.tsx): `src/app/(admin)/dashboard/@sales/page.tsx`
- [Promotion summary](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40promotions/page.tsx): `src/app/(admin)/dashboard/@promotions/page.tsx`
- [Country breakdown](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40countries/page.tsx): `src/app/(admin)/dashboard/@countries/page.tsx`
- [Category breakdown](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40categories/page.tsx): `src/app/(admin)/dashboard/@categories/page.tsx`
- [Summary statistics](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/%40stats/page.tsx): `src/app/(admin)/dashboard/@stats/page.tsx`
- [New companies view](https://github.com/deniweb/crm_nextjs/blob/main/src/app/(admin)/dashboard/newCompanies/page.tsx): `src/app/(admin)/dashboard/newCompanies/page.tsx`

### Shared UI and data

- [Sidebar navigation](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/sidebar.tsx): `src/app/components/sidebar.tsx`
- [CRM API client](https://github.com/deniweb/crm_nextjs/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Query prefetch cache](https://github.com/deniweb/crm_nextjs/blob/main/src/lib/utils/getQueryClient.ts): `src/lib/utils/getQueryClient.ts`
- [Count aggregation](https://github.com/deniweb/crm_nextjs/blob/main/src/lib/utils/getCountById.ts): `src/lib/utils/getCountById.ts`
- [Page header](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/header.tsx): `src/app/components/header.tsx`
- [Toolbar and search](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/toolbar.tsx): `src/app/components/toolbar.tsx`
- [Search input](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/search-input.tsx): `src/app/components/search-input.tsx`
- [Action buttons](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/button.tsx): `src/app/components/button.tsx`
- [Form controls](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/input-field.tsx): `src/app/components/input-field.tsx`
- [Logo uploader](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/logo-uploader.tsx): `src/app/components/logo-uploader.tsx`
- [Status label](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/status-label.tsx): `src/app/components/status-label.tsx`
- [Dashboard card](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/dashboard-card.tsx): `src/app/components/dashboard-card.tsx`
- [Stat card](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/stat-card/stat-card.tsx): `src/app/components/stat-card/stat-card.tsx`
- [Summary table](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/summary-table.tsx): `src/app/components/summary-table.tsx`
- [Summary table header](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/summary-table-header.tsx): `src/app/components/summary-table-header.tsx`
- [Summary table cell](https://github.com/deniweb/crm_nextjs/blob/main/src/app/components/summary-table-cell.tsx): `src/app/components/summary-table-cell.tsx`

### Other components

- **Admin user**
- **MockAPI service**

## Connections

- Admin user → Admin shell: opens admin
- Admin shell → Sidebar navigation: renders (evidence: `src/app/(admin)/layout.tsx`)
- Admin user → Company list route: browses companies
- Company list route → Company table: renders (evidence: `src/app/(admin)/companies/page.tsx`)
- Company list route → CRM API client: prefetches companies (evidence: `src/app/(admin)/companies/page.tsx`)
- Company list route → Query prefetch cache: gets query client (evidence: `src/app/(admin)/companies/page.tsx`)
- Company table → CRM API client: loads company data (evidence: `src/app/components/company-table.tsx`)
- Admin user → Company detail route: opens company
- Company detail route → Company information: renders (evidence: `src/app/(admin)/companies/[id]/page.tsx`)
- Company detail route → Company promotions: renders (evidence: `src/app/(admin)/companies/[id]/page.tsx`)
- Company detail route → CRM API client: prefetches record and promotions (evidence: `src/app/(admin)/companies/[id]/page.tsx`)
- Company detail route → Query prefetch cache: gets query client (evidence: `src/app/(admin)/companies/[id]/page.tsx`)
- Company information → CRM API client: loads company (evidence: `src/app/components/company-info.tsx`)
- Company promotions → CRM API client: loads promotions (evidence: `src/app/components/company-promotions.tsx`)
- Company promotions → Promotion form: displays promotions
- Admin user → Company form: adds company
- Company form → CRM API client: creates company (evidence: `src/app/components/company-form.tsx`)
- Company form → Action buttons: uses (evidence: `src/app/components/company-form.tsx`)
- Company form → Form controls: uses (evidence: `src/app/components/company-form.tsx`)
- Company form → Logo uploader: uses (evidence: `src/app/components/company-form.tsx`)
- Company form → Status label: uses (evidence: `src/app/components/company-form.tsx`)
- Admin user → Promotion form: adds promotion
- Promotion form → CRM API client: creates promotion (evidence: `src/app/components/promotion-form.tsx`)
- Promotion form → Action buttons: uses (evidence: `src/app/components/promotion-form.tsx`)
- Promotion form → Form controls: uses (evidence: `src/app/components/promotion-form.tsx`)
- Promotion form → Logo uploader: uses (evidence: `src/app/components/promotion-form.tsx`)
- CRM API client → MockAPI service: sends HTTP requests (evidence: `src/lib/api.ts`)
- Dashboard page → Page header: renders (evidence: `src/app/(admin)/dashboard/page.tsx`)
- Admin user → Dashboard page: views dashboard
- Sales summary → CRM API client: fetches sales (evidence: `src/app/(admin)/dashboard/@sales/page.tsx`)
- Sales summary → Dashboard card: renders (evidence: `src/app/(admin)/dashboard/@sales/page.tsx`)
- Sales summary → Summary table: renders (evidence: `src/app/(admin)/dashboard/@sales/page.tsx`)
- Sales summary → Summary table header: renders (evidence: `src/app/(admin)/dashboard/@sales/page.tsx`)
- Sales summary → Summary table cell: renders (evidence: `src/app/(admin)/dashboard/@sales/page.tsx`)
- Promotion summary → CRM API client: fetches promotions (evidence: `src/app/(admin)/dashboard/@promotions/page.tsx`)
- Promotion summary → Dashboard card: renders (evidence: `src/app/(admin)/dashboard/@promotions/page.tsx`)
- Promotion summary → Summary table: renders (evidence: `src/app/(admin)/dashboard/@promotions/page.tsx`)
- Promotion summary → Summary table header: renders (evidence: `src/app/(admin)/dashboard/@promotions/page.tsx`)
- Promotion summary → Summary table cell: renders (evidence: `src/app/(admin)/dashboard/@promotions/page.tsx`)
- Country breakdown → CRM API client: fetches country and company data (evidence: `src/app/(admin)/dashboard/@countries/page.tsx`)
- Country breakdown → Count aggregation: counts by country (evidence: `src/app/(admin)/dashboard/@countries/page.tsx`)
- Country breakdown → Dashboard card: renders (evidence: `src/app/(admin)/dashboard/@countries/page.tsx`)
- Category breakdown → CRM API client: fetches category and company data (evidence: `src/app/(admin)/dashboard/@categories/page.tsx`)
- Category breakdown → Count aggregation: counts by category (evidence: `src/app/(admin)/dashboard/@categories/page.tsx`)
- Category breakdown → Dashboard card: renders (evidence: `src/app/(admin)/dashboard/@categories/page.tsx`)
- Category breakdown → Stat card: renders (evidence: `src/app/(admin)/dashboard/@categories/page.tsx`)
- Summary statistics → CRM API client: fetches summary stats (evidence: `src/app/(admin)/dashboard/@stats/page.tsx`)
- New companies view → CRM API client: loads new companies
