# majibrin/btc-auth-dashboard architecture

> Architecture diagram of the GitHub repository majibrin/btc-auth-dashboard, 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/majibrin/btc-auth-dashboard
- Repository: https://github.com/majibrin/btc-auth-dashboard

## Overview

This is a BTC dashboard with account registration and login, role-based admin user management, and Bitcoin price display. Users enter through the React app, register or log in through the authentication API, then reach the dashboard or admin view; the dashboard fetches BTC prices, while admins can retrieve user records. The backend stores account and login metadata in MongoDB and enriches signup/login details with IP and user-agent information. Source coverage is based on the supplied excerpts and index; unsampled subsystems and unshown wiring are omitted.

Main entry points: [`backend/routes/auth.js`](https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/routes/auth.js) (Auth and data routes), [`frontend/src/App.jsx`](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/App.jsx) (App routes), [`frontend/src/pages/Register.jsx`](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Register.jsx) (Registration), [`frontend/src/pages/Login.jsx`](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Login.jsx) (Login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web app"]
  node_entry["React entry<br/>[main.jsx]"]
  node_router["App routes<br/>[App.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_dashboard["BTC dashboard<br/>[Dashboard.jsx]"]
  node_admin["Admin panel<br/>[Admin.jsx]"]
  node_api_config["API base config<br/>[api.js]"]
end

subgraph group_backend["Backend API"]
  node_api_server["Express server<br/>[server.js]"]
  node_auth_routes["Auth and data routes<br/>[auth.js]"]
end

subgraph group_identity["Identity data"]
  node_user_schema["User schema<br/>[User.js]"]
  node_user_info["Request metadata<br/>[helpers.js]"]
end

subgraph group_integrations["External services"]
  node_mongo[("MongoDB")]
  node_price_api["BTC price providers"]
  node_geo_api["Geo-IP fallback"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens app"| node_entry
node_entry -->|"renders"| node_router
node_router -->|"routes to"| node_register
node_router -->|"routes to"| node_login
node_router -->|"routes to"| node_dashboard
node_router -->|"routes to"| node_admin
node_register -->|"reads base URL"| node_api_config
node_login -->|"reads base URL"| node_api_config
node_admin -->|"reads base URL"| node_api_config
node_register -->|"posts registration"| node_auth_routes
node_login -->|"posts login"| node_auth_routes
node_admin -->|"fetches users"| node_auth_routes
node_dashboard -->|"fetches BTC price"| node_auth_routes
node_api_server -->|"mounts routes"| node_auth_routes
node_api_server -->|"connects to"| node_mongo
node_auth_routes -->|"queries and saves"| node_user_schema
node_auth_routes -->|"parses request info"| node_user_info
node_auth_routes -->|"requests BTC prices"| node_price_api
node_user_schema -->|"persists user data"| node_mongo
node_user_info -->|"uses fallback lookup"| node_geo_api

click node_entry "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/main.jsx"
click node_router "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/App.jsx"
click node_register "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Register.jsx"
click node_login "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Login.jsx"
click node_dashboard "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Dashboard.jsx"
click node_admin "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Admin.jsx"
click node_api_config "https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/config/api.js"
click node_api_server "https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/server.js"
click node_auth_routes "https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/routes/auth.js"
click node_user_schema "https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/models/User.js"
click node_user_info "https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/utils/helpers.js"

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_entry,node_router,node_register,node_login,node_dashboard,node_admin,node_api_config toneBlue
class node_api_server,node_auth_routes toneAmber
class node_user_schema,node_user_info toneMint
class node_mongo,node_price_api,node_geo_api toneRose
class node_visitor toneIndigo
```

## Components

### Web app

- [React entry](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [App routes](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Registration](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Login](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [BTC dashboard](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Admin panel](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/pages/Admin.jsx): `frontend/src/pages/Admin.jsx`
- [API base config](https://github.com/majibrin/btc-auth-dashboard/blob/main/frontend/src/config/api.js): `frontend/src/config/api.js`

### Backend API

- [Express server](https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/server.js): `backend/server.js`
- [Auth and data routes](https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/routes/auth.js): `backend/routes/auth.js`

### Identity data

- [User schema](https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/models/User.js): `backend/models/User.js`
- [Request metadata](https://github.com/majibrin/btc-auth-dashboard/blob/main/backend/utils/helpers.js): `backend/utils/helpers.js`

### External services

- **MongoDB**
- **BTC price providers**
- **Geo-IP fallback**

### Other components

- **Visitor**

## Connections

- Visitor → React entry: opens app (evidence: `frontend/src/main.jsx`)
- React entry → App routes: renders (evidence: `frontend/src/main.jsx`)
- App routes → Registration: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Login: routes to (evidence: `frontend/src/App.jsx`)
- App routes → BTC dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Admin panel: routes to (evidence: `frontend/src/App.jsx`)
- Registration → API base config: reads base URL (evidence: `frontend/src/pages/Register.jsx`)
- Login → API base config: reads base URL (evidence: `frontend/src/pages/Login.jsx`)
- Admin panel → API base config: reads base URL (evidence: `frontend/src/pages/Admin.jsx`)
- Registration → Auth and data routes: posts registration (evidence: `frontend/src/pages/Register.jsx`)
- Login → Auth and data routes: posts login (evidence: `frontend/src/pages/Login.jsx`)
- Admin panel → Auth and data routes: fetches users (evidence: `frontend/src/pages/Admin.jsx`)
- BTC dashboard → Auth and data routes: fetches BTC price (evidence: `frontend/src/pages/Dashboard.jsx`)
- Express server → Auth and data routes: mounts routes (evidence: `backend/server.js`)
- Express server → MongoDB: connects to (evidence: `backend/server.js`)
- Auth and data routes → User schema: queries and saves (evidence: `backend/routes/auth.js`)
- Auth and data routes → Request metadata: parses request info (evidence: `backend/routes/auth.js`)
- Auth and data routes → BTC price providers: requests BTC prices (evidence: `backend/routes/auth.js`)
- User schema → MongoDB: persists user data (evidence: `backend/models/User.js`)
- Request metadata → Geo-IP fallback: uses fallback lookup (evidence: `backend/utils/helpers.js`)
