# sleepyash13/forge architecture

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

- Interactive diagram: https://gitdiagram.com/sleepyash13/forge
- Repository: https://github.com/sleepyash13/forge

## Overview

Forge is a React and ASP.NET Core authentication system. The principal workflow is browser login or registration through credentialed, CSRF-protected API calls, followed by JWT-cookie authentication and protected profile access. Backend application services validate credentials and profiles, while repositories persist users in SQL Server. The sampled code clearly supports cookie authentication, anti-forgery validation, protected routes, and profile/password management; the README mentions RBAC, but no role-specific implementation was sampled.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend Experience"]
  node_react_app["React Application<br/>[App.tsx]"]
  node_auth_state["Authentication State<br/>[AuthContext.tsx]"]
  node_protected_routes["Protected Routing<br/>[AppRoutes.tsx]"]
  node_frontend_auth["Auth Client<br/>[authService.ts]"]
  node_frontend_users["User Client<br/>[userService.ts]"]
end

subgraph group_api["API Security"]
  node_api_client["Credentialed API Client<br/>[apiClient.ts]"]
  node_auth_controller["Auth Controller<br/>[AuthController.cs]"]
  node_user_controller["User Controller<br/>[UserController.cs]"]
  node_security_pipeline["Security Pipeline<br/>[Program.cs]"]
  node_antiforgery["Anti-Forgery Protection<br/>[Program.cs]"]
end

subgraph group_application["Application Services"]
  node_auth_service["Authentication Service<br/>[AuthServices.cs]"]
  node_user_service["User Profile Service<br/>[UserService.cs]"]
  node_jwt_service["JWT Token Service<br/>[JwtTokenService.cs]"]
end

subgraph group_persistence["Identity Persistence"]
  node_user_repository["User Repository<br/>[UserRepository.cs]"]
  node_user_entity["User Entity<br/>[User.cs]"]
  node_forge_db[("Forge SQL Database<br/>[ForgeDbContext.cs]")]
end

node_browser_user(("Browser User"))

node_browser_user -->|"uses"| node_react_app
node_react_app -->|"hosts"| node_auth_state
node_auth_state -->|"loads identity"| node_frontend_auth
node_auth_state -->|"provides auth"| node_protected_routes
node_frontend_auth -->|"invokes"| node_api_client
node_frontend_users -->|"invokes"| node_api_client
node_api_client -->|"sends auth requests"| node_auth_controller
node_api_client -->|"sends user requests"| node_user_controller
node_api_client -->|"sends CSRF header"| node_antiforgery
node_auth_controller -->|"validates tokens"| node_antiforgery
node_security_pipeline -->|"configures"| node_antiforgery
node_security_pipeline -->|"maps endpoints"| node_auth_controller
node_security_pipeline -->|"maps endpoints"| node_user_controller
node_auth_controller -->|"dispatches auth"| node_auth_service
node_auth_controller -->|"changes password"| node_user_service
node_user_controller -->|"dispatches profiles"| node_user_service
node_auth_service -->|"reads and writes"| node_user_repository
node_auth_service -->|"generates token"| node_jwt_service
node_user_service -->|"reads and writes"| node_user_repository
node_user_repository -->|"queries users"| node_forge_db
node_user_entity -->|"maps identity"| node_forge_db
node_security_pipeline -->|"configures validation"| node_jwt_service

