# tasfers/tsf-auth-mod architecture

> Architecture diagram of the GitHub repository tasfers/tsf-auth-mod, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tasfers/tsf-auth-mod
- Repository: https://github.com/tasfers/tsf-auth-mod

## Overview

#### Purpose and Runtime
`tsf-auth` is a client-side Fabric mod for Minecraft 1.21.11 that manages multiple game accounts and authenticates them against a private TSF authorization service. It runs in the Minecraft client on Java 21, using Fabric Loader/Fabric API and Mixin hooks to alter client login, multiplayer, and player behavior.

Core registration and runtime metadata are in `src/main/resources/fabric.mod.json` and `src/main/resources/tsfauth.mixins.json`.

#### Mod Bootstrap and Launch Integration
`TsfAuthClient` is the likely Fabric client initializer and establishes client-side services/UI integration. `TsfAuthPreLaunch` provides an earlier lifecycle point, likely for authentication-library setup before normal client startup.

Relevant paths:
- `src/main/java/com/tasfers/tsfauth/TsfAuthClient.java`
- `src/main/java/com/tasfers/tsfauth/TsfAuthPreLaunch.java`
- `src/main/resources/fabric.mod.json`

#### Account State and Switching
`AccountManager` is the central account-domain component: it owns saved/active account state and coordinates account changes. `AccountListScreen` is the in-game account-switcher UI, allowing users to add, select, and remove accounts without restarting Minecraft. `AuthScreen` handles the interactive authorization flow for an account.

Relevant paths:
- `src/main/java/com/tasfers/tsfauth/AccountManager.java`
- `src/main/java/com/tasfers/tsfauth/AccountListScreen.java`
- `src/main/java/com/tasfers/tsfauth/AuthScreen.java`

#### Authentication Service Boundary
The mod delegates identity validation to the external private `tsf-auth` server. `AuthServerStatusChecker` isolates availability/status checks, while `LocalAuthProxyServer` indicates a local HTTP/proxy boundary used to bridge Minecraft/Authlib-compatible requests to the private auth service. This separates game-client integration from remote authorization protocol behavior.

Relevant paths:
- `src/main/java/com/tasfers/tsfauth/AuthServerStatusChecker.java`
- `src/main/java/com/tasfers/tsfauth/LocalAuthProxyServer.java`
- `src/main/java/com/tasfers/tsfauth/AuthScreen.java`

#### Authlib and Session Continuity
`AuthlibInjectorManager` configures or controls Authlib Injector compatibility so Minecraft can use the TSF authentication ecosystem rather than only the default account flow. `TokenRefresher` runs background validation/refresh work to keep active sessions valid during long-running client use.

Primary flow: active account selected → Authlib integration/proxy routes authentication → token is retained by account/session state → periodic refresher validates or renews it with the authorization service.

Relevant paths:
- `src/main/java/com/tasfers/tsfauth/AuthlibInjectorManager.java`
- `src/main/java/com/tasfers/tsfauth/TokenRefresher.java`
- `src/main/java/com/tasfers/tsfauth/AccountManager.java`

#### Client Hooks and Multiplayer Behavior
Mixins connect the account/auth system to Minecraft internals. Player and user accessors enable controlled identity/session replacement; multiplayer and server-info mixins integrate account-aware behavior into server navigation; disconnect handling can react to authentication/session failures.

Relevant paths:
- `src/main/java/com/tasfers/tsfauth/mixin/AbstractClientPlayerMixin.java`
- `src/main/java/com/tasfers/tsfauth/mixin/MultiplayerScreenMixin.java`
- `src/main/java/com/tasfers/tsfauth/mixin/DisconnectedScreenMixin.java`

#### Skins and Secret Handling
`SkinFetcher` provides a separate external-fetch boundary for player skin data. `StringDecrypter` supports runtime recovery of protected strings, likely including service endpoints or protocol-sensitive constants. Build-time string obfuscation is implemented as a custom Gradle task.

Relevant paths:
- `src/main/java/com/tasfers/tsfauth/SkinFetcher.java`
- `src/main/java/com/tasfers/tsfauth/security/StringDecrypter.java`
- `buildSrc/src/main/java/com/tasfers/obfuscator/StringObfuscatorTask.java`

