# kumar-student/financial-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/kumar-student/financial-dashboard
- Repository: https://github.com/kumar-student/financial-dashboard

## Overview

This is a Next.js course dashboard for viewing revenue, invoices, and customers, with credential-based login and invoice management. A user signs in, enters the protected dashboard, searches and pages through invoices, then creates, edits, or deletes them; dashboard views also summarize revenue and recent invoices. The graph separates route orchestration, UI, data access, and authentication. Source coverage is limited to the supplied excerpts and SOURCE INDEX; customer-route behavior and some UI details are therefore shown only where documented or left unconnected.

Main entry points: [`app/lib/data.ts`](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/data.ts) (Dashboard and invoice queries), [`auth.ts`](https://github.com/kumar-student/financial-dashboard/blob/main/auth.ts) (Credentials authentication), [`app/lib/actions.ts`](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/actions.ts) (Invoice and login actions), [`app/dashboard/invoices/page.tsx`](https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/page.tsx) (Invoice list route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routes["Dashboard routes"]
  node_dashboard["Dashboard overview<br/>[page.tsx]"]
  node_invoice_list_route["Invoice list route<br/>[page.tsx]"]
  node_invoice_create_route["Create invoice route<br/>[page.tsx]"]
  node_invoice_edit_route["Edit invoice route<br/>[page.tsx]"]
  node_customers_route["Customer route<br/>[page.tsx]"]
  node_login_route["Login route<br/>[page.tsx]"]
end

subgraph group_ui["User interface"]
  node_dashboard_views["Dashboard cards and lists<br/>[cards.tsx]"]
  node_revenue_chart["Revenue chart<br/>[revenue-chart.tsx]"]
  node_invoice_table["Invoice table<br/>[table.tsx]"]
  node_invoice_search["Invoice search<br/>[search.tsx]"]
  node_invoice_forms["Invoice forms<br/>[create-form.tsx]"]
  node_customer_table["Customer table<br/>[table.tsx]"]
  node_login_form["Login form<br/>[login-form.tsx]"]
  node_invoice_actions_ui["Invoice actions<br/>[buttons.tsx]"]
end

subgraph group_data["Data and actions"]
  node_data_access["Dashboard and invoice queries<br/>[data.ts]"]
  node_server_actions["Invoice and login actions<br/>[actions.ts]"]
  node_types["Domain data types<br/>[definitions.ts]"]
  node_formatting["Formatting utilities<br/>[utils.ts]"]
  node_placeholder_data["Placeholder records"]
end

subgraph group_identity["Authentication"]
  node_auth_config["Auth policy<br/>[auth.config.ts]"]
  node_auth["Credentials authentication<br/>[auth.ts]"]
  node_middleware["Route protection<br/>[middleware.ts]"]
end

node_visitor(("Visitor"))
node_postgres[("Postgres database")]

node_visitor -->|"opens login"| node_login_route
node_login_route -->|"renders"| node_login_form
node_login_form -->|"submits credentials"| node_server_actions
node_server_actions -->|"signs in"| node_auth
node_auth -->|"uses policy"| node_auth_config
node_auth -->|"reads user"| node_postgres
node_middleware -->|"checks access"| node_auth_config
node_auth -->|"configures"| node_auth_config
node_visitor -.->|"opens dashboard"| node_dashboard
node_dashboard -->|"renders"| node_dashboard_views
node_dashboard -->|"renders"| node_revenue_chart
node_dashboard_views -->|"fetches summaries"| node_data_access
node_revenue_chart -->|"fetches revenue"| node_data_access
node_invoice_list_route -->|"renders"| node_invoice_search
node_invoice_list_route -->|"renders"| node_invoice_table
node_invoice_list_route -->|"counts pages"| node_data_access
node_invoice_search -->|"updates query"| node_invoice_list_route
node_invoice_table -->|"loads rows"| node_data_access
node_invoice_create_route -->|"renders"| node_invoice_forms
node_invoice_edit_route -->|"renders edit form"| node_invoice_forms
node_invoice_edit_route -->|"loads invoice"| node_data_access
node_invoice_forms -->|"submits changes"| node_server_actions
node_invoice_actions_ui -->|"invokes deletion"| node_server_actions
node_server_actions -->|"writes invoices"| node_postgres
node_data_access -->|"queries records"| node_postgres
node_customers_route -.->|"renders table"| node_customer_table
node_customer_table -.->|"loads customers"| node_data_access
node_data_access -->|"formats amounts"| node_formatting
node_data_access -->|"uses types"| node_types
node_auth -->|"uses user type"| node_types

click node_dashboard "https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/(overview)/page.tsx"
click node_invoice_list_route "https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/page.tsx"
click node_invoice_create_route "https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/create/page.tsx"
click node_invoice_edit_route "https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/%5Bid%5D/edit/page.tsx"
click node_customers_route "https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/customers/page.tsx"
click node_login_route "https://github.com/kumar-student/financial-dashboard/blob/main/app/login/page.tsx"
click node_dashboard_views "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/dashboard/cards.tsx"
click node_revenue_chart "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/dashboard/revenue-chart.tsx"
click node_invoice_table "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/invoices/table.tsx"
click node_invoice_search "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/search.tsx"
click node_invoice_forms "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/invoices/create-form.tsx"
click node_customer_table "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/customers/table.tsx"
click node_login_form "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/login-form.tsx"
click node_invoice_actions_ui "https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/invoices/buttons.tsx"
click node_data_access "https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/data.ts"
click node_server_actions "https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/actions.ts"
click node_types "https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/definitions.ts"
click node_formatting "https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/utils.ts"
click node_placeholder_data "https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/placeholder-data.js"
click node_auth_config "https://github.com/kumar-student/financial-dashboard/blob/main/auth.config.ts"
click node_auth "https://github.com/kumar-student/financial-dashboard/blob/main/auth.ts"
click node_middleware "https://github.com/kumar-student/financial-dashboard/blob/main/middleware.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_invoice_list_route,node_invoice_create_route,node_invoice_edit_route,node_customers_route,node_login_route toneBlue
class node_dashboard_views,node_revenue_chart,node_invoice_table,node_invoice_search,node_invoice_forms,node_customer_table,node_login_form,node_invoice_actions_ui,node_postgres toneAmber
class node_data_access,node_server_actions,node_types,node_formatting,node_placeholder_data toneMint
class node_auth_config,node_auth,node_middleware toneRose
class node_visitor toneIndigo
```

## Components

### Dashboard routes

- [Dashboard overview](https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/(overview)/page.tsx): `app/dashboard/(overview)/page.tsx`
- [Invoice list route](https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/page.tsx): `app/dashboard/invoices/page.tsx`
- [Create invoice route](https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/create/page.tsx): `app/dashboard/invoices/create/page.tsx`
- [Edit invoice route](https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/invoices/%5Bid%5D/edit/page.tsx): `app/dashboard/invoices/[id]/edit/page.tsx`
- [Customer route](https://github.com/kumar-student/financial-dashboard/blob/main/app/dashboard/customers/page.tsx): `app/dashboard/customers/page.tsx`
- [Login route](https://github.com/kumar-student/financial-dashboard/blob/main/app/login/page.tsx): `app/login/page.tsx`

### User interface

- [Dashboard cards and lists](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/dashboard/cards.tsx): `app/ui/dashboard/cards.tsx`
- [Revenue chart](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/dashboard/revenue-chart.tsx): `app/ui/dashboard/revenue-chart.tsx`
- [Invoice table](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/invoices/table.tsx): `app/ui/invoices/table.tsx`
- [Invoice search](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/search.tsx): `app/ui/search.tsx`
- [Invoice forms](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/invoices/create-form.tsx): `app/ui/invoices/create-form.tsx`
- [Customer table](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/customers/table.tsx): `app/ui/customers/table.tsx`
- [Login form](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/login-form.tsx): `app/ui/login-form.tsx`
- [Invoice actions](https://github.com/kumar-student/financial-dashboard/blob/main/app/ui/invoices/buttons.tsx): `app/ui/invoices/buttons.tsx`

### Data and actions

- [Dashboard and invoice queries](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/data.ts): `app/lib/data.ts`
- [Invoice and login actions](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/actions.ts): `app/lib/actions.ts`
- [Domain data types](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/definitions.ts): `app/lib/definitions.ts`
- [Formatting utilities](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/utils.ts): `app/lib/utils.ts`
- [Placeholder records](https://github.com/kumar-student/financial-dashboard/blob/main/app/lib/placeholder-data.js): `app/lib/placeholder-data.js`

### Authentication

- [Auth policy](https://github.com/kumar-student/financial-dashboard/blob/main/auth.config.ts): `auth.config.ts`
- [Credentials authentication](https://github.com/kumar-student/financial-dashboard/blob/main/auth.ts): `auth.ts`
- [Route protection](https://github.com/kumar-student/financial-dashboard/blob/main/middleware.ts): `middleware.ts`

### Other components

- **Visitor**
- **Postgres database**

## Connections

- Visitor → Login route: opens login (evidence: `app/login/page.tsx`)
- Login route → Login form: renders (evidence: `app/login/page.tsx`)
- Login form → Invoice and login actions: submits credentials (evidence: `app/lib/actions.ts`)
- Invoice and login actions → Credentials authentication: signs in (evidence: `app/lib/actions.ts`)
- Credentials authentication → Auth policy: uses policy (evidence: `auth.ts`)
- Credentials authentication → Postgres database: reads user (evidence: `auth.ts`)
- Route protection → Auth policy: checks access (evidence: `middleware.ts`)
- Credentials authentication → Auth policy: configures (evidence: `auth.ts`)
- Visitor → Dashboard overview: opens dashboard
- Dashboard overview → Dashboard cards and lists: renders (evidence: `app/dashboard/(overview)/page.tsx`)
- Dashboard overview → Revenue chart: renders (evidence: `app/dashboard/(overview)/page.tsx`)
- Dashboard cards and lists → Dashboard and invoice queries: fetches summaries (evidence: `app/ui/dashboard/cards.tsx`)
- Revenue chart → Dashboard and invoice queries: fetches revenue (evidence: `app/ui/dashboard/revenue-chart.tsx`)
- Invoice list route → Invoice search: renders (evidence: `app/dashboard/invoices/page.tsx`)
- Invoice list route → Invoice table: renders (evidence: `app/dashboard/invoices/page.tsx`)
- Invoice list route → Dashboard and invoice queries: counts pages (evidence: `app/dashboard/invoices/page.tsx`)
- Invoice search → Invoice list route: updates query (evidence: `app/ui/search.tsx`)
- Invoice table → Dashboard and invoice queries: loads rows (evidence: `app/ui/invoices/table.tsx`)
- Create invoice route → Invoice forms: renders (evidence: `app/dashboard/invoices/create/page.tsx`)
- Edit invoice route → Invoice forms: renders edit form (evidence: `app/dashboard/invoices/[id]/edit/page.tsx`)
- Edit invoice route → Dashboard and invoice queries: loads invoice (evidence: `app/dashboard/invoices/[id]/edit/page.tsx`)
- Invoice forms → Invoice and login actions: submits changes (evidence: `app/lib/actions.ts`)
- Invoice actions → Invoice and login actions: invokes deletion (evidence: `app/ui/invoices/buttons.tsx`)
- Invoice and login actions → Postgres database: writes invoices (evidence: `app/lib/actions.ts`)
- Dashboard and invoice queries → Postgres database: queries records (evidence: `app/lib/data.ts`)
- Customer route → Customer table: renders table
- Customer table → Dashboard and invoice queries: loads customers
- Dashboard and invoice queries → Formatting utilities: formats amounts (evidence: `app/lib/data.ts`)
- Dashboard and invoice queries → Domain data types: uses types (evidence: `app/lib/data.ts`)
- Credentials authentication → Domain data types: uses user type (evidence: `auth.ts`)