click node_react_app "https://github.com/sleepyash13/forge/blob/main/frontend/src/App.tsx"
click node_auth_state "https://github.com/sleepyash13/forge/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_protected_routes "https://github.com/sleepyash13/forge/blob/main/frontend/src/routes/AppRoutes.tsx"
click node_frontend_auth "https://github.com/sleepyash13/forge/blob/main/frontend/src/services/authService.ts"
click node_frontend_users "https://github.com/sleepyash13/forge/blob/main/frontend/src/services/userService.ts"
click node_api_client "https://github.com/sleepyash13/forge/blob/main/frontend/src/services/apiClient.ts"
click node_auth_controller "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Controllers/AuthController.cs"
click node_user_controller "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Controllers/UserController.cs"
click node_security_pipeline "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Program.cs"
click node_antiforgery "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Program.cs"
click node_auth_service "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Application/Services/Auth/AuthServices.cs"
click node_user_service "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Application/Services/Auth/UserService.cs"
click node_jwt_service "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Infrastructure/Authentication/JwtTokenService.cs"
click node_user_repository "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Infrastructure/Repositories/UserRepository.cs"
click node_user_entity "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Domain/Entities/User.cs"
click node_forge_db "https://github.com/sleepyash13/forge/blob/main/backend/Forge.Infrastructure/Persistence/ForgeDbContext.cs"

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_react_app,node_auth_state,node_protected_routes,node_frontend_auth,node_frontend_users,node_browser_user toneBlue
class node_api_client,node_auth_controller,node_user_controller,node_security_pipeline,node_antiforgery toneAmber
class node_auth_service,node_user_service,node_jwt_service toneMint
class node_user_repository,node_user_entity,node_forge_db toneRose
```

## Components

### Frontend Experience

- [React Application](https://github.com/sleepyash13/forge/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Authentication State](https://github.com/sleepyash13/forge/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`
- [Protected Routing](https://github.com/sleepyash13/forge/blob/main/frontend/src/routes/AppRoutes.tsx): `frontend/src/routes/AppRoutes.tsx`
- [Auth Client](https://github.com/sleepyash13/forge/blob/main/frontend/src/services/authService.ts): `frontend/src/services/authService.ts`
- [User Client](https://github.com/sleepyash13/forge/blob/main/frontend/src/services/userService.ts): `frontend/src/services/userService.ts`

### API Security

- [Credentialed API Client](https://github.com/sleepyash13/forge/blob/main/frontend/src/services/apiClient.ts): `frontend/src/services/apiClient.ts`
- [Auth Controller](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Controllers/AuthController.cs): `backend/Forge.Api/Controllers/AuthController.cs`
- [User Controller](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Controllers/UserController.cs): `backend/Forge.Api/Controllers/UserController.cs`
- [Security Pipeline](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Program.cs): `backend/Forge.Api/Program.cs`
- [Anti-Forgery Protection](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Api/Program.cs): `backend/Forge.Api/Program.cs`

### Application Services

- [Authentication Service](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Application/Services/Auth/AuthServices.cs): `backend/Forge.Application/Services/Auth/AuthServices.cs`
- [User Profile Service](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Application/Services/Auth/UserService.cs): `backend/Forge.Application/Services/Auth/UserService.cs`
- [JWT Token Service](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Infrastructure/Authentication/JwtTokenService.cs): `backend/Forge.Infrastructure/Authentication/JwtTokenService.cs`

### Identity Persistence

- [User Repository](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Infrastructure/Repositories/UserRepository.cs): `backend/Forge.Infrastructure/Repositories/UserRepository.cs`
- [User Entity](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Domain/Entities/User.cs): `backend/Forge.Domain/Entities/User.cs`
- [Forge SQL Database](https://github.com/sleepyash13/forge/blob/main/backend/Forge.Infrastructure/Persistence/ForgeDbContext.cs): `backend/Forge.Infrastructure/Persistence/ForgeDbContext.cs`

### Other components

- **Browser User**

## Connections

- Browser User → React Application: uses
- React Application → Authentication State: hosts
- Authentication State → Auth Client: loads identity
- Authentication State → Protected Routing: provides auth
- Auth Client → Credentialed API Client: invokes
- User Client → Credentialed API Client: invokes
- Credentialed API Client → Auth Controller: sends auth requests
- Credentialed API Client → User Controller: sends user requests
- Credentialed API Client → Anti-Forgery Protection: sends CSRF header
- Auth Controller → Anti-Forgery Protection: validates tokens
- Security Pipeline → Anti-Forgery Protection: configures
- Security Pipeline → Auth Controller: maps endpoints
- Security Pipeline → User Controller: maps endpoints
- Auth Controller → Authentication Service: dispatches auth
- Auth Controller → User Profile Service: changes password
- User Controller → User Profile Service: dispatches profiles
- Authentication Service → User Repository: reads and writes
- Authentication Service → JWT Token Service: generates token
- User Profile Service → User Repository: reads and writes
- User Repository → Forge SQL Database: queries users
- User Entity → Forge SQL Database: maps identity
- Security Pipeline → JWT Token Service: configures validation