Main entry points: [`src/main/java/com/tasfers/tsfauth/AccountManager.java`](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AccountManager.java) (Account manager), [`src/main/java/com/tasfers/tsfauth/TsfAuthClient.java`](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TsfAuthClient.java) (Client bootstrap), [`src/main/java/com/tasfers/tsfauth/AuthScreen.java`](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthScreen.java) (Authorization screen), [`src/main/java/com/tasfers/tsfauth/TokenRefresher.java`](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TokenRefresher.java) (Token refresher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Fabric Client Runtime"]
  node_mod_metadata["Fabric mod metadata<br/>Fabric descriptor<br/>[fabric.mod.json]"]
  node_prelaunch["Pre-launch setup<br/>Fabric pre-launch entrypoint"]
  node_client_bootstrap["Client bootstrap<br/>Fabric client initializer<br/>[TsfAuthClient.java]"]
end

subgraph group_accounts["Accounts &amp; UI"]
  node_account_manager["Account manager<br/>account state coordinator"]
  node_account_list["Account list<br/>Minecraft screen"]
  node_auth_screen["Authorization screen<br/>Minecraft screen<br/>[AuthScreen.java]"]
end

subgraph group_auth["Authentication Integration"]
  node_authlib_manager["Authlib Injector manager<br/>Authlib integration"]
  node_local_proxy{{"Local auth proxy<br/>local HTTP proxy"}}
  node_status_checker["Auth server status<br/>availability checker"]
  node_token_refresher["Token refresher<br/>background session worker"]
  node_skin_fetcher["Skin fetcher<br/>external data client<br/>[SkinFetcher.java]"]
  node_string_decrypter["String decrypter<br/>runtime secret utility"]
end

subgraph group_hooks["Minecraft Hooks"]
  node_minecraft_mixins["Client behavior mixins<br/>Mixin hooks"]
end

node_auth_service{{"Private TSF auth service<br/>external authorization service"}}
node_minecraft_client["Minecraft client<br/>game runtime"]
node_string_obfuscator["String obfuscator task<br/>Gradle build task"]

node_mod_metadata -->|"registers"| node_prelaunch
node_mod_metadata -->|"registers"| node_client_bootstrap
node_client_bootstrap -->|"initializes"| node_account_manager
node_client_bootstrap -->|"integrates UI"| node_account_list
node_account_list -->|"changes active account"| node_account_manager
node_auth_screen -->|"stores authorization"| node_account_manager
node_auth_screen -->|"checks availability"| node_status_checker
node_status_checker -->|"checks"| node_auth_service
node_auth_screen -->|"uses auth bridge"| node_local_proxy
node_account_manager -->|"applies active account"| node_authlib_manager
node_authlib_manager -->|"routes requests through"| node_local_proxy
node_local_proxy -->|"forwards authentication"| node_auth_service
node_token_refresher -->|"maintains active session"| node_account_manager
node_token_refresher -->|"validates or renews token"| node_auth_service
node_minecraft_mixins -->|"reads or replaces identity"| node_account_manager
node_minecraft_mixins -->|"injects behavior"| node_minecraft_client
node_skin_fetcher -->|"fetches skin data"| node_auth_service
node_string_decrypter -.->|"reveals connection constants"| node_auth_service
node_string_obfuscator -.->|"produces protected strings for"| node_string_decrypter
node_client_bootstrap -->|"starts"| node_token_refresher

click node_mod_metadata "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/resources/fabric.mod.json"
click node_prelaunch "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TsfAuthPreLaunch.java"
click node_client_bootstrap "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TsfAuthClient.java"
click node_account_manager "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AccountManager.java"
click node_account_list "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AccountListScreen.java"
click node_auth_screen "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthScreen.java"
click node_authlib_manager "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthlibInjectorManager.java"
click node_local_proxy "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/LocalAuthProxyServer.java"
click node_status_checker "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthServerStatusChecker.java"
click node_token_refresher "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TokenRefresher.java"
click node_skin_fetcher "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/SkinFetcher.java"
click node_string_decrypter "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/security/StringDecrypter.java"
click node_minecraft_mixins "https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/mixin/AbstractClientPlayerMixin.java"
click node_string_obfuscator "https://github.com/tasfers/tsf-auth-mod/blob/main/buildSrc/src/main/java/com/tasfers/obfuscator/StringObfuscatorTask.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_mod_metadata,node_prelaunch,node_client_bootstrap toneBlue
class node_account_manager,node_account_list,node_auth_screen toneAmber
class node_authlib_manager,node_local_proxy,node_status_checker,node_token_refresher,node_skin_fetcher,node_string_decrypter toneMint
class node_minecraft_mixins toneRose
class node_auth_service,node_minecraft_client,node_string_obfuscator toneNeutral
```

## Components

### Fabric Client Runtime

- [Fabric mod metadata](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/resources/fabric.mod.json): Fabric descriptor · Registers client and pre-launch entrypoints plus mixins. · `src/main/resources/fabric.mod.json`
- [Pre-launch setup](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TsfAuthPreLaunch.java): Fabric pre-launch entrypoint · `src/main/java/com/tasfers/tsfauth/TsfAuthPreLaunch.java`
- [Client bootstrap](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TsfAuthClient.java): Fabric client initializer · `src/main/java/com/tasfers/tsfauth/TsfAuthClient.java`

### Accounts & UI

- [Account manager](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AccountManager.java): account state coordinator · Owns saved and active account state. · `src/main/java/com/tasfers/tsfauth/AccountManager.java`
- [Account list](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AccountListScreen.java): Minecraft screen · Adds, selects, and removes accounts in-game. · `src/main/java/com/tasfers/tsfauth/AccountListScreen.java`
- [Authorization screen](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthScreen.java): Minecraft screen · `src/main/java/com/tasfers/tsfauth/AuthScreen.java`

### Authentication Integration

- [Authlib Injector manager](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthlibInjectorManager.java): Authlib integration · Configures TSF-compatible Minecraft authentication. · `src/main/java/com/tasfers/tsfauth/AuthlibInjectorManager.java`
- [Local auth proxy](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/LocalAuthProxyServer.java): local HTTP proxy · Bridges Authlib-compatible requests to the private service. · `src/main/java/com/tasfers/tsfauth/LocalAuthProxyServer.java`
- [Auth server status](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/AuthServerStatusChecker.java): availability checker · `src/main/java/com/tasfers/tsfauth/AuthServerStatusChecker.java`
- [Token refresher](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/TokenRefresher.java): background session worker · Periodically validates or renews active tokens. · `src/main/java/com/tasfers/tsfauth/TokenRefresher.java`
- [Skin fetcher](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/SkinFetcher.java): external data client · `src/main/java/com/tasfers/tsfauth/SkinFetcher.java`
- [String decrypter](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/security/StringDecrypter.java): runtime secret utility · Recovers protected service or protocol strings. · `src/main/java/com/tasfers/tsfauth/security/StringDecrypter.java`

### Minecraft Hooks

- [Client behavior mixins](https://github.com/tasfers/tsf-auth-mod/blob/main/src/main/java/com/tasfers/tsfauth/mixin/AbstractClientPlayerMixin.java): Mixin hooks · Inject account-aware player, multiplayer, and disconnect behavior. · `src/main/java/com/tasfers/tsfauth/mixin/AbstractClientPlayerMixin.java`

### Other components

- **Private TSF auth service**: external authorization service
- **Minecraft client**: game runtime
- [String obfuscator task](https://github.com/tasfers/tsf-auth-mod/blob/main/buildSrc/src/main/java/com/tasfers/obfuscator/StringObfuscatorTask.java): Gradle build task · Obfuscates protected strings at build time. · `buildSrc/src/main/java/com/tasfers/obfuscator/StringObfuscatorTask.java`

## Connections

- Fabric mod metadata → Pre-launch setup: registers
- Fabric mod metadata → Client bootstrap: registers
- Client bootstrap → Account manager: initializes
- Client bootstrap → Account list: integrates UI
- Account list → Account manager: changes active account
- Authorization screen → Account manager: stores authorization
- Authorization screen → Auth server status: checks availability
- Auth server status → Private TSF auth service: checks
- Authorization screen → Local auth proxy: uses auth bridge
- Account manager → Authlib Injector manager: applies active account
- Authlib Injector manager → Local auth proxy: routes requests through
- Local auth proxy → Private TSF auth service: forwards authentication
- Token refresher → Account manager: maintains active session
- Token refresher → Private TSF auth service: validates or renews token
- Client behavior mixins → Account manager: reads or replaces identity
- Client behavior mixins → Minecraft client: injects behavior
- Skin fetcher → Private TSF auth service: fetches skin data
- String decrypter → Private TSF auth service: reveals connection constants
- String obfuscator task → String decrypter: produces protected strings for
- Client bootstrap → Token refresher: starts
