# fedhako7/lead-management architecture

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

- Interactive diagram: https://gitdiagram.com/fedhako7/lead-management
- Repository: https://github.com/fedhako7/lead-management

## Overview

LeadFlow is a full-stack lead-management application. Users review dashboard metrics and recent leads, browse a searchable, filterable, sortable, paginated lead list, and create leads; the API also supports reading, updating, and deleting leads. The backend routes requests through controllers to a MongoDB model, while the frontend’s API client communicates with the backend. Dashboard and list calls are visible in excerpts; some form-to-API wiring and unsampled integrations are shown only as documented capabilities.

Main entry points: [`frontend/lib/api.ts`](https://github.com/fedhako7/lead-management/blob/main/frontend/lib/api.ts) (API client), [`backend/start.ts`](https://github.com/fedhako7/lead-management/blob/main/backend/start.ts) (Express server), [`frontend/app/page.tsx`](https://github.com/fedhako7/lead-management/blob/main/frontend/app/page.tsx) (Dashboard), [`backend/controllers/leadController.ts`](https://github.com/fedhako7/lead-management/blob/main/backend/controllers/leadController.ts) (Lead operations and analytics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["LeadFlow interface"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_lead_list_page["Lead list page<br/>[page.tsx]"]
  node_lead_list["Lead search and list<br/>[leads-client.tsx]"]
  node_lead_form["Create lead form<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_backend["Lead API"]
  node_server["Express server<br/>[start.ts]"]
  node_lead_routes["Lead routes<br/>[leadRoutes.ts]"]
  node_lead_controller["Lead operations and analytics<br/>[leadController.ts]"]
  node_error_handling["Error handling<br/>[errorHandler.ts]"]
  node_lead_types["Lead API types<br/>[index.ts]"]
end

subgraph group_storage["Lead persistence"]
  node_lead_model["Lead model<br/>[Lead.ts]"]
  node_database_connection["MongoDB connection<br/>[connection.ts]"]
end

node_user(("Sales user"))
node_api_service{{"Lead API"}}
node_mongodb[("MongoDB")]

node_user -->|"views"| node_dashboard
node_user -->|"browses"| node_lead_list_page
node_user -->|"creates"| node_lead_form
node_lead_list_page -->|"renders"| node_lead_list
node_dashboard -->|"requests metrics"| node_api_client
node_dashboard -->|"requests recent leads"| node_api_client
node_lead_list -->|"fetches leads"| node_api_client
node_lead_form -.->|"submits lead"| node_api_client
node_api_client -.->|"sends HTTP requests"| node_api_service
node_api_service -->|"reaches"| node_server
node_server -->|"connects"| node_database_connection
node_server -->|"mounts routes"| node_lead_routes
node_server -->|"registers middleware"| node_error_handling
node_lead_routes -->|"dispatches"| node_lead_controller
node_lead_controller -->|"queries and updates"| node_lead_model
node_lead_controller -->|"uses response types"| node_lead_types
node_database_connection -->|"connects"| node_mongodb
node_lead_model -.->|"reads and writes"| node_mongodb

click node_dashboard "https://github.com/fedhako7/lead-management/blob/main/frontend/app/page.tsx"
click node_lead_list_page "https://github.com/fedhako7/lead-management/blob/main/frontend/app/leads/page.tsx"
click node_lead_list "https://github.com/fedhako7/lead-management/blob/main/frontend/app/leads/leads-client.tsx"
click node_lead_form "https://github.com/fedhako7/lead-management/blob/main/frontend/app/leads/new/page.tsx"
click node_api_client "https://github.com/fedhako7/lead-management/blob/main/frontend/lib/api.ts"
click node_server "https://github.com/fedhako7/lead-management/blob/main/backend/start.ts"
click node_lead_routes "https://github.com/fedhako7/lead-management/blob/main/backend/routes/leadRoutes.ts"
click node_lead_controller "https://github.com/fedhako7/lead-management/blob/main/backend/controllers/leadController.ts"
click node_error_handling "https://github.com/fedhako7/lead-management/blob/main/backend/middleware/errorHandler.ts"
click node_lead_types "https://github.com/fedhako7/lead-management/blob/main/backend/types/index.ts"
click node_lead_model "https://github.com/fedhako7/lead-management/blob/main/backend/models/Lead.ts"
click node_database_connection "https://github.com/fedhako7/lead-management/blob/main/backend/db/connection.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_lead_list_page,node_lead_list,node_lead_form,node_api_client,node_user toneBlue
class node_server,node_lead_routes,node_lead_controller,node_error_handling,node_lead_types,node_mongodb toneAmber
class node_lead_model,node_database_connection,node_api_service toneMint
```

## Components

### LeadFlow interface

- [Dashboard](https://github.com/fedhako7/lead-management/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Lead list page](https://github.com/fedhako7/lead-management/blob/main/frontend/app/leads/page.tsx): `frontend/app/leads/page.tsx`
- [Lead search and list](https://github.com/fedhako7/lead-management/blob/main/frontend/app/leads/leads-client.tsx): `frontend/app/leads/leads-client.tsx`
- [Create lead form](https://github.com/fedhako7/lead-management/blob/main/frontend/app/leads/new/page.tsx): `frontend/app/leads/new/page.tsx`
- [API client](https://github.com/fedhako7/lead-management/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### Lead API

- [Express server](https://github.com/fedhako7/lead-management/blob/main/backend/start.ts): `backend/start.ts`
- [Lead routes](https://github.com/fedhako7/lead-management/blob/main/backend/routes/leadRoutes.ts): `backend/routes/leadRoutes.ts`
- [Lead operations and analytics](https://github.com/fedhako7/lead-management/blob/main/backend/controllers/leadController.ts): `backend/controllers/leadController.ts`
- [Error handling](https://github.com/fedhako7/lead-management/blob/main/backend/middleware/errorHandler.ts): `backend/middleware/errorHandler.ts`
- [Lead API types](https://github.com/fedhako7/lead-management/blob/main/backend/types/index.ts): `backend/types/index.ts`

### Lead persistence

- [Lead model](https://github.com/fedhako7/lead-management/blob/main/backend/models/Lead.ts): `backend/models/Lead.ts`
- [MongoDB connection](https://github.com/fedhako7/lead-management/blob/main/backend/db/connection.ts): `backend/db/connection.ts`

### Other components

- **Sales user**
- **Lead API**
- **MongoDB**

## Connections

- Sales user → Dashboard: views (evidence: `README.md`)
- Sales user → Lead list page: browses (evidence: `README.md`)
- Sales user → Create lead form: creates (evidence: `README.md`)
- Lead list page → Lead search and list: renders (evidence: `frontend/app/leads/page.tsx`)
- Dashboard → API client: requests metrics (evidence: `frontend/app/page.tsx`)
- Dashboard → API client: requests recent leads (evidence: `frontend/app/page.tsx`)
- Lead search and list → API client: fetches leads (evidence: `frontend/app/leads/leads-client.tsx`)
- Create lead form → API client: submits lead
- API client → Lead API: sends HTTP requests (evidence: `README.md`)
- Lead API → Express server: reaches (evidence: `README.md`)
- Express server → MongoDB connection: connects (evidence: `backend/start.ts`)
- Express server → Lead routes: mounts routes (evidence: `backend/start.ts`)
- Express server → Error handling: registers middleware (evidence: `backend/start.ts`)
- Lead routes → Lead operations and analytics: dispatches (evidence: `backend/routes/leadRoutes.ts`)
- Lead operations and analytics → Lead model: queries and updates (evidence: `backend/controllers/leadController.ts`)
- Lead operations and analytics → Lead API types: uses response types (evidence: `backend/controllers/leadController.ts`)
- MongoDB connection → MongoDB: connects (evidence: `backend/db/connection.ts`)
- Lead model → MongoDB: reads and writes
