# sahilbehera6531/authsphere architecture

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

- Interactive diagram: https://gitdiagram.com/sahilbehera6531/authsphere
- Repository: https://github.com/sahilbehera6531/authsphere

## Overview

AuthSphere is a REST backend for identity, authorization, user administration, and memberships. Users register or log in through the API, receive JWT and refresh-token credentials, and use protected endpoints for profiles and subscriptions; administrators manage users, roles, and plans. The graph shows the API-to-service workflow and the documented security and persistence layers. Several controller and service links are supported by the source index; unsampled implementation details are not asserted, and Redis is shown as an optional documented capability.

Main entry points: [`src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java`](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java) (Authentication Service), [`src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java`](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java) (Membership Service), [`src/main/java/com/sahil/authsphere/repository/UserRepository.java`](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/repository/UserRepository.java) (Data Repositories), [`src/main/java/com/sahil/authsphere/controller/AuthController.java`](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/AuthController.java) (Authentication API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_auth_api["Authentication API"]
  node_user_api["User API"]
  node_admin_api["Admin API"]
  node_membership_api["Membership API"]
  node_swagger["API Documentation<br/>[OpenApiConfig.java]"]
  node_errors["Error Handling"]
end

subgraph group_identity["Identity and Security"]
  node_auth_service["Authentication Service"]
  node_refresh_service["Refresh Token Service"]
  node_jwt["JWT Service<br/>[JwtService.java]"]
  node_security["Request Security"]
  node_security_config["Security Configuration"]
end

subgraph group_users["User Administration"]
  node_user_service["User Service"]
  node_user_domain["User Domain<br/>[User.java]"]
end

subgraph group_membership["Memberships"]
  node_membership_service["Membership Service"]
  node_membership_domain["Membership Domain<br/>[Membership.java]"]
end

subgraph group_data["Persistence"]
  node_repositories["Data Repositories"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis Cache")]
end

node_client(("API Client"))

node_client -->|"submits credentials"| node_auth_api
node_client -->|"manages profile"| node_user_api
node_client -->|"manages subscription"| node_membership_api
node_auth_api -->|"delegates auth"| node_auth_service
node_user_api -->|"delegates user operations"| node_user_service
node_admin_api -->|"delegates administration"| node_user_service
node_membership_api -->|"delegates membership"| node_membership_service
node_auth_service -->|"issues tokens"| node_jwt
node_auth_service -->|"rotates tokens"| node_refresh_service
node_security_config -.->|"configures requests"| node_security
node_security -.->|"validates JWT"| node_jwt
node_auth_service -->|"accesses users"| node_repositories
node_membership_service -->|"accesses membership data"| node_repositories
node_repositories -->|"persists records"| node_postgres
node_membership_service -->|"manages membership state"| node_membership_domain
node_auth_service -->|"creates accounts"| node_user_domain
node_client -->|"views API docs"| node_swagger
node_client -.->|"receives API errors"| node_errors
node_membership_service -.->|"may use caching"| node_redis

click node_auth_api "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/AuthController.java"
click node_user_api "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/UserController.java"
click node_admin_api "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/AdminController.java"
click node_membership_api "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/MembershipController.java"
click node_auth_service "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java"
click node_refresh_service "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/RefreshTokenServiceImpl.java"
click node_jwt "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/security/JwtService.java"
click node_security "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/security/JwtAuthenticationFilter.java"
click node_security_config "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/config/SecurityConfig.java"
click node_user_service "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/UserServiceImpl.java"
click node_membership_service "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java"
click node_membership_domain "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/entity/Membership.java"
click node_user_domain "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/entity/User.java"
click node_repositories "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/repository/UserRepository.java"
click node_swagger "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/config/OpenApiConfig.java"
click node_errors "https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/exception/GlobalExceptionHandler.java"

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_auth_api,node_user_api,node_admin_api,node_membership_api,node_swagger,node_errors,node_client toneBlue
class node_auth_service,node_refresh_service,node_jwt,node_security,node_security_config toneAmber
class node_user_service,node_user_domain toneMint
class node_membership_service,node_membership_domain toneRose
class node_repositories,node_postgres,node_redis toneIndigo
```

## Components

### REST API

- [Authentication API](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/AuthController.java): `src/main/java/com/sahil/authsphere/controller/AuthController.java`
- [User API](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/UserController.java): `src/main/java/com/sahil/authsphere/controller/UserController.java`
- [Admin API](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/AdminController.java): `src/main/java/com/sahil/authsphere/controller/AdminController.java`
- [Membership API](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/controller/MembershipController.java): `src/main/java/com/sahil/authsphere/controller/MembershipController.java`
- [API Documentation](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/config/OpenApiConfig.java): `src/main/java/com/sahil/authsphere/config/OpenApiConfig.java`
- [Error Handling](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/exception/GlobalExceptionHandler.java): `src/main/java/com/sahil/authsphere/exception/GlobalExceptionHandler.java`

### Identity and Security

- [Authentication Service](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java): `src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java`
- [Refresh Token Service](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/RefreshTokenServiceImpl.java): `src/main/java/com/sahil/authsphere/service/impl/RefreshTokenServiceImpl.java`
- [JWT Service](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/security/JwtService.java): `src/main/java/com/sahil/authsphere/security/JwtService.java`
- [Request Security](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/security/JwtAuthenticationFilter.java): `src/main/java/com/sahil/authsphere/security/JwtAuthenticationFilter.java`
- [Security Configuration](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/config/SecurityConfig.java): `src/main/java/com/sahil/authsphere/config/SecurityConfig.java`

### User Administration

- [User Service](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/UserServiceImpl.java): `src/main/java/com/sahil/authsphere/service/impl/UserServiceImpl.java`
- [User Domain](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/entity/User.java): `src/main/java/com/sahil/authsphere/entity/User.java`

### Memberships

- [Membership Service](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java): `src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java`
- [Membership Domain](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/entity/Membership.java): `src/main/java/com/sahil/authsphere/entity/Membership.java`

### Persistence

- [Data Repositories](https://github.com/sahilbehera6531/authsphere/blob/main/src/main/java/com/sahil/authsphere/repository/UserRepository.java): `src/main/java/com/sahil/authsphere/repository/UserRepository.java`
- **PostgreSQL**
- **Redis Cache**

### Other components

- **API Client**

## Connections

- API Client → Authentication API: submits credentials (evidence: `README.md`)
- API Client → User API: manages profile (evidence: `README.md`)
- API Client → Membership API: manages subscription (evidence: `README.md`)
- Authentication API → Authentication Service: delegates auth (evidence: `src/main/java/com/sahil/authsphere/controller/AuthController.java`)
- User API → User Service: delegates user operations (evidence: `src/main/java/com/sahil/authsphere/controller/UserController.java`)
- Admin API → User Service: delegates administration (evidence: `src/main/java/com/sahil/authsphere/controller/AdminController.java`)
- Membership API → Membership Service: delegates membership (evidence: `src/main/java/com/sahil/authsphere/controller/MembershipController.java`)
- Authentication Service → JWT Service: issues tokens (evidence: `src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java`)
- Authentication Service → Refresh Token Service: rotates tokens (evidence: `src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java`)
- Security Configuration → Request Security: configures requests
- Request Security → JWT Service: validates JWT
- Authentication Service → Data Repositories: accesses users (evidence: `src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java`)
- Membership Service → Data Repositories: accesses membership data (evidence: `src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java`)
- Data Repositories → PostgreSQL: persists records (evidence: `README.md`)
- Membership Service → Membership Domain: manages membership state (evidence: `src/main/java/com/sahil/authsphere/service/impl/MembershipServiceImpl.java`)
- Authentication Service → User Domain: creates accounts (evidence: `src/main/java/com/sahil/authsphere/service/impl/AuthServiceImpl.java`)
- API Client → API Documentation: views API docs (evidence: `README.md`)
- API Client → Error Handling: receives API errors
- Membership Service → Redis Cache: may use caching (evidence: `README.md`)
