# hassanzohaib121/authentication-app architecture

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

- Interactive diagram: https://gitdiagram.com/hassanzohaib121/authentication-app
- Repository: https://github.com/hassanzohaib121/authentication-app

## Overview

This is a local desktop authentication and user-management app. A first-run user creates the initial super-admin account; later, users sign in, receive a session, and use the dashboard for profile and password changes, while super-admins manage accounts and roles. The Next.js UI invokes Rust commands through Tauri; Rust owns authentication, authorization, sessions, and persistence in SQLite. The graph also preserves account lockout and audit logging. Some frontend and backend modules are unsampled, so their documented responsibilities are shown without speculative internal wiring.

Main entry points: [`src-tauri/src/lib.rs`](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/lib.rs) (Tauri command host), [`src-tauri/src/auth/service.rs`](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/service.rs) (Auth and account logic), [`src/app/signup/page.tsx`](https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/signup/page.tsx) (First-run page), [`src/components/dashboard/dashboard-auth-guard.tsx`](https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/dashboard/dashboard-auth-guard.tsx) (Session guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_signup_page["First-run page<br/>[page.tsx]"]
  node_signup_form["Setup form<br/>[signup-form.tsx]"]
  node_login_page["Login page<br/>[page.tsx]"]
  node_login_form["Login form<br/>[login-form.tsx]"]
  node_dashboard_guard["Session guard"]
  node_dashboard["Dashboard shell<br/>[layout.tsx]"]
  node_settings["Account settings<br/>[page.tsx]"]
end

subgraph group_backend["Authentication backend"]
  node_tauri["Tauri command host<br/>[lib.rs]"]
  node_commands["Auth commands<br/>[commands.rs]"]
  node_service["Auth and account logic<br/>[service.rs]"]
  node_sessions["Session lifecycle<br/>[session.rs]"]
  node_audit["Audit logging<br/>[audit.rs]"]
  node_auth_entities["Auth data entities<br/>[entity.rs]"]
end

subgraph group_persistence["Local persistence"]
  node_connection["Database initialization<br/>[connection.rs]"]
  node_sqlite[("SQLite database")]
end

node_user(("App user"))

node_user -->|"starts setup"| node_signup_page
node_signup_page -->|"checks setup"| node_tauri
node_signup_page -->|"shows form"| node_signup_form
node_signup_form -->|"submits setup"| node_tauri
node_user -->|"opens sign-in"| node_login_page
node_login_page -->|"shows form"| node_login_form
node_login_form -->|"submits credentials"| node_tauri
node_tauri -->|"dispatches commands"| node_commands
node_commands -->|"calls auth logic"| node_service
node_service -->|"manages sessions"| node_sessions
node_service -->|"records actions"| node_audit
node_service -->|"uses auth records"| node_auth_entities
node_commands -->|"validates session"| node_sessions
node_tauri -->|"initializes database"| node_connection
node_connection -->|"creates and seeds"| node_sqlite
node_service -->|"reads and writes"| node_sqlite
node_sessions -->|"stores sessions"| node_sqlite
node_audit -->|"stores audit events"| node_sqlite
node_user -->|"opens dashboard"| node_dashboard_guard
node_dashboard_guard -->|"checks session"| node_tauri
node_dashboard_guard -->|"allows access"| node_dashboard
node_dashboard -->|"opens settings"| node_settings
node_settings -->|"manages account"| node_tauri

click node_signup_page "https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/signup/page.tsx"
click node_signup_form "https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/auth/signup-form.tsx"
click node_login_page "https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/login/page.tsx"
click node_login_form "https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/auth/login-form.tsx"
click node_dashboard_guard "https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/dashboard/dashboard-auth-guard.tsx"
click node_dashboard "https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/dashboard/layout.tsx"
click node_settings "https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/dashboard/settings/page.tsx"
click node_tauri "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/lib.rs"
click node_commands "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/commands.rs"
click node_service "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/service.rs"
click node_sessions "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/session.rs"
click node_audit "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/audit.rs"
click node_auth_entities "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/entity.rs"
click node_connection "https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/connection.rs"

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_signup_page,node_signup_form,node_login_page,node_login_form,node_dashboard_guard,node_dashboard,node_settings,node_user toneBlue
class node_tauri,node_commands,node_service,node_sessions,node_audit,node_auth_entities toneAmber
class node_connection,node_sqlite toneMint
```

## Components

### Frontend experience

- [First-run page](https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/signup/page.tsx): `src/app/signup/page.tsx`
- [Setup form](https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/auth/signup-form.tsx): `src/components/auth/signup-form.tsx`
- [Login page](https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Login form](https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/auth/login-form.tsx): `src/components/auth/login-form.tsx`
- [Session guard](https://github.com/hassanzohaib121/authentication-app/blob/main/src/components/dashboard/dashboard-auth-guard.tsx): `src/components/dashboard/dashboard-auth-guard.tsx`
- [Dashboard shell](https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/dashboard/layout.tsx): `src/app/dashboard/layout.tsx`
- [Account settings](https://github.com/hassanzohaib121/authentication-app/blob/main/src/app/dashboard/settings/page.tsx): `src/app/dashboard/settings/page.tsx`

### Authentication backend

- [Tauri command host](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`
- [Auth commands](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/commands.rs): `src-tauri/src/auth/commands.rs`
- [Auth and account logic](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/service.rs): `src-tauri/src/auth/service.rs`
- [Session lifecycle](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/session.rs): `src-tauri/src/auth/session.rs`
- [Audit logging](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/audit.rs): `src-tauri/src/auth/audit.rs`
- [Auth data entities](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/auth/entity.rs): `src-tauri/src/auth/entity.rs`

### Local persistence

- [Database initialization](https://github.com/hassanzohaib121/authentication-app/blob/main/src-tauri/src/connection.rs): `src-tauri/src/connection.rs`
- **SQLite database**

### Other components

- **App user**

## Connections

- App user → First-run page: starts setup
- First-run page → Tauri command host: checks setup
- First-run page → Setup form: shows form
- Setup form → Tauri command host: submits setup
- App user → Login page: opens sign-in
- Login page → Login form: shows form
- Login form → Tauri command host: submits credentials
- Tauri command host → Auth commands: dispatches commands
- Auth commands → Auth and account logic: calls auth logic
- Auth and account logic → Session lifecycle: manages sessions
- Auth and account logic → Audit logging: records actions
- Auth and account logic → Auth data entities: uses auth records
- Auth commands → Session lifecycle: validates session
- Tauri command host → Database initialization: initializes database
- Database initialization → SQLite database: creates and seeds
- Auth and account logic → SQLite database: reads and writes
- Session lifecycle → SQLite database: stores sessions
- Audit logging → SQLite database: stores audit events
- App user → Session guard: opens dashboard
- Session guard → Tauri command host: checks session
- Session guard → Dashboard shell: allows access
- Dashboard shell → Account settings: opens settings
- Account settings → Tauri command host: manages account
