# leodviana/clubclincheckpro architecture

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

- Interactive diagram: https://gitdiagram.com/leodviana/clubclincheckpro
- Repository: https://github.com/leodviana/clubclincheckpro

## Overview

This is a Next.js dental-support chat frontend: users sign in, access chat conversations, and submit messages; administrators review open, pending-response, and closed chats and can manage conversations. Authentication is maintained through a provider and API client, while chat and admin screens use a shared authenticated-fetch layer. The tree also shows password recovery/reset and a credits display. Evidence is limited to the README (empty), tree, SOURCE INDEX, and sampled excerpts; unsampled reset and credit behavior is represented without speculative connections.

Main entry points: [`hooks/useAuth.ts`](https://github.com/leodviana/clubclincheckpro/blob/main/hooks/useAuth.ts) (Auth hook), [`hooks/useApi.ts`](https://github.com/leodviana/clubclincheckpro/blob/main/hooks/useApi.ts) (Authenticated API hook), [`app/chat/[chatId]/page.tsx`](https://github.com/leodviana/clubclincheckpro/blob/main/app/chat/%5BchatId%5D/page.tsx) (Chat conversation), [`components/UserCredits.tsx`](https://github.com/leodviana/clubclincheckpro/blob/main/components/UserCredits.tsx) (Credits display)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and identity"]
  node_login["Login screen<br/>[page.tsx]"]
  node_recovery["Password recovery<br/>[page.tsx]"]
  node_resetroute["Password reset route<br/>[route.ts]"]
  node_authprovider["Auth provider<br/>[AuthProvider.tsx]"]
  node_authhook["Auth hook<br/>[useAuth.ts]"]
  node_authgate["Auth gate<br/>[AuthGate.tsx]"]
  node_navauth["Account navigation<br/>[NavAuth.tsx]"]
  node_layout["App shell<br/>[layout.tsx]"]
  node_redirect["Admin redirect<br/>[AdminRedirect.tsx]"]
end

subgraph group_chat["Chat workflow"]
  node_chatpage["Chat conversation<br/>[page.tsx]"]
  node_home["Home and credits<br/>[page.tsx]"]
  node_credits["Credits display<br/>[UserCredits.tsx]"]
end

subgraph group_admin["Admin operations"]
  node_adminopen["Open chats<br/>[page.tsx]"]
  node_adminpending["Pending response<br/>[page.tsx]"]
  node_adminclosed["Closed chats<br/>[page.tsx]"]
  node_adminhome["Admin dashboard<br/>[page.tsx]"]
end

subgraph group_shared["Shared client services"]
  node_creditadapter["Credits adapter<br/>[credits-adapter.ts]"]
  node_api["Authenticated API hook<br/>[useApi.ts]"]
  node_apifetch["API fetch helper<br/>[api-fetch.ts]"]
  node_authclient["Authentication API client<br/>[auth-client.ts]"]
end

node_visitor(("User"))
node_externalapi{{"Backend API"}}

node_visitor -->|"opens"| node_login
node_login -->|"uses session"| node_authhook
node_recovery -->|"requests recovery"| node_authclient
node_authprovider -->|"calls auth"| node_authclient
node_authhook -->|"reads context"| node_authprovider
node_layout -->|"provides session"| node_authprovider
node_layout -->|"gates access"| node_authgate
node_layout -->|"renders navigation"| node_navauth
node_authgate -->|"checks session"| node_authhook
node_navauth -->|"reads session"| node_authhook
node_home -->|"renders credits"| node_credits
node_home -->|"renders redirect"| node_redirect
node_redirect -->|"checks identity"| node_authhook
node_credits -->|"reads session"| node_authhook
node_credits -->|"loads data"| node_api
node_credits -->|"adapts credits"| node_creditadapter
node_chatpage -->|"reads session"| node_authhook
node_chatpage -->|"loads and sends"| node_api
node_adminopen -->|"checks identity"| node_authhook
node_adminopen -->|"loads and closes"| node_api
node_adminopen -->|"links conversations"| node_chatpage
node_adminpending -->|"checks identity"| node_authhook
node_adminpending -->|"loads chats"| node_api
node_adminpending -->|"links conversations"| node_chatpage
node_adminclosed -->|"checks identity"| node_authhook
node_adminclosed -->|"loads chats"| node_api
node_adminclosed -->|"links conversations"| node_chatpage
node_adminhome -.->|"serves dashboard"| node_visitor
node_api -->|"gets token"| node_authhook
node_api -->|"sends requests"| node_apifetch
node_authclient -->|"calls auth endpoints"| node_externalapi

click node_login "https://github.com/leodviana/clubclincheckpro/blob/main/app/login/page.tsx"
click node_recovery "https://github.com/leodviana/clubclincheckpro/blob/main/app/recuperar/page.tsx"
click node_resetroute "https://github.com/leodviana/clubclincheckpro/blob/main/app/api/Login/resetPassword/route.ts"
click node_authprovider "https://github.com/leodviana/clubclincheckpro/blob/main/components/AuthProvider.tsx"
click node_authhook "https://github.com/leodviana/clubclincheckpro/blob/main/hooks/useAuth.ts"
click node_authgate "https://github.com/leodviana/clubclincheckpro/blob/main/components/AuthGate.tsx"
click node_navauth "https://github.com/leodviana/clubclincheckpro/blob/main/components/NavAuth.tsx"
click node_chatpage "https://github.com/leodviana/clubclincheckpro/blob/main/app/chat/%5BchatId%5D/page.tsx"
click node_adminopen "https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/chats/page.tsx"
click node_adminpending "https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/chats/pending-admin-response/page.tsx"
click node_adminclosed "https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/chats/closed/page.tsx"
click node_adminhome "https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/page.tsx"
click node_home "https://github.com/leodviana/clubclincheckpro/blob/main/app/page.tsx"
click node_credits "https://github.com/leodviana/clubclincheckpro/blob/main/components/UserCredits.tsx"
click node_creditadapter "https://github.com/leodviana/clubclincheckpro/blob/main/lib/utils/credits-adapter.ts"
click node_api "https://github.com/leodviana/clubclincheckpro/blob/main/hooks/useApi.ts"
click node_apifetch "https://github.com/leodviana/clubclincheckpro/blob/main/lib/api-fetch.ts"
click node_authclient "https://github.com/leodviana/clubclincheckpro/blob/main/lib/auth-client.ts"
click node_layout "https://github.com/leodviana/clubclincheckpro/blob/main/app/layout.tsx"
click node_redirect "https://github.com/leodviana/clubclincheckpro/blob/main/components/AdminRedirect.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_login,node_recovery,node_resetroute,node_authprovider,node_authhook,node_authgate,node_navauth,node_layout,node_redirect,node_visitor toneBlue
class node_chatpage,node_home,node_credits toneAmber
class node_adminopen,node_adminpending,node_adminclosed,node_adminhome,node_externalapi toneMint
class node_creditadapter,node_api,node_apifetch,node_authclient toneRose
```

## Components

### Access and identity

- [Login screen](https://github.com/leodviana/clubclincheckpro/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Password recovery](https://github.com/leodviana/clubclincheckpro/blob/main/app/recuperar/page.tsx): `app/recuperar/page.tsx`
- [Password reset route](https://github.com/leodviana/clubclincheckpro/blob/main/app/api/Login/resetPassword/route.ts): `app/api/Login/resetPassword/route.ts`
- [Auth provider](https://github.com/leodviana/clubclincheckpro/blob/main/components/AuthProvider.tsx): `components/AuthProvider.tsx`
- [Auth hook](https://github.com/leodviana/clubclincheckpro/blob/main/hooks/useAuth.ts): `hooks/useAuth.ts`
- [Auth gate](https://github.com/leodviana/clubclincheckpro/blob/main/components/AuthGate.tsx): `components/AuthGate.tsx`
- [Account navigation](https://github.com/leodviana/clubclincheckpro/blob/main/components/NavAuth.tsx): `components/NavAuth.tsx`
- [App shell](https://github.com/leodviana/clubclincheckpro/blob/main/app/layout.tsx): `app/layout.tsx`
- [Admin redirect](https://github.com/leodviana/clubclincheckpro/blob/main/components/AdminRedirect.tsx): `components/AdminRedirect.tsx`

### Chat workflow

- [Chat conversation](https://github.com/leodviana/clubclincheckpro/blob/main/app/chat/%5BchatId%5D/page.tsx): `app/chat/[chatId]/page.tsx`
- [Home and credits](https://github.com/leodviana/clubclincheckpro/blob/main/app/page.tsx): `app/page.tsx`
- [Credits display](https://github.com/leodviana/clubclincheckpro/blob/main/components/UserCredits.tsx): `components/UserCredits.tsx`

### Admin operations

- [Open chats](https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/chats/page.tsx): `app/admin/chats/page.tsx`
- [Pending response](https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/chats/pending-admin-response/page.tsx): `app/admin/chats/pending-admin-response/page.tsx`
- [Closed chats](https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/chats/closed/page.tsx): `app/admin/chats/closed/page.tsx`
- [Admin dashboard](https://github.com/leodviana/clubclincheckpro/blob/main/app/admin/page.tsx): `app/admin/page.tsx`

### Shared client services

- [Credits adapter](https://github.com/leodviana/clubclincheckpro/blob/main/lib/utils/credits-adapter.ts): `lib/utils/credits-adapter.ts`
- [Authenticated API hook](https://github.com/leodviana/clubclincheckpro/blob/main/hooks/useApi.ts): `hooks/useApi.ts`
- [API fetch helper](https://github.com/leodviana/clubclincheckpro/blob/main/lib/api-fetch.ts): `lib/api-fetch.ts`
- [Authentication API client](https://github.com/leodviana/clubclincheckpro/blob/main/lib/auth-client.ts): `lib/auth-client.ts`

### Other components

- **User**
- **Backend API**

## Connections

- User → Login screen: opens (evidence: `app/login/page.tsx`)
- Login screen → Auth hook: uses session (evidence: `app/login/page.tsx`)
- Password recovery → Authentication API client: requests recovery (evidence: `app/recuperar/page.tsx`)
- Auth provider → Authentication API client: calls auth (evidence: `components/AuthProvider.tsx`)
- Auth hook → Auth provider: reads context (evidence: `hooks/useAuth.ts`)
- App shell → Auth provider: provides session (evidence: `app/layout.tsx`)
- App shell → Auth gate: gates access (evidence: `app/layout.tsx`)
- App shell → Account navigation: renders navigation (evidence: `app/layout.tsx`)
- Auth gate → Auth hook: checks session (evidence: `components/AuthGate.tsx`)
- Account navigation → Auth hook: reads session (evidence: `components/NavAuth.tsx`)
- Home and credits → Credits display: renders credits (evidence: `app/page.tsx`)
- Home and credits → Admin redirect: renders redirect (evidence: `app/page.tsx`)
- Admin redirect → Auth hook: checks identity (evidence: `components/AdminRedirect.tsx`)
- Credits display → Auth hook: reads session (evidence: `components/UserCredits.tsx`)
- Credits display → Authenticated API hook: loads data (evidence: `components/UserCredits.tsx`)
- Credits display → Credits adapter: adapts credits (evidence: `components/UserCredits.tsx`)
- Chat conversation → Auth hook: reads session (evidence: `app/chat/[chatId]/page.tsx`)
- Chat conversation → Authenticated API hook: loads and sends (evidence: `app/chat/[chatId]/page.tsx`)
- Open chats → Auth hook: checks identity (evidence: `app/admin/chats/page.tsx`)
- Open chats → Authenticated API hook: loads and closes (evidence: `app/admin/chats/page.tsx`)
- Open chats → Chat conversation: links conversations (evidence: `app/admin/chats/page.tsx`)
- Pending response → Auth hook: checks identity (evidence: `app/admin/chats/pending-admin-response/page.tsx`)
- Pending response → Authenticated API hook: loads chats (evidence: `app/admin/chats/pending-admin-response/page.tsx`)
- Pending response → Chat conversation: links conversations (evidence: `app/admin/chats/pending-admin-response/page.tsx`)
- Closed chats → Auth hook: checks identity (evidence: `app/admin/chats/closed/page.tsx`)
- Closed chats → Authenticated API hook: loads chats (evidence: `app/admin/chats/closed/page.tsx`)
- Closed chats → Chat conversation: links conversations (evidence: `app/admin/chats/closed/page.tsx`)
- Admin dashboard → User: serves dashboard (evidence: `app/admin/page.tsx`)
- Authenticated API hook → Auth hook: gets token (evidence: `hooks/useApi.ts`)
- Authenticated API hook → API fetch helper: sends requests (evidence: `hooks/useApi.ts`)
- Authentication API client → Backend API: calls auth endpoints (evidence: `lib/auth-client.ts`)
