# xenocore-wirachain/wirachain-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/xenocore-wirachain/wirachain-frontend
- Repository: https://github.com/xenocore-wirachain/wirachain-frontend

## Overview

This is a role-based clinic and medical-consultation management frontend. Users authenticate, enter a role-specific dashboard, and work with clinic, doctor, patient, appointment, and administration features through a shared Redux/RTK Query layer. The tree and sampled files support the routing, auth state, shared API setup, and several feature areas; most feature-page and endpoint implementations were not sampled, so their internal call paths are not asserted.

Main entry points: [`src/routers/index.tsx`](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/routers/index.tsx) (Role router), [`src/redux/api/CustomBaseQuery.tsx`](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/api/CustomBaseQuery.tsx) (Authenticated API transport), [`src/redux/index.tsx`](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/index.tsx) (Redux store), [`src/main.tsx`](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/main.tsx) (React app mount)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["React app mount<br/>[main.tsx]"]
end

subgraph group_identity["Identity and routing"]
  node_router["Role router<br/>[index.tsx]"]
  node_auth_pages["Sign in and register"]
  node_auth_hook["Auth selector<br/>[UseAuth.tsx]"]
  node_token["Token storage<br/>[TokenManager.tsx]"]
end

subgraph group_features["Role-based workflows"]
  node_dashboard["Dashboard shell<br/>[BodyDashboard.tsx]"]
  node_admin["Platform administration"]
  node_clinic["Clinic management"]
  node_doctor["Doctor workflow"]
  node_patient["Patient workflow"]
end

subgraph group_shared["Shared state and APIs"]
  node_auth_state["Auth state<br/>[AuthSlice.tsx]"]
  node_consultations["Consultation data"]
  node_api_layer["RTK Query APIs"]
  node_store["Redux store<br/>[index.tsx]"]
  node_api_base["Authenticated API transport"]
end

node_user(("User"))
node_server["Backend API"]

node_user -->|"uses"| node_app
node_app -->|"provides state"| node_store
node_app -->|"mounts routes"| node_router
node_router -->|"routes to"| node_auth_pages
node_router -->|"renders dashboard"| node_dashboard
node_router -->|"routes by role"| node_admin
node_router -->|"routes by role"| node_clinic
node_router -->|"routes by role"| node_doctor
node_router -->|"routes by role"| node_patient
node_router -->|"checks identity"| node_auth_hook
node_auth_hook -->|"selects state"| node_store
node_auth_state -->|"persists tokens"| node_token
node_store -->|"registers reducer"| node_auth_state
node_store -->|"registers APIs"| node_api_layer
node_api_layer -->|"uses transport"| node_api_base
node_api_base -->|"reads credentials"| node_token
node_api_base -->|"refreshes or logs out"| node_auth_state
node_api_base -->|"sends requests"| node_server
node_api_layer -->|"registers endpoint"| node_consultations

click node_app "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/main.tsx"
click node_router "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/routers/index.tsx"
click node_auth_pages "https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/auth/pages"
click node_auth_hook "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/features/auth/hooks/UseAuth.tsx"
click node_token "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/features/auth/utils/TokenManager.tsx"
click node_auth_state "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/slices/AuthSlice.tsx"
click node_dashboard "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/layouts/BodyDashboard.tsx"
click node_admin "https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/admin"
click node_clinic "https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/clinic"
click node_doctor "https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/doctor"
click node_patient "https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/patient"
click node_consultations "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/api/MedicalConsultationAPI.tsx"
click node_api_layer "https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/redux/api"
click node_store "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/index.tsx"
click node_api_base "https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/api/CustomBaseQuery.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_app,node_user toneBlue
class node_router,node_auth_pages,node_auth_hook,node_token toneAmber
class node_dashboard,node_admin,node_clinic,node_doctor,node_patient,node_server toneMint
class node_auth_state,node_consultations,node_api_layer,node_store,node_api_base toneRose
```

## Components

### Application entry

- [React app mount](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/main.tsx): `src/main.tsx`

### Identity and routing

- [Role router](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/routers/index.tsx): `src/routers/index.tsx`
- [Sign in and register](https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/auth/pages): `src/features/auth/pages`
- [Auth selector](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/features/auth/hooks/UseAuth.tsx): `src/features/auth/hooks/UseAuth.tsx`
- [Token storage](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/features/auth/utils/TokenManager.tsx): `src/features/auth/utils/TokenManager.tsx`

### Role-based workflows

- [Dashboard shell](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/layouts/BodyDashboard.tsx): `src/layouts/BodyDashboard.tsx`
- [Platform administration](https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/admin): `src/features/admin`
- [Clinic management](https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/clinic): `src/features/clinic`
- [Doctor workflow](https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/doctor): `src/features/doctor`
- [Patient workflow](https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/features/patient): `src/features/patient`

### Shared state and APIs

- [Auth state](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/slices/AuthSlice.tsx): `src/redux/slices/AuthSlice.tsx`
- [Consultation data](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/api/MedicalConsultationAPI.tsx): `src/redux/api/MedicalConsultationAPI.tsx`
- [RTK Query APIs](https://github.com/xenocore-wirachain/wirachain-frontend/tree/main/src/redux/api): `src/redux/api`
- [Redux store](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/index.tsx): `src/redux/index.tsx`
- [Authenticated API transport](https://github.com/xenocore-wirachain/wirachain-frontend/blob/main/src/redux/api/CustomBaseQuery.tsx): `src/redux/api/CustomBaseQuery.tsx`

### Other components

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

## Connections

- User → React app mount: uses
- React app mount → Redux store: provides state (evidence: `src/main.tsx`)
- React app mount → Role router: mounts routes (evidence: `src/main.tsx`)
- Role router → Sign in and register: routes to (evidence: `src/routers/index.tsx`)
- Role router → Dashboard shell: renders dashboard (evidence: `src/routers/index.tsx`)
- Role router → Platform administration: routes by role (evidence: `src/routers/index.tsx`)
- Role router → Clinic management: routes by role (evidence: `src/routers/index.tsx`)
- Role router → Doctor workflow: routes by role (evidence: `src/routers/index.tsx`)
- Role router → Patient workflow: routes by role (evidence: `src/routers/index.tsx`)
- Role router → Auth selector: checks identity (evidence: `src/routers/index.tsx`)
- Auth selector → Redux store: selects state (evidence: `src/features/auth/hooks/UseAuth.tsx`)
- Auth state → Token storage: persists tokens (evidence: `src/redux/slices/AuthSlice.tsx`)
- Redux store → Auth state: registers reducer (evidence: `src/redux/index.tsx`)
- Redux store → RTK Query APIs: registers APIs (evidence: `src/redux/index.tsx`)
- RTK Query APIs → Authenticated API transport: uses transport (evidence: `src/redux/api/AuthAPI.tsx`)
- Authenticated API transport → Token storage: reads credentials (evidence: `src/redux/api/CustomBaseQuery.tsx`)
- Authenticated API transport → Auth state: refreshes or logs out (evidence: `src/redux/api/CustomBaseQuery.tsx`)
- Authenticated API transport → Backend API: sends requests (evidence: `src/redux/api/CustomBaseQuery.tsx`)
- RTK Query APIs → Consultation data: registers endpoint (evidence: `src/redux/index.tsx`)
