# saadkhan10412/tokentrail architecture

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

- Interactive diagram: https://gitdiagram.com/saadkhan10412/tokentrail
- Repository: https://github.com/saadkhan10412/tokentrail

## Overview

TokenTrail is an AI discovery and learning product: users browse articles, snippets, and AI model listings, with profiles and bookmarks for personalization. The backend exposes these capabilities through FastAPI and persists content and user activity; separate automation fetches and enriches feed content and generates snippets. The README is empty, and frontend-to-API wiring was not shown, so that relationship is left unverified rather than asserted.

Main entry points: [`backend/app/main.py`](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/main.py) (API entry), [`backend/app/models/content.py`](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/content.py) (Content models), [`backend/app/routers/snippets.py`](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/snippets.py) (Snippet routes), [`backend/app/routers/models.py`](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/models.py) (Model routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend_app["Application UI<br/>[app.js]"]
  node_frontend_explore["Explore UI<br/>[explore.js]"]
  node_frontend_snippets["Snippet UI<br/>[snippets.js]"]
  node_frontend_auth["Authentication UI<br/>[auth.js]"]
  node_frontend_guard["Auth guard<br/>[auth-guard.js]"]
  node_frontend_progress["Progress UI<br/>[progress.js]"]
end

subgraph group_api["API and identity"]
  node_api_entry["API entry<br/>[main.py]"]
  node_user_routes["User routes<br/>[users.py]"]
  node_profile_routes["Profile routes<br/>[profiles.py]"]
  node_auth_service["Auth service<br/>[auth.py]"]
  node_auth_dependency["Auth dependency<br/>[dependencies.py]"]
end

subgraph group_content["Content discovery"]
  node_article_routes["Article routes<br/>[articles.py]"]
  node_category_routes["Category routes<br/>[categories.py]"]
  node_source_routes["Source routes<br/>[sources.py]"]
  node_snippet_routes["Snippet routes<br/>[snippets.py]"]
  node_model_routes["Model routes<br/>[models.py]"]
  node_model_service["Model service<br/>[models.py]"]
  node_profile_service["Profile service<br/>[profile.py]"]
  node_content_models[("Content models<br/>[content.py]")]
  node_user_models[("User models<br/>[users.py]")]
  node_activity_models[("Activity models<br/>[activity.py]")]
  node_ingestion_models[("Ingestion models<br/>[ingestion.py]")]
  node_taxonomy_models[("Taxonomy models<br/>[taxonomy.py]")]
  node_database[("Database access<br/>[database.py]")]
end

subgraph group_automation["Content automation"]
  node_feed_fetcher["Feed fetcher<br/>[feeds.py]"]
  node_article_ingest["Article ingestion<br/>[ingest.py]"]
  node_snippet_generation["Snippet generation"]
  node_ai_processor["Article AI processing<br/>[processor.py]"]
  node_snippet_generator["AI snippet generator"]
  node_ai_client["AI client<br/>[client.py]"]
end

node_reader(("Reader"))
node_supabase{{"Supabase Auth"}}
node_openrouter{{"OpenRouter"}}
node_github_fetch{{"GitHub data"}}

node_reader -->|"uses"| node_frontend_app
node_frontend_app -.->|"requests API"| node_api_entry
node_api_entry -->|"registers"| node_user_routes
node_api_entry -->|"registers"| node_profile_routes
node_api_entry -->|"registers"| node_article_routes
node_api_entry -->|"registers"| node_category_routes
node_api_entry -->|"registers"| node_source_routes
node_api_entry -->|"registers"| node_snippet_routes
node_api_entry -->|"registers"| node_model_routes
node_user_routes -->|"calls"| node_auth_service
node_auth_service -->|"sends auth requests"| node_supabase
node_auth_dependency -->|"verifies token"| node_auth_service
node_profile_routes -->|"calls"| node_profile_service
node_profile_routes -->|"requires user"| node_auth_dependency
node_snippet_routes -->|"requires user"| node_auth_dependency
node_model_routes -->|"uses dependency"| node_auth_dependency
node_article_routes -->|"queries"| node_content_models
node_category_routes -->|"queries"| node_content_models
node_source_routes -->|"queries"| node_content_models
node_snippet_routes -->|"queries snippets"| node_content_models
node_snippet_routes -->|"queries bookmarks"| node_user_models
node_model_routes -->|"queries models"| node_content_models
node_model_routes -->|"queries user data"| node_user_models
node_model_routes -->|"calls"| node_model_service
node_profile_service -->|"uses"| node_user_models
node_article_routes -->|"gets session"| node_database
node_snippet_routes -->|"gets session"| node_database
node_article_ingest -->|"fetches feeds"| node_feed_fetcher
node_article_ingest -->|"processes articles"| node_ai_processor
node_article_ingest -->|"stores articles"| node_content_models
node_article_ingest -->|"opens session"| node_database
node_feed_fetcher -->|"reads sources"| node_content_models
node_feed_fetcher -->|"opens session"| node_database
node_feed_fetcher -.->|"uses GitHub data"| node_github_fetch
node_ai_processor -->|"generates JSON"| node_ai_client
node_snippet_generation -->|"generates snippets"| node_snippet_generator
node_snippet_generator -->|"generates JSON"| node_ai_client
node_ai_client -->|"sends prompts"| node_openrouter
node_snippet_generation -->|"reads and writes"| node_content_models
node_snippet_generation -->|"opens session"| node_database

click node_frontend_app "https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/app.js"
click node_frontend_explore "https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/explore.js"
click node_frontend_snippets "https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/snippets.js"
click node_frontend_auth "https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/auth.js"
click node_frontend_guard "https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/auth-guard.js"
click node_frontend_progress "https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/progress.js"
click node_api_entry "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/main.py"
click node_user_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/users.py"
click node_profile_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/profiles.py"
click node_auth_service "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/auth.py"
click node_auth_dependency "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/utils/dependencies.py"
click node_article_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/articles.py"
click node_category_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/categories.py"
click node_source_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/sources.py"
click node_snippet_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/snippets.py"
click node_model_routes "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/models.py"
click node_model_service "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/models.py"
click node_profile_service "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/profile.py"
click node_content_models "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/content.py"
click node_user_models "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/users.py"
click node_activity_models "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/activity.py"
click node_ingestion_models "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/ingestion.py"
click node_taxonomy_models "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/taxonomy.py"
click node_database "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/database.py"
click node_feed_fetcher "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/automation/feeds.py"
click node_article_ingest "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/automation/ingest.py"
click node_snippet_generation "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/automation/generate_snippets.py"
click node_ai_processor "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/ai/processor.py"
click node_snippet_generator "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/ai/snippet_generator.py"
click node_ai_client "https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/ai/client.py"

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_frontend_app,node_frontend_explore,node_frontend_snippets,node_frontend_auth,node_frontend_guard,node_frontend_progress toneBlue
class node_api_entry,node_user_routes,node_profile_routes,node_auth_service,node_auth_dependency toneAmber
class node_article_routes,node_category_routes,node_source_routes,node_snippet_routes,node_model_routes,node_model_service,node_profile_service,node_content_models,node_user_models,node_activity_models,node_ingestion_models,node_taxonomy_models,node_database,node_openrouter toneMint
class node_feed_fetcher,node_article_ingest,node_snippet_generation,node_ai_processor,node_snippet_generator,node_ai_client toneRose
class node_reader,node_supabase,node_github_fetch toneIndigo
```

## Components

### Web experience

- [Application UI](https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Explore UI](https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/explore.js): `frontend/js/explore.js`
- [Snippet UI](https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/snippets.js): `frontend/js/snippets.js`
- [Authentication UI](https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/auth.js): `frontend/js/auth.js`
- [Auth guard](https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/auth-guard.js): `frontend/js/auth-guard.js`
- [Progress UI](https://github.com/saadkhan10412/tokentrail/blob/main/frontend/js/progress.js): `frontend/js/progress.js`

### API and identity

- [API entry](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/main.py): `backend/app/main.py`
- [User routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/users.py): `backend/app/routers/users.py`
- [Profile routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/profiles.py): `backend/app/routers/profiles.py`
- [Auth service](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/auth.py): `backend/app/services/auth.py`
- [Auth dependency](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/utils/dependencies.py): `backend/app/utils/dependencies.py`

### Content discovery

- [Article routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/articles.py): `backend/app/routers/articles.py`
- [Category routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/categories.py): `backend/app/routers/categories.py`
- [Source routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/sources.py): `backend/app/routers/sources.py`
- [Snippet routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/snippets.py): `backend/app/routers/snippets.py`
- [Model routes](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/routers/models.py): `backend/app/routers/models.py`
- [Model service](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/models.py): `backend/app/services/models.py`
- [Profile service](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/profile.py): `backend/app/services/profile.py`
- [Content models](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/content.py): `backend/app/models/content.py`
- [User models](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/users.py): `backend/app/models/users.py`
- [Activity models](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/activity.py): `backend/app/models/activity.py`
- [Ingestion models](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/ingestion.py): `backend/app/models/ingestion.py`
- [Taxonomy models](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/models/taxonomy.py): `backend/app/models/taxonomy.py`
- [Database access](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/database.py): `backend/app/database.py`

### Content automation

- [Feed fetcher](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/automation/feeds.py): `backend/app/automation/feeds.py`
- [Article ingestion](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/automation/ingest.py): `backend/app/automation/ingest.py`
- [Snippet generation](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/automation/generate_snippets.py): `backend/app/automation/generate_snippets.py`
- [Article AI processing](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/ai/processor.py): `backend/app/services/ai/processor.py`
- [AI snippet generator](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/ai/snippet_generator.py): `backend/app/services/ai/snippet_generator.py`
- [AI client](https://github.com/saadkhan10412/tokentrail/blob/main/backend/app/services/ai/client.py): `backend/app/services/ai/client.py`

### Other components

- **Reader**
- **Supabase Auth**
- **OpenRouter**
- **GitHub data**

## Connections

- Reader → Application UI: uses
- Application UI → API entry: requests API
- API entry → User routes: registers (evidence: `backend/app/main.py`)
- API entry → Profile routes: registers (evidence: `backend/app/main.py`)
- API entry → Article routes: registers (evidence: `backend/app/main.py`)
- API entry → Category routes: registers (evidence: `backend/app/main.py`)
- API entry → Source routes: registers (evidence: `backend/app/main.py`)
- API entry → Snippet routes: registers (evidence: `backend/app/main.py`)
- API entry → Model routes: registers (evidence: `backend/app/main.py`)
- User routes → Auth service: calls (evidence: `backend/app/routers/users.py`)
- Auth service → Supabase Auth: sends auth requests (evidence: `backend/app/services/auth.py`)
- Auth dependency → Auth service: verifies token (evidence: `backend/app/utils/dependencies.py`)
- Profile routes → Profile service: calls (evidence: `backend/app/routers/profiles.py`)
- Profile routes → Auth dependency: requires user (evidence: `backend/app/routers/profiles.py`)
- Snippet routes → Auth dependency: requires user (evidence: `backend/app/routers/snippets.py`)
- Model routes → Auth dependency: uses dependency (evidence: `backend/app/routers/models.py`)
- Article routes → Content models: queries (evidence: `backend/app/routers/articles.py`)
- Category routes → Content models: queries (evidence: `backend/app/routers/categories.py`)
- Source routes → Content models: queries (evidence: `backend/app/routers/sources.py`)
- Snippet routes → Content models: queries snippets (evidence: `backend/app/routers/snippets.py`)
- Snippet routes → User models: queries bookmarks (evidence: `backend/app/routers/snippets.py`)
- Model routes → Content models: queries models (evidence: `backend/app/routers/models.py`)
- Model routes → User models: queries user data (evidence: `backend/app/routers/models.py`)
- Model routes → Model service: calls (evidence: `backend/app/routers/models.py`)
- Profile service → User models: uses (evidence: `backend/app/services/profile.py`)
- Article routes → Database access: gets session (evidence: `backend/app/routers/articles.py`)
- Snippet routes → Database access: gets session (evidence: `backend/app/routers/snippets.py`)
- Article ingestion → Feed fetcher: fetches feeds (evidence: `backend/app/automation/ingest.py`)
- Article ingestion → Article AI processing: processes articles (evidence: `backend/app/automation/ingest.py`)
- Article ingestion → Content models: stores articles (evidence: `backend/app/automation/ingest.py`)
- Article ingestion → Database access: opens session (evidence: `backend/app/automation/ingest.py`)
- Feed fetcher → Content models: reads sources (evidence: `backend/app/automation/feeds.py`)
- Feed fetcher → Database access: opens session (evidence: `backend/app/automation/feeds.py`)
- Feed fetcher → GitHub data: uses GitHub data
- Article AI processing → AI client: generates JSON (evidence: `backend/app/services/ai/processor.py`)
- Snippet generation → AI snippet generator: generates snippets (evidence: `backend/app/automation/generate_snippets.py`)
- AI snippet generator → AI client: generates JSON (evidence: `backend/app/services/ai/snippet_generator.py`)
- AI client → OpenRouter: sends prompts (evidence: `backend/app/services/ai/client.py`)
- Snippet generation → Content models: reads and writes (evidence: `backend/app/automation/generate_snippets.py`)
- Snippet generation → Database access: opens session (evidence: `backend/app/automation/generate_snippets.py`)
