# trchopan/firebase-auth architecture

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

- Interactive diagram: https://gitdiagram.com/trchopan/firebase-auth
- Repository: https://github.com/trchopan/firebase-auth

## Overview

Firebase Auth is a small Rust runtime library that verifies Firebase ID tokens and integrates that verification with Axum and Actix request extraction. The main flow is a protected request carrying a bearer token, framework-specific extraction, token verification against cached Google public keys, and delivery of decoded claims as FirebaseUser. The library also refreshes its key cache and supports custom claim shapes through generic verification. The excerpts show the core and both adapters; examples document usage but are not separate runtime components.

Main entry points: [`firebase-auth/src/firebase_auth.rs`](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/firebase_auth.rs) (Firebase verifier), [`firebase-auth/src/actix_feature.rs`](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/actix_feature.rs) (Actix extractor), [`firebase-auth/src/axum_feature.rs`](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/axum_feature.rs) (Axum extractor), [`firebase-auth/src/structs.rs`](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/structs.rs) (Claims and JWK types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_framework["Framework adapters"]
  node_actix["Actix extractor<br/>[actix_feature.rs]"]
  node_axum["Axum extractor<br/>[axum_feature.rs]"]
end

subgraph group_verification["Token verification"]
  node_auth["Firebase verifier<br/>[firebase_auth.rs]"]
end

subgraph group_models["Claims and keys"]
  node_claims["Claims and JWK types<br/>[structs.rs]"]
end

node_client(("API caller"))
node_google["Google JWK endpoint"]
node_handler(("Protected handler"))

node_client -->|"sends bearer token"| node_actix
node_client -->|"sends bearer token"| node_axum
node_actix -->|"verifies token"| node_auth
node_axum -->|"verifies token"| node_auth
node_auth -->|"fetches JWKs"| node_google
node_auth -->|"uses key types"| node_claims
node_actix -->|"provides FirebaseUser"| node_handler
node_axum -->|"provides FirebaseUser"| node_handler

click node_actix "https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/actix_feature.rs"
click node_axum "https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/axum_feature.rs"
click node_auth "https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/firebase_auth.rs"
click node_claims "https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/structs.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_actix,node_axum toneBlue
class node_auth toneAmber
class node_claims,node_client,node_handler toneMint
class node_google toneIndigo
```

## Components

### Framework adapters

- [Actix extractor](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/actix_feature.rs): `firebase-auth/src/actix_feature.rs`
- [Axum extractor](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/axum_feature.rs): `firebase-auth/src/axum_feature.rs`

### Token verification

- [Firebase verifier](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/firebase_auth.rs): `firebase-auth/src/firebase_auth.rs`

### Claims and keys

- [Claims and JWK types](https://github.com/trchopan/firebase-auth/blob/main/firebase-auth/src/structs.rs): `firebase-auth/src/structs.rs`

### Other components

- **API caller**
- **Google JWK endpoint**
- **Protected handler**

## Connections

- API caller → Actix extractor: sends bearer token (evidence: `README.md`)
- API caller → Axum extractor: sends bearer token (evidence: `README.md`)
- Actix extractor → Firebase verifier: verifies token (evidence: `firebase-auth/src/actix_feature.rs`)
- Axum extractor → Firebase verifier: verifies token (evidence: `firebase-auth/src/axum_feature.rs`)
- Firebase verifier → Google JWK endpoint: fetches JWKs (evidence: `firebase-auth/src/firebase_auth.rs`)
- Firebase verifier → Claims and JWK types: uses key types (evidence: `firebase-auth/src/firebase_auth.rs`)
- Actix extractor → Protected handler: provides FirebaseUser (evidence: `README.md`)
- Axum extractor → Protected handler: provides FirebaseUser (evidence: `README.md`)
