# opabinia9/tcghub architecture

> Architecture diagram of the GitHub repository opabinia9/tcghub, 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/opabinia9/tcghub
- Repository: https://github.com/opabinia9/tcghub

## Overview

This repository is a small web authentication application. A visitor can navigate from the front-end landing page to login or account-creation pages; the sampled front-end code only confirms those navigation links, not form submission or account creation. The backend exposes login and protected routes: login validates credentials against in-memory sample users and returns a signed access token, while the protected route verifies a JWT before responding. Other front-end pages are present in the tree, but their behavior and wiring could not be confirmed from the sampled source.

Main entry points: [`apps/backend/src/routes/api/v1/auth.ts`](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/routes/api/v1/auth.ts) (Auth routes), [`apps/backend/src/persistence/user_reposistory.ts`](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/user_reposistory.ts) (User repository), [`apps/backend/src/index.ts`](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/index.ts) (Fastify server), [`apps/FRONT-END/script.js`](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/script.js) (Page navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web front end"]
  node_landing["Landing page<br/>[index.html]"]
  node_navigation["Page navigation<br/>[script.js]"]
  node_login_page["Login page<br/>[login.html]"]
  node_account_page["Create account page"]
  node_app_page["App page<br/>[app.html]"]
  node_cards_page["Cards page<br/>[cards.html]"]
  node_decks_page["Decks page<br/>[decks.html]"]
end

subgraph group_backend["Authentication API"]
  node_server["Fastify server<br/>[index.ts]"]
  node_auth_routes["Auth routes<br/>[auth.ts]"]
  node_login_schema["Login schema<br/>[routeschemas.ts]"]
  node_auth_controller["Auth controller<br/>[authController.ts]"]
  node_jwt_decorator["JWT verifier<br/>[jwtDecorator.ts]"]
  node_jwt_plugin["JWT plugin"]
end

subgraph group_domain["User lookup"]
  node_facade["User facade<br/>[facade.ts]"]
  node_user_repository["User repository"]
  node_user_store[("In-memory users")]
  node_repository_base["Repository base<br/>[reposistory.ts]"]
  node_user_types["User type<br/>[types.ts]"]
  node_not_found["Not-found error<br/>[notFoundError.ts]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens"| node_landing
node_landing -->|"uses"| node_navigation
node_navigation -->|"navigates"| node_login_page
node_navigation -->|"navigates"| node_account_page
node_visitor -->|"opens"| node_app_page
node_visitor -->|"opens"| node_cards_page
node_visitor -->|"opens"| node_decks_page
node_server -->|"registers"| node_auth_routes
node_server -->|"registers"| node_jwt_plugin
node_server -->|"registers"| node_jwt_decorator
node_auth_routes -->|"validates with"| node_login_schema
node_auth_routes -->|"dispatches to"| node_auth_controller
node_auth_routes -->|"guards with"| node_jwt_decorator
node_auth_controller -->|"looks up user"| node_facade
node_facade -->|"queries"| node_user_repository
node_user_repository -->|"reads"| node_user_store
node_user_repository -->|"extends"| node_repository_base
node_user_repository -->|"uses type"| node_user_types
node_facade -->|"throws"| node_not_found
node_auth_controller -->|"signs token"| node_jwt_plugin
node_jwt_decorator -->|"verifies token"| node_jwt_plugin

click node_landing "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/index.html"
click node_navigation "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/script.js"
click node_login_page "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/login.html"
click node_account_page "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/create-account.html"
click node_app_page "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/app.html"
click node_cards_page "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/cards.html"
click node_decks_page "https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/decks.html"
click node_server "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/index.ts"
click node_auth_routes "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/routes/api/v1/auth.ts"
click node_login_schema "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/routes/api/v1/routeschemas.ts"
click node_auth_controller "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/controllers/authController.ts"
click node_jwt_decorator "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/decorators/jwtDecorator.ts"
click node_facade "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/services/facade.ts"
click node_user_repository "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/user_reposistory.ts"
click node_user_store "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/user_reposistory.ts"
click node_repository_base "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/reposistory.ts"
click node_user_types "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/types.ts"
click node_not_found "https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/errortypes/notFoundError.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_landing,node_navigation,node_login_page,node_account_page,node_app_page,node_cards_page,node_decks_page toneBlue
class node_server,node_auth_routes,node_login_schema,node_auth_controller,node_jwt_decorator,node_jwt_plugin toneAmber
class node_facade,node_user_repository,node_user_store,node_repository_base,node_user_types,node_not_found toneMint
class node_visitor toneIndigo
```

## Components

### Web front end

- [Landing page](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/index.html): `apps/FRONT-END/index.html`
- [Page navigation](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/script.js): `apps/FRONT-END/script.js`
- [Login page](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/login.html): `apps/FRONT-END/login.html`
- [Create account page](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/create-account.html): `apps/FRONT-END/create-account.html`
- [App page](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/app.html): `apps/FRONT-END/app.html`
- [Cards page](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/cards.html): `apps/FRONT-END/cards.html`
- [Decks page](https://github.com/opabinia9/tcghub/blob/main/apps/FRONT-END/decks.html): `apps/FRONT-END/decks.html`

### Authentication API

- [Fastify server](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/index.ts): `apps/backend/src/index.ts`
- [Auth routes](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/routes/api/v1/auth.ts): `apps/backend/src/routes/api/v1/auth.ts`
- [Login schema](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/routes/api/v1/routeschemas.ts): `apps/backend/src/routes/api/v1/routeschemas.ts`
- [Auth controller](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/controllers/authController.ts): `apps/backend/src/controllers/authController.ts`
- [JWT verifier](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/decorators/jwtDecorator.ts): `apps/backend/src/decorators/jwtDecorator.ts`
- **JWT plugin**

### User lookup

- [User facade](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/services/facade.ts): `apps/backend/src/services/facade.ts`
- [User repository](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/user_reposistory.ts): `apps/backend/src/persistence/user_reposistory.ts`
- [In-memory users](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/user_reposistory.ts): `apps/backend/src/persistence/user_reposistory.ts`
- [Repository base](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/reposistory.ts): `apps/backend/src/persistence/reposistory.ts`
- [User type](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/persistence/types.ts): `apps/backend/src/persistence/types.ts`
- [Not-found error](https://github.com/opabinia9/tcghub/blob/main/apps/backend/src/errortypes/notFoundError.ts): `apps/backend/src/errortypes/notFoundError.ts`

### Other components

- **Visitor**

## Connections

- Visitor → Landing page: opens
- Landing page → Page navigation: uses
- Page navigation → Login page: navigates
- Page navigation → Create account page: navigates
- Visitor → App page: opens
- Visitor → Cards page: opens
- Visitor → Decks page: opens
- Fastify server → Auth routes: registers
- Fastify server → JWT plugin: registers
- Fastify server → JWT verifier: registers
- Auth routes → Login schema: validates with
- Auth routes → Auth controller: dispatches to
- Auth routes → JWT verifier: guards with
- Auth controller → User facade: looks up user
- User facade → User repository: queries
- User repository → In-memory users: reads
- User repository → Repository base: extends
- User repository → User type: uses type
- User facade → Not-found error: throws
- Auth controller → JWT plugin: signs token
- JWT verifier → JWT plugin: verifies token
