# tsinjonantosoa/nexusai-platform architecture

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

- Interactive diagram: https://gitdiagram.com/tsinjonantosoa/nexusai-platform
- Repository: https://github.com/tsinjonantosoa/nexusai-platform

## Overview

NexusAI is a bilingual AI-character chat demonstration: users browse characters, access chat/conversation screens, and manage accounts and wallet purchases. The current backend is a modular foundation, not a functioning AI-chat or payment-fulfillment system: identity, wallet ledger, product catalogue, and Sandbox Checkout are implemented, while AI calls, conversation persistence, webhooks, and wallet fulfillment remain future work. The frontend supports mock and API modes. Edges below follow explicit router registration/imports and shown calls; unsampled feature internals and browser-to-API wiring are not asserted.

Main entry points: [`backend/app/main.py`](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/routeTree.gen.ts`](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/routeTree.gen.ts) (SPA routes), [`backend/app/db/models.py`](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/db/models.py) (PostgreSQL records), [`frontend/src/services/api.ts`](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["SPA routes<br/>[routeTree.gen.ts]"]
  node_shell["Application shell<br/>[Shell.tsx]"]
  node_auth_ui["Auth screens<br/>[Auth.tsx]"]
  node_discovery["Character discovery<br/>[Discovery.tsx]"]
  node_conversations["Chat and conversations<br/>[Conversations.tsx]"]
  node_settings_ui["Settings<br/>[Settings.tsx]"]
  node_billing_ui["Billing screens<br/>[Billing.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_mock_service["Mock service<br/>[mock.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth_router["Identity endpoints<br/>[router.py]"]
  node_auth_service["Session lifecycle<br/>[service.py]"]
  node_auth_dependencies["Session and CSRF checks<br/>[dependencies.py]"]
  node_users_router["Current user<br/>[router.py]"]
end

subgraph group_commerce["Billing and wallet"]
  node_wallet_router["Wallet queries<br/>[router.py]"]
  node_wallet_service["Wallet ledger operations<br/>[service.py]"]
  node_billing_router["Billing endpoints<br/>[router.py]"]
  node_checkout_service["Checkout and orders<br/>[checkout.py]"]
  node_catalogue["Product catalogue<br/>[catalogue.py]"]
  node_stripe["Stripe Sandbox gateway<br/>[stripe_client.py]"]
end

subgraph group_platform["API and persistence"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_health_admin["Health and admin<br/>[health.py]"]
  node_configuration["Runtime configuration<br/>[config.py]"]
  node_database_session["Database sessions<br/>[session.py]"]
  node_database[("PostgreSQL records<br/>[models.py]")]
end

node_visitor(("Visitor"))
node_stripe_service{{"Stripe"}}

node_visitor -->|"uses"| node_frontend
node_frontend -.->|"renders"| node_shell
node_frontend -.->|"routes to"| node_auth_ui
node_frontend -.->|"routes to"| node_discovery
node_frontend -.->|"routes to"| node_conversations
node_frontend -.->|"routes to"| node_settings_ui
node_frontend -.->|"routes to"| node_billing_ui
node_auth_ui -.->|"requests"| node_api_client
node_billing_ui -.->|"requests"| node_api_client
node_conversations -.->|"requests"| node_api_client
node_discovery -.->|"requests"| node_api_client
node_api_client -.->|"calls API"| node_fastapi
node_visitor -.->|"uses demo"| node_mock_service
node_fastapi -->|"registers"| node_health_admin
node_fastapi -->|"registers"| node_auth_router
node_fastapi -->|"registers"| node_users_router
node_fastapi -->|"registers"| node_wallet_router
node_fastapi -->|"registers"| node_billing_router
node_fastapi -->|"loads settings"| node_configuration
node_fastapi -->|"builds sessions"| node_database_session
node_health_admin -->|"checks database"| node_database_session
node_database_session -.->|"queries"| node_database
node_auth_router -->|"issues sessions"| node_auth_service
node_auth_router -->|"creates wallet"| node_wallet_service
node_auth_router -->|"checks access"| node_auth_dependencies
node_auth_service -->|"persists sessions"| node_database
node_auth_dependencies -->|"reads sessions"| node_database
node_users_router -->|"formats user"| node_auth_service
node_users_router -->|"requires user"| node_auth_dependencies
node_wallet_router -->|"reads wallet ledger"| node_database
node_wallet_router -->|"requires user"| node_auth_dependencies
node_wallet_service -->|"updates ledger"| node_database
node_billing_router -->|"creates orders"| node_checkout_service
node_billing_router -->|"lists products"| node_database
node_billing_router -->|"requires user"| node_auth_dependencies
node_checkout_service -->|"uses products"| node_catalogue
node_checkout_service -->|"requests checkout"| node_stripe
node_stripe -->|"calls"| node_stripe_service
node_checkout_service -.->|"stores orders"| node_database

click node_frontend "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/routeTree.gen.ts"
click node_shell "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/components/layout/Shell.tsx"
click node_auth_ui "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Auth.tsx"
click node_discovery "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Discovery.tsx"
click node_conversations "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Conversations.tsx"
click node_settings_ui "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Settings.tsx"
click node_billing_ui "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Billing.tsx"
click node_api_client "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/services/api.ts"
click node_mock_service "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/services/mock.ts"
click node_fastapi "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/main.py"
click node_health_admin "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/api/health.py"
click node_configuration "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/core/config.py"
click node_database_session "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/db/session.py"
click node_database "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/db/models.py"
click node_auth_router "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/auth/router.py"
click node_auth_service "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/auth/service.py"
click node_auth_dependencies "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/auth/dependencies.py"
click node_users_router "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/users/router.py"
click node_wallet_router "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/wallet/router.py"
click node_wallet_service "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/wallet/service.py"
click node_billing_router "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/router.py"
click node_checkout_service "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/checkout.py"
click node_catalogue "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/catalogue.py"
click node_stripe "https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/stripe_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,node_shell,node_auth_ui,node_discovery,node_conversations,node_settings_ui,node_billing_ui,node_api_client,node_mock_service toneBlue
class node_auth_router,node_auth_service,node_auth_dependencies,node_users_router toneAmber
class node_wallet_router,node_wallet_service,node_billing_router,node_checkout_service,node_catalogue,node_stripe toneMint
class node_fastapi,node_health_admin,node_configuration,node_database_session,node_database toneRose
class node_visitor,node_stripe_service toneIndigo
```

## Components

### Web experience

- [SPA routes](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/routeTree.gen.ts): `frontend/src/routeTree.gen.ts`
- [Application shell](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/components/layout/Shell.tsx): `frontend/src/components/layout/Shell.tsx`
- [Auth screens](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Auth.tsx): `frontend/src/features/Auth.tsx`
- [Character discovery](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Discovery.tsx): `frontend/src/features/Discovery.tsx`
- [Chat and conversations](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Conversations.tsx): `frontend/src/features/Conversations.tsx`
- [Settings](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Settings.tsx): `frontend/src/features/Settings.tsx`
- [Billing screens](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/features/Billing.tsx): `frontend/src/features/Billing.tsx`
- [API client](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Mock service](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/frontend/src/services/mock.ts): `frontend/src/services/mock.ts`

### Identity and access

- [Identity endpoints](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/auth/router.py): `backend/app/auth/router.py`
- [Session lifecycle](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/auth/service.py): `backend/app/auth/service.py`
- [Session and CSRF checks](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`
- [Current user](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/users/router.py): `backend/app/users/router.py`

### Billing and wallet

- [Wallet queries](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/wallet/router.py): `backend/app/wallet/router.py`
- [Wallet ledger operations](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/wallet/service.py): `backend/app/wallet/service.py`
- [Billing endpoints](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/router.py): `backend/app/billing/router.py`
- [Checkout and orders](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/checkout.py): `backend/app/billing/checkout.py`
- [Product catalogue](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/catalogue.py): `backend/app/billing/catalogue.py`
- [Stripe Sandbox gateway](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/billing/stripe_client.py): `backend/app/billing/stripe_client.py`

### API and persistence

- [FastAPI application](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/main.py): `backend/app/main.py`
- [Health and admin](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/api/health.py): `backend/app/api/health.py`
- [Runtime configuration](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Database sessions](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [PostgreSQL records](https://github.com/tsinjonantosoa/nexusai-platform/blob/main/backend/app/db/models.py): `backend/app/db/models.py`

### Other components

- **Visitor**
- **Stripe**

## Connections

- Visitor → SPA routes: uses (evidence: `frontend/src/routeTree.gen.ts`)
- SPA routes → Application shell: renders
- SPA routes → Auth screens: routes to
- SPA routes → Character discovery: routes to
- SPA routes → Chat and conversations: routes to
- SPA routes → Settings: routes to
- SPA routes → Billing screens: routes to
- Auth screens → API client: requests
- Billing screens → API client: requests
- Chat and conversations → API client: requests
- Character discovery → API client: requests
- API client → FastAPI application: calls API
- Visitor → Mock service: uses demo
- FastAPI application → Health and admin: registers (evidence: `backend/app/main.py`)
- FastAPI application → Identity endpoints: registers (evidence: `backend/app/main.py`)
- FastAPI application → Current user: registers (evidence: `backend/app/main.py`)
- FastAPI application → Wallet queries: registers (evidence: `backend/app/main.py`)
- FastAPI application → Billing endpoints: registers (evidence: `backend/app/main.py`)
- FastAPI application → Runtime configuration: loads settings (evidence: `backend/app/main.py`)
- FastAPI application → Database sessions: builds sessions (evidence: `backend/app/main.py`)
- Health and admin → Database sessions: checks database (evidence: `backend/app/api/health.py`)
- Database sessions → PostgreSQL records: queries
- Identity endpoints → Session lifecycle: issues sessions (evidence: `backend/app/auth/router.py`)
- Identity endpoints → Wallet ledger operations: creates wallet (evidence: `backend/app/auth/router.py`)
- Identity endpoints → Session and CSRF checks: checks access (evidence: `backend/app/auth/router.py`)
- Session lifecycle → PostgreSQL records: persists sessions (evidence: `backend/app/auth/service.py`)
- Session and CSRF checks → PostgreSQL records: reads sessions (evidence: `backend/app/auth/dependencies.py`)
- Current user → Session lifecycle: formats user (evidence: `backend/app/users/router.py`)
- Current user → Session and CSRF checks: requires user (evidence: `backend/app/users/router.py`)
- Wallet queries → PostgreSQL records: reads wallet ledger (evidence: `backend/app/wallet/router.py`)
- Wallet queries → Session and CSRF checks: requires user (evidence: `backend/app/wallet/router.py`)
- Wallet ledger operations → PostgreSQL records: updates ledger (evidence: `backend/app/wallet/service.py`)
- Billing endpoints → Checkout and orders: creates orders (evidence: `backend/app/billing/router.py`)
- Billing endpoints → PostgreSQL records: lists products (evidence: `backend/app/billing/router.py`)
- Billing endpoints → Session and CSRF checks: requires user (evidence: `backend/app/billing/router.py`)
- Checkout and orders → Product catalogue: uses products (evidence: `backend/app/billing/checkout.py`)
- Checkout and orders → Stripe Sandbox gateway: requests checkout (evidence: `backend/app/billing/checkout.py`)
- Stripe Sandbox gateway → Stripe: calls (evidence: `backend/app/billing/stripe_client.py`)
- Checkout and orders → PostgreSQL records: stores orders (evidence: `backend/app/billing/checkout.py`)
