# alifaizan786-op/amp_csr architecture

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

- Interactive diagram: https://gitdiagram.com/alifaizan786-op/amp_csr
- Repository: https://github.com/alifaizan786-op/amp_csr

## Overview

AMP CSR Portal is a customer-service application for finding accounts and resolving membership issues. A CSR searches and filters the customer list, opens an account to review vehicles, subscriptions, purchases and activity, then edits account details or performs guarded vehicle and membership actions. The React client calls an Express API; controllers apply business rules and persist customer, purchase and activity records in MongoDB. The README documents UI and API capabilities beyond the sampled excerpts; those branches are represented without inferring unsampled call links.

Main entry points: [`server/controllers/customerController.ts`](https://github.com/alifaizan786-op/amp_csr/blob/main/server/controllers/customerController.ts) (Customer rules), [`server/controllers/vehicleController.ts`](https://github.com/alifaizan786-op/amp_csr/blob/main/server/controllers/vehicleController.ts) (Membership rules), [`client/src/pages/CustomerDetailPage.tsx`](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/pages/CustomerDetailPage.tsx) (Account detail), [`client/src/api/customers.ts`](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/customers.ts) (Customer requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["CSR client"]
  node_app["Routes and layout<br/>[App.tsx]"]
  node_list["Customer search"]
  node_detail["Account detail"]
  node_customer_ui["Account actions"]
  node_vehicle_ui["Vehicle actions"]
  node_customer_api["Customer requests<br/>[customers.ts]"]
  node_vehicle_api["Vehicle requests<br/>[vehicles.ts]"]
  node_http["HTTP client<br/>[client.ts]"]
end

subgraph group_api["API and rules"]
  node_routes["API routes"]
  node_customer_ctrl["Customer rules"]
  node_vehicle_ctrl["Membership rules"]
  node_query["Search filters<br/>[customerQuery.ts]"]
  node_vehicle_helpers["Vehicle operations<br/>[vehicleHelpers.ts]"]
  node_plans["Plan definitions<br/>[plans.ts]"]
  node_activity_helper["Activity logging<br/>[logActivity.ts]"]
  node_connection["Database connection<br/>[connection.ts]"]
end

subgraph group_data["MongoDB records"]
  node_customer_model["Customer and vehicles<br/>[Customer.ts]"]
  node_purchase_model["Purchase records<br/>[Purchase.ts]"]
  node_activity_model["Activity records<br/>[Activity.ts]"]
end

subgraph group_seed["Demo data"]
  node_seed_data["Demo scenarios<br/>[seedData.ts]"]
  node_seed_runner["Seed runner<br/>[seed.ts]"]
end

node_csr(("CSR"))
node_mongo[("MongoDB")]

node_csr -->|"uses portal"| node_app
node_app -->|"routes to"| node_list
node_app -->|"routes to"| node_detail
node_list -->|"requests list"| node_customer_api
node_detail -->|"loads account"| node_customer_api
node_detail -->|"renders"| node_customer_ui
node_detail -->|"renders"| node_vehicle_ui
node_customer_ui -.->|"submits changes"| node_customer_api
node_vehicle_ui -.->|"submits actions"| node_vehicle_api
node_customer_api -->|"sends requests"| node_http
node_vehicle_api -.->|"sends requests"| node_http
node_http -->|"calls API"| node_routes
node_routes -->|"dispatches"| node_customer_ctrl
node_routes -->|"dispatches"| node_vehicle_ctrl
node_customer_ctrl -->|"builds filters"| node_query
node_customer_ctrl -->|"reads and saves"| node_customer_model
node_customer_ctrl -->|"reads purchases"| node_purchase_model
node_customer_ctrl -->|"reads activity"| node_activity_model
node_customer_ctrl -->|"logs changes"| node_activity_helper
node_vehicle_ctrl -->|"saves customer"| node_customer_model
node_vehicle_ctrl -->|"applies operations"| node_vehicle_helpers
node_vehicle_ctrl -->|"validates plans"| node_plans
node_vehicle_ctrl -->|"logs changes"| node_activity_helper
node_activity_helper -->|"creates entries"| node_activity_model
node_connection -->|"connects"| node_mongo
node_customer_model -.->|"persists"| node_mongo
node_purchase_model -.->|"persists"| node_mongo
node_activity_model -.->|"persists"| node_mongo
node_seed_runner -->|"builds fixtures"| node_seed_data
node_seed_runner -->|"writes demo records"| node_customer_model

click node_app "https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/App.tsx"
click node_list "https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/pages/CustomerListPage.tsx"
click node_detail "https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/pages/CustomerDetailPage.tsx"
click node_customer_ui "https://github.com/alifaizan786-op/amp_csr/tree/main/client/src/components/customer"
click node_vehicle_ui "https://github.com/alifaizan786-op/amp_csr/tree/main/client/src/components/vehicle"
click node_customer_api "https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/customers.ts"
click node_vehicle_api "https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/vehicles.ts"
click node_http "https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/client.ts"
click node_routes "https://github.com/alifaizan786-op/amp_csr/tree/main/server/routes"
click node_customer_ctrl "https://github.com/alifaizan786-op/amp_csr/blob/main/server/controllers/customerController.ts"
click node_vehicle_ctrl "https://github.com/alifaizan786-op/amp_csr/blob/main/server/controllers/vehicleController.ts"
click node_query "https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/customerQuery.ts"
click node_vehicle_helpers "https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/vehicleHelpers.ts"
click node_plans "https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/plans.ts"
click node_activity_helper "https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/logActivity.ts"
click node_customer_model "https://github.com/alifaizan786-op/amp_csr/blob/main/server/models/Customer.ts"
click node_purchase_model "https://github.com/alifaizan786-op/amp_csr/blob/main/server/models/Purchase.ts"
click node_activity_model "https://github.com/alifaizan786-op/amp_csr/blob/main/server/models/Activity.ts"
click node_seed_data "https://github.com/alifaizan786-op/amp_csr/blob/main/server/seeds/seedData.ts"
click node_seed_runner "https://github.com/alifaizan786-op/amp_csr/blob/main/server/seeds/seed.ts"
click node_connection "https://github.com/alifaizan786-op/amp_csr/blob/main/server/config/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_app,node_list,node_detail,node_customer_ui,node_vehicle_ui,node_customer_api,node_vehicle_api,node_http toneBlue
class node_routes,node_customer_ctrl,node_vehicle_ctrl,node_query,node_vehicle_helpers,node_plans,node_activity_helper,node_connection,node_mongo toneAmber
class node_customer_model,node_purchase_model,node_activity_model toneMint
class node_seed_data,node_seed_runner toneRose
class node_csr toneIndigo
```

## Components

### CSR client

- [Routes and layout](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Customer search](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/pages/CustomerListPage.tsx): `client/src/pages/CustomerListPage.tsx`
- [Account detail](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/pages/CustomerDetailPage.tsx): `client/src/pages/CustomerDetailPage.tsx`
- [Account actions](https://github.com/alifaizan786-op/amp_csr/tree/main/client/src/components/customer): `client/src/components/customer`
- [Vehicle actions](https://github.com/alifaizan786-op/amp_csr/tree/main/client/src/components/vehicle): `client/src/components/vehicle`
- [Customer requests](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/customers.ts): `client/src/api/customers.ts`
- [Vehicle requests](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/vehicles.ts): `client/src/api/vehicles.ts`
- [HTTP client](https://github.com/alifaizan786-op/amp_csr/blob/main/client/src/api/client.ts): `client/src/api/client.ts`

### API and rules

- [API routes](https://github.com/alifaizan786-op/amp_csr/tree/main/server/routes): `server/routes`
- [Customer rules](https://github.com/alifaizan786-op/amp_csr/blob/main/server/controllers/customerController.ts): `server/controllers/customerController.ts`
- [Membership rules](https://github.com/alifaizan786-op/amp_csr/blob/main/server/controllers/vehicleController.ts): `server/controllers/vehicleController.ts`
- [Search filters](https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/customerQuery.ts): `server/utils/customerQuery.ts`
- [Vehicle operations](https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/vehicleHelpers.ts): `server/utils/vehicleHelpers.ts`
- [Plan definitions](https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/plans.ts): `server/utils/plans.ts`
- [Activity logging](https://github.com/alifaizan786-op/amp_csr/blob/main/server/utils/logActivity.ts): `server/utils/logActivity.ts`
- [Database connection](https://github.com/alifaizan786-op/amp_csr/blob/main/server/config/connection.ts): `server/config/connection.ts`

### MongoDB records

- [Customer and vehicles](https://github.com/alifaizan786-op/amp_csr/blob/main/server/models/Customer.ts): `server/models/Customer.ts`
- [Purchase records](https://github.com/alifaizan786-op/amp_csr/blob/main/server/models/Purchase.ts): `server/models/Purchase.ts`
- [Activity records](https://github.com/alifaizan786-op/amp_csr/blob/main/server/models/Activity.ts): `server/models/Activity.ts`

### Demo data

- [Demo scenarios](https://github.com/alifaizan786-op/amp_csr/blob/main/server/seeds/seedData.ts): `server/seeds/seedData.ts`
- [Seed runner](https://github.com/alifaizan786-op/amp_csr/blob/main/server/seeds/seed.ts): `server/seeds/seed.ts`

### Other components

- **CSR**
- **MongoDB**

## Connections

- CSR → Routes and layout: uses portal (evidence: `README.md`)
- Routes and layout → Customer search: routes to (evidence: `client/src/App.tsx`)
- Routes and layout → Account detail: routes to (evidence: `client/src/App.tsx`)
- Customer search → Customer requests: requests list (evidence: `client/src/pages/CustomerListPage.tsx`)
- Account detail → Customer requests: loads account (evidence: `client/src/pages/CustomerDetailPage.tsx`)
- Account detail → Account actions: renders (evidence: `client/src/pages/CustomerDetailPage.tsx`)
- Account detail → Vehicle actions: renders (evidence: `client/src/pages/CustomerDetailPage.tsx`)
- Account actions → Customer requests: submits changes
- Vehicle actions → Vehicle requests: submits actions
- Customer requests → HTTP client: sends requests (evidence: `client/src/api/customers.ts`)
- Vehicle requests → HTTP client: sends requests
- HTTP client → API routes: calls API (evidence: `client/src/api/client.ts`)
- API routes → Customer rules: dispatches (evidence: `server/routes/customers.ts`)
- API routes → Membership rules: dispatches (evidence: `server/routes/vehicles.ts`)
- Customer rules → Search filters: builds filters (evidence: `server/controllers/customerController.ts`)
- Customer rules → Customer and vehicles: reads and saves (evidence: `server/controllers/customerController.ts`)
- Customer rules → Purchase records: reads purchases (evidence: `server/controllers/customerController.ts`)
- Customer rules → Activity records: reads activity (evidence: `server/controllers/customerController.ts`)
- Customer rules → Activity logging: logs changes (evidence: `server/controllers/customerController.ts`)
- Membership rules → Customer and vehicles: saves customer (evidence: `server/controllers/vehicleController.ts`)
- Membership rules → Vehicle operations: applies operations (evidence: `server/controllers/vehicleController.ts`)
- Membership rules → Plan definitions: validates plans (evidence: `server/controllers/vehicleController.ts`)
- Membership rules → Activity logging: logs changes (evidence: `server/controllers/vehicleController.ts`)
- Activity logging → Activity records: creates entries (evidence: `server/utils/logActivity.ts`)
- Database connection → MongoDB: connects (evidence: `server/config/connection.ts`)
- Customer and vehicles → MongoDB: persists
- Purchase records → MongoDB: persists
- Activity records → MongoDB: persists
- Seed runner → Demo scenarios: builds fixtures (evidence: `server/seeds/seed.ts`)
- Seed runner → Customer and vehicles: writes demo records (evidence: `server/seeds/seed.ts`)
