# pavantejareddy1/secureauth architecture

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

- Interactive diagram: https://gitdiagram.com/pavantejareddy1/secureauth
- Repository: https://github.com/pavantejareddy1/secureauth

## Overview

SecureAuth is a passwordless authentication platform. The main user journey runs through registration or login, OTP delivery and verification, then session creation; signed-in users can also register or use a WebAuthn passkey. Server-side user state enforces verification, failed-attempt lockout, and one active device. The graph includes the client screens and API boundary, server routing and handlers, and the state and delivery layers. Relationships reflect the excerpts, source index references, and README; unsampled implementation details are not inferred.

Main entry points: [`client/src/App.jsx`](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/App.jsx) (Client routes), [`client/src/services/api.js`](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/services/api.js) (API client), [`server/controllers/authController.js`](https://github.com/pavantejareddy1/secureauth/blob/main/server/controllers/authController.js) (OTP and sessions), [`server/services/otpDelivery.js`](https://github.com/pavantejareddy1/secureauth/blob/main/server/services/otpDelivery.js) (OTP dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_routes_ui["Client routes<br/>[App.jsx]"]
  node_registration["Registration<br/>[RegisterPage.jsx]"]
  node_login["OTP login<br/>[LoginPage.jsx]"]
  node_otp_screen["OTP verification<br/>[OtpPage.jsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.jsx]"]
  node_biometric_ui["Passkey screens<br/>[BiometricPage.jsx]"]
  node_locked["Lockout screen<br/>[LockedPage.jsx]"]
  node_auth_state["Auth context<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_ui_kit["UI components"]
  node_validators["Form validation<br/>[validators.js]"]
end

subgraph group_server["API and workflows"]
  node_express_app["Express app<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_auth_controller["OTP and sessions<br/>[authController.js]"]
  node_webauthn_routes["WebAuthn routes<br/>[webauthn.js]"]
  node_webauthn_controller["Passkey verification"]
  node_session_auth["Session middleware<br/>[authenticate.js]"]
end

subgraph group_state["Identity state"]
  node_user_model[("User records<br/>[User.js]")]
  node_session_utils["Session utilities<br/>[session.js]"]
  node_otp_utils["OTP generation<br/>[otp.js]"]
end

subgraph group_delivery["OTP delivery"]
  node_otp_delivery["OTP dispatcher<br/>[otpDelivery.js]"]
  node_email_service["Email delivery<br/>[emailService.js]"]
  node_sms_service["SMS delivery<br/>[smsService.js]"]
  node_demo_service["Demo delivery<br/>[demoService.js]"]
end

node_user(("User"))
node_authenticator(("Device authenticator"))

node_user -->|"uses"| node_routes_ui
node_routes_ui -->|"routes to"| node_registration
node_routes_ui -->|"routes to"| node_login
node_routes_ui -->|"routes to"| node_otp_screen
node_routes_ui -->|"routes to"| node_dashboard
node_routes_ui -->|"routes to"| node_biometric_ui
node_routes_ui -->|"routes to"| node_locked
node_registration -->|"validates with"| node_validators
node_login -->|"validates with"| node_validators
node_registration -->|"submits through"| node_api_client
node_login -->|"requests OTP"| node_api_client
node_otp_screen -->|"verifies through"| node_api_client
node_dashboard -->|"calls services"| node_api_client
node_biometric_ui -->|"calls services"| node_api_client
node_api_client -->|"sends API requests"| node_express_app
node_auth_state -->|"checks session"| node_api_client
node_express_app -->|"mounts"| node_auth_routes
node_express_app -->|"mounts"| node_webauthn_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_webauthn_routes -->|"dispatches"| node_webauthn_controller
node_auth_routes -->|"protects routes"| node_session_auth
node_webauthn_routes -->|"protects routes"| node_session_auth
node_auth_controller -->|"reads and updates"| node_user_model
node_auth_controller -->|"generates and checks"| node_otp_utils
node_auth_controller -->|"creates session"| node_session_utils
node_auth_controller -->|"requests delivery"| node_otp_delivery
node_webauthn_controller -->|"stores credentials"| node_user_model
node_webauthn_controller -->|"creates session"| node_session_utils
node_session_auth -->|"verifies token"| node_session_utils
node_session_auth -->|"checks active session"| node_user_model
node_otp_delivery -->|"routes email"| node_email_service
node_otp_delivery -->|"routes SMS"| node_sms_service
node_otp_delivery -.->|"supports demo mode"| node_demo_service
node_user_model -->|"stores public credential"| node_authenticator
node_biometric_ui -->|"invokes device prompt"| node_authenticator

click node_routes_ui "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/App.jsx"
click node_registration "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/RegisterPage.jsx"
click node_login "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/LoginPage.jsx"
click node_otp_screen "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/OtpPage.jsx"
click node_dashboard "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/DashboardPage.jsx"
click node_biometric_ui "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/BiometricPage.jsx"
click node_locked "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/LockedPage.jsx"
click node_auth_state "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/context/AuthContext.jsx"
click node_api_client "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/services/api.js"
click node_ui_kit "https://github.com/pavantejareddy1/secureauth/tree/main/client/src/components/ui"
click node_validators "https://github.com/pavantejareddy1/secureauth/blob/main/client/src/utils/validators.js"
click node_express_app "https://github.com/pavantejareddy1/secureauth/blob/main/server/app.js"
click node_auth_routes "https://github.com/pavantejareddy1/secureauth/blob/main/server/routes/auth.js"
click node_auth_controller "https://github.com/pavantejareddy1/secureauth/blob/main/server/controllers/authController.js"
click node_webauthn_routes "https://github.com/pavantejareddy1/secureauth/blob/main/server/routes/webauthn.js"
click node_webauthn_controller "https://github.com/pavantejareddy1/secureauth/blob/main/server/controllers/webauthnController.js"
click node_session_auth "https://github.com/pavantejareddy1/secureauth/blob/main/server/middleware/authenticate.js"
click node_user_model "https://github.com/pavantejareddy1/secureauth/blob/main/server/models/User.js"
click node_session_utils "https://github.com/pavantejareddy1/secureauth/blob/main/server/utils/session.js"
click node_otp_utils "https://github.com/pavantejareddy1/secureauth/blob/main/server/utils/otp.js"
click node_otp_delivery "https://github.com/pavantejareddy1/secureauth/blob/main/server/services/otpDelivery.js"
click node_email_service "https://github.com/pavantejareddy1/secureauth/blob/main/server/services/emailService.js"
click node_sms_service "https://github.com/pavantejareddy1/secureauth/blob/main/server/services/smsService.js"
click node_demo_service "https://github.com/pavantejareddy1/secureauth/blob/main/server/services/demoService.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_routes_ui,node_registration,node_login,node_otp_screen,node_dashboard,node_biometric_ui,node_locked,node_auth_state,node_api_client,node_ui_kit,node_validators,node_user toneBlue
class node_express_app,node_auth_routes,node_auth_controller,node_webauthn_routes,node_webauthn_controller,node_session_auth toneAmber
class node_user_model,node_session_utils,node_otp_utils toneMint
class node_otp_delivery,node_email_service,node_sms_service,node_demo_service toneRose
class node_authenticator toneIndigo
```

## Components

### Client experience

- [Client routes](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Registration](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/RegisterPage.jsx): `client/src/pages/RegisterPage.jsx`
- [OTP login](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/LoginPage.jsx): `client/src/pages/LoginPage.jsx`
- [OTP verification](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/OtpPage.jsx): `client/src/pages/OtpPage.jsx`
- [Dashboard](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [Passkey screens](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/BiometricPage.jsx): `client/src/pages/BiometricPage.jsx`
- [Lockout screen](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/pages/LockedPage.jsx): `client/src/pages/LockedPage.jsx`
- [Auth context](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [API client](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [UI components](https://github.com/pavantejareddy1/secureauth/tree/main/client/src/components/ui): `client/src/components/ui`
- [Form validation](https://github.com/pavantejareddy1/secureauth/blob/main/client/src/utils/validators.js): `client/src/utils/validators.js`

### API and workflows

- [Express app](https://github.com/pavantejareddy1/secureauth/blob/main/server/app.js): `server/app.js`
- [Auth routes](https://github.com/pavantejareddy1/secureauth/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [OTP and sessions](https://github.com/pavantejareddy1/secureauth/blob/main/server/controllers/authController.js): `server/controllers/authController.js`
- [WebAuthn routes](https://github.com/pavantejareddy1/secureauth/blob/main/server/routes/webauthn.js): `server/routes/webauthn.js`
- [Passkey verification](https://github.com/pavantejareddy1/secureauth/blob/main/server/controllers/webauthnController.js): `server/controllers/webauthnController.js`
- [Session middleware](https://github.com/pavantejareddy1/secureauth/blob/main/server/middleware/authenticate.js): `server/middleware/authenticate.js`

### Identity state

- [User records](https://github.com/pavantejareddy1/secureauth/blob/main/server/models/User.js): `server/models/User.js`
- [Session utilities](https://github.com/pavantejareddy1/secureauth/blob/main/server/utils/session.js): `server/utils/session.js`
- [OTP generation](https://github.com/pavantejareddy1/secureauth/blob/main/server/utils/otp.js): `server/utils/otp.js`

### OTP delivery

- [OTP dispatcher](https://github.com/pavantejareddy1/secureauth/blob/main/server/services/otpDelivery.js): `server/services/otpDelivery.js`
- [Email delivery](https://github.com/pavantejareddy1/secureauth/blob/main/server/services/emailService.js): `server/services/emailService.js`
- [SMS delivery](https://github.com/pavantejareddy1/secureauth/blob/main/server/services/smsService.js): `server/services/smsService.js`
- [Demo delivery](https://github.com/pavantejareddy1/secureauth/blob/main/server/services/demoService.js): `server/services/demoService.js`

### Other components

- **User**
- **Device authenticator**

## Connections

- User → Client routes: uses (evidence: `README.md`)
- Client routes → Registration: routes to (evidence: `client/src/App.jsx`)
- Client routes → OTP login: routes to (evidence: `client/src/App.jsx`)
- Client routes → OTP verification: routes to (evidence: `client/src/App.jsx`)
- Client routes → Dashboard: routes to (evidence: `client/src/App.jsx`)
- Client routes → Passkey screens: routes to (evidence: `client/src/App.jsx`)
- Client routes → Lockout screen: routes to (evidence: `client/src/App.jsx`)
- Registration → Form validation: validates with (evidence: `client/src/pages/RegisterPage.jsx`)
- OTP login → Form validation: validates with (evidence: `client/src/pages/LoginPage.jsx`)
- Registration → API client: submits through (evidence: `client/src/pages/RegisterPage.jsx`)
- OTP login → API client: requests OTP (evidence: `client/src/pages/LoginPage.jsx`)
- OTP verification → API client: verifies through (evidence: `client/src/pages/OtpPage.jsx`)
- Dashboard → API client: calls services (evidence: `client/src/pages/DashboardPage.jsx`)
- Passkey screens → API client: calls services (evidence: `client/src/pages/BiometricPage.jsx`)
- API client → Express app: sends API requests (evidence: `README.md`)
- Auth context → API client: checks session (evidence: `client/src/context/AuthContext.jsx`)
- Express app → Auth routes: mounts (evidence: `server/app.js`)
- Express app → WebAuthn routes: mounts (evidence: `server/app.js`)
- Auth routes → OTP and sessions: dispatches (evidence: `server/routes/auth.js`)
- WebAuthn routes → Passkey verification: dispatches (evidence: `server/routes/webauthn.js`)
- Auth routes → Session middleware: protects routes (evidence: `server/routes/auth.js`)
- WebAuthn routes → Session middleware: protects routes (evidence: `server/routes/webauthn.js`)
- OTP and sessions → User records: reads and updates (evidence: `server/controllers/authController.js`)
- OTP and sessions → OTP generation: generates and checks (evidence: `server/controllers/authController.js`)
- OTP and sessions → Session utilities: creates session (evidence: `server/controllers/authController.js`)
- OTP and sessions → OTP dispatcher: requests delivery (evidence: `server/controllers/authController.js`)
- Passkey verification → User records: stores credentials (evidence: `server/controllers/webauthnController.js`)
- Passkey verification → Session utilities: creates session (evidence: `server/controllers/webauthnController.js`)
- Session middleware → Session utilities: verifies token (evidence: `server/middleware/authenticate.js`)
- Session middleware → User records: checks active session (evidence: `server/middleware/authenticate.js`)
- OTP dispatcher → Email delivery: routes email (evidence: `server/services/otpDelivery.js`)
- OTP dispatcher → SMS delivery: routes SMS (evidence: `server/services/otpDelivery.js`)
- OTP dispatcher → Demo delivery: supports demo mode
- User records → Device authenticator: stores public credential (evidence: `README.md`)
- Passkey screens → Device authenticator: invokes device prompt (evidence: `README.md`)
