# manish166/authnext architecture

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

- Interactive diagram: https://gitdiagram.com/manish166/authnext
- Repository: https://github.com/manish166/authnext

## Overview

This is a Next.js authentication application: users open sign-in or sign-up UI, submit credentials or registration details, and receive a profile or session token through server actions backed by Clerk. The source also shows separate authorized and unauthorized layouts and an authorized home page. Validation and error conversion form an internal server-action layer. Form submission wiring and page behavior are not fully sampled, so those links are omitted; the Prisma schema is present, but the sampled auth service uses Clerk rather than Prisma.

Main entry points: [`src/bff/auth/authService.ts`](https://github.com/manish166/authnext/blob/main/src/bff/auth/authService.ts) (Auth service), [`src/app/actions/auth.ts`](https://github.com/manish166/authnext/blob/main/src/app/actions/auth.ts) (Auth actions), [`src/app/components/molecules/ModalManager.tsx`](https://github.com/manish166/authnext/blob/main/src/app/components/molecules/ModalManager.tsx) (Modal manager), [`src/app/(unAuthorised)/layout.tsx`](https://github.com/manish166/authnext/blob/main/src/app/(unAuthorised)/layout.tsx) (Public layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_public_layout["Public layout<br/>[layout.tsx]"]
  node_authorized_layout["Authorized layout<br/>[layout.tsx]"]
  node_home["Home page<br/>[page.tsx]"]
  node_auth_forms["Auth forms<br/>[SignInForm.tsx]"]
  node_modal_manager["Modal manager<br/>[ModalManager.tsx]"]
  node_modal_state["Modal state"]
  node_root_layout["Root layout<br/>[layout.tsx]"]
end

subgraph group_actions["Server actions"]
  node_auth_actions["Auth actions<br/>[auth.ts]"]
  node_validation["Input validation"]
  node_error_handling["Error conversion<br/>[errorHandler.ts]"]
end

subgraph group_auth["Authentication service"]
  node_auth_service["Auth service<br/>[authService.ts]"]
  node_auth_contracts["Auth contracts<br/>[authInterface.ts]"]
end

node_visitor(("Visitor"))
node_clerk["Clerk identity"]
node_profile_result["User profile"]
node_token_result["Session token"]

node_visitor -->|"opens app"| node_public_layout
node_public_layout -->|"renders within"| node_root_layout
node_root_layout -->|"renders"| node_modal_manager
node_modal_manager -->|"reads state"| node_modal_state
node_modal_manager -->|"renders by view"| node_auth_forms
node_authorized_layout -->|"wraps page"| node_home
node_auth_actions -->|"validates input"| node_validation
node_auth_actions -->|"invokes"| node_auth_service
node_auth_actions -->|"converts errors"| node_error_handling
node_auth_service -->|"manages identity"| node_clerk
node_auth_service -->|"returns profile"| node_profile_result
node_auth_service -->|"returns token"| node_token_result

click node_public_layout "https://github.com/manish166/authnext/blob/main/src/app/(unAuthorised)/layout.tsx"
click node_authorized_layout "https://github.com/manish166/authnext/blob/main/src/app/(authorised)/layout.tsx"
click node_home "https://github.com/manish166/authnext/blob/main/src/app/(authorised)/home/page.tsx"
click node_auth_forms "https://github.com/manish166/authnext/blob/main/src/app/components/molecules/SignInForm.tsx"
click node_modal_manager "https://github.com/manish166/authnext/blob/main/src/app/components/molecules/ModalManager.tsx"
click node_modal_state "https://github.com/manish166/authnext/blob/main/src/app/store/useAuthModalStore.ts"
click node_root_layout "https://github.com/manish166/authnext/blob/main/src/app/layout.tsx"
click node_auth_actions "https://github.com/manish166/authnext/blob/main/src/app/actions/auth.ts"
click node_validation "https://github.com/manish166/authnext/blob/main/src/validationSchemas.ts"
click node_error_handling "https://github.com/manish166/authnext/blob/main/src/app/lib/errorHandler.ts"
click node_auth_service "https://github.com/manish166/authnext/blob/main/src/bff/auth/authService.ts"
click node_auth_contracts "https://github.com/manish166/authnext/blob/main/src/bff/auth/authInterface.ts"

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_public_layout,node_authorized_layout,node_home,node_auth_forms,node_modal_manager,node_modal_state,node_root_layout,node_profile_result toneBlue
class node_auth_actions,node_validation,node_error_handling toneAmber
class node_auth_service,node_auth_contracts toneMint
class node_visitor,node_clerk,node_token_result toneIndigo
```

## Components

### User experience

- [Public layout](https://github.com/manish166/authnext/blob/main/src/app/(unAuthorised)/layout.tsx): `src/app/(unAuthorised)/layout.tsx`
- [Authorized layout](https://github.com/manish166/authnext/blob/main/src/app/(authorised)/layout.tsx): `src/app/(authorised)/layout.tsx`
- [Home page](https://github.com/manish166/authnext/blob/main/src/app/(authorised)/home/page.tsx): `src/app/(authorised)/home/page.tsx`
- [Auth forms](https://github.com/manish166/authnext/blob/main/src/app/components/molecules/SignInForm.tsx): `src/app/components/molecules/SignInForm.tsx`
- [Modal manager](https://github.com/manish166/authnext/blob/main/src/app/components/molecules/ModalManager.tsx): `src/app/components/molecules/ModalManager.tsx`
- [Modal state](https://github.com/manish166/authnext/blob/main/src/app/store/useAuthModalStore.ts): `src/app/store/useAuthModalStore.ts`
- [Root layout](https://github.com/manish166/authnext/blob/main/src/app/layout.tsx): `src/app/layout.tsx`

### Server actions

- [Auth actions](https://github.com/manish166/authnext/blob/main/src/app/actions/auth.ts): `src/app/actions/auth.ts`
- [Input validation](https://github.com/manish166/authnext/blob/main/src/validationSchemas.ts): `src/validationSchemas.ts`
- [Error conversion](https://github.com/manish166/authnext/blob/main/src/app/lib/errorHandler.ts): `src/app/lib/errorHandler.ts`

### Authentication service

- [Auth service](https://github.com/manish166/authnext/blob/main/src/bff/auth/authService.ts): `src/bff/auth/authService.ts`
- [Auth contracts](https://github.com/manish166/authnext/blob/main/src/bff/auth/authInterface.ts): `src/bff/auth/authInterface.ts`

### Other components

- **Visitor**
- **Clerk identity**
- **User profile**
- **Session token**

## Connections

- Visitor → Public layout: opens app
- Public layout → Root layout: renders within
- Root layout → Modal manager: renders
- Modal manager → Modal state: reads state
- Modal manager → Auth forms: renders by view
- Authorized layout → Home page: wraps page
- Auth actions → Input validation: validates input
- Auth actions → Auth service: invokes
- Auth actions → Error conversion: converts errors
- Auth service → Clerk identity: manages identity
- Auth service → User profile: returns profile
- Auth service → Session token: returns token
