# bambafall19/nav-stats architecture

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

- Interactive diagram: https://gitdiagram.com/bambafall19/nav-stats
- Repository: https://github.com/bambafall19/nav-stats

## Overview

NavéStats is a football results, statistics and prediction platform, with public browsing and user features alongside an admin console. Its central user journey is to explore matches and teams, submit predictions, then follow rankings and community activity. The tree also shows cadet competitions, profiles and social features, match analysis, and notification workflows. Sampled API handlers confirm Supabase access, AI-provider calls, and web-push dispatch; other public and admin capabilities are represented by their source paths, but their internal wiring was not sampled.

Main entry points: [`src/app/api/ai/agent/route.ts`](https://github.com/bambafall19/nav-stats/blob/main/src/app/api/ai/agent/route.ts) (Admin AI agent), [`src/lib/supabase/server.ts`](https://github.com/bambafall19/nav-stats/blob/main/src/lib/supabase/server.ts) (Server data client), [`src/app/api/ai/match-analysis/route.ts`](https://github.com/bambafall19/nav-stats/blob/main/src/app/api/ai/match-analysis/route.ts) (Match analysis API), [`src/app/api/notifications`](https://github.com/bambafall19/nav-stats/tree/main/src/app/api/notifications) (Push and reminders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Football data"]
  node_public_pages["Public pages"]
  node_matches["Match details"]
  node_teams["Team pages<br/>[page.tsx]"]
  node_cadets["Cadet competitions<br/>[page.tsx]"]
  node_rankings["Rankings and stats"]
end

subgraph group_predictions["Predictions and community"]
  node_prediction_pages["Prediction pages"]
  node_community["Community<br/>[page.tsx]"]
end

subgraph group_accounts["User features"]
  node_profile["Profiles<br/>[page.tsx]"]
  node_auth["Authentication"]
  node_notifications_ui["Notification screens<br/>[page.tsx]"]
end

subgraph group_operations["Admin and AI"]
  node_admin["Admin console"]
  node_ai_agent["Admin AI agent<br/>[route.ts]"]
  node_match_ai["Match analysis API<br/>[route.ts]"]
  node_ai_context["AI context builders<br/>[context.ts]"]
  node_ai_provider["xAI client<br/>[xai.ts]"]
end

subgraph group_platform["Data and notifications"]
  node_supabase_server["Server data client<br/>[server.ts]"]
  node_push_routes["Push and reminders"]
  node_push_lib["Web-push service<br/>[webpush.ts]"]
  node_push_subscribe["Push subscription UI"]
end

node_visitor(("Visitor"))
node_member(("Signed-in member"))
node_supabase[("Supabase")]
node_browser_push["Browser push service"]

node_visitor -->|"browses"| node_public_pages
node_member -->|"signs in"| node_auth
node_member -->|"submits predictions"| node_prediction_pages
node_member -->|"participates"| node_community
node_member -->|"views profile"| node_profile
node_member -->|"checks alerts"| node_notifications_ui
node_member -->|"manages push"| node_push_subscribe
node_admin -->|"requests assistance"| node_ai_agent
node_ai_agent -->|"authenticates"| node_supabase_server
node_ai_agent -->|"builds context"| node_ai_context
node_ai_agent -->|"requests response"| node_ai_provider
node_match_ai -->|"reads match data"| node_supabase_server
node_match_ai -->|"requests analysis"| node_ai_provider
node_push_routes -->|"reads and writes"| node_supabase_server
node_push_routes -->|"dispatches push"| node_push_lib
node_push_subscribe -->|"stores subscription"| node_supabase
node_push_lib -->|"sends web push"| node_browser_push
node_supabase_server -->|"queries data"| node_supabase

click node_public_pages "https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)"
click node_matches "https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)/matchs"
click node_teams "https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/equipes/%5Bid%5D/page.tsx"
click node_cadets "https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/cadets/page.tsx"
click node_rankings "https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)/classements"
click node_prediction_pages "https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)/pronostics"
click node_community "https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/communaute/page.tsx"
click node_profile "https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/profil/%5Bid%5D/page.tsx"
click node_auth "https://github.com/bambafall19/nav-stats/tree/main/src/app/auth"
click node_notifications_ui "https://github.com/bambafall19/nav-stats/blob/main/src/app/notifications/page.tsx"
click node_admin "https://github.com/bambafall19/nav-stats/tree/main/src/app/admin"
click node_ai_agent "https://github.com/bambafall19/nav-stats/blob/main/src/app/api/ai/agent/route.ts"
click node_match_ai "https://github.com/bambafall19/nav-stats/blob/main/src/app/api/ai/match-analysis/route.ts"
click node_ai_context "https://github.com/bambafall19/nav-stats/blob/main/src/lib/ai/context.ts"
click node_ai_provider "https://github.com/bambafall19/nav-stats/blob/main/src/lib/ai/xai.ts"
click node_supabase_server "https://github.com/bambafall19/nav-stats/blob/main/src/lib/supabase/server.ts"
click node_push_routes "https://github.com/bambafall19/nav-stats/tree/main/src/app/api/notifications"
click node_push_lib "https://github.com/bambafall19/nav-stats/blob/main/src/lib/push/webpush.ts"
click node_push_subscribe "https://github.com/bambafall19/nav-stats/blob/main/src/components/shared/PushNotificationManager.tsx"

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_public_pages,node_matches,node_teams,node_cadets,node_rankings,node_browser_push toneBlue
class node_prediction_pages,node_community,node_supabase toneAmber
class node_profile,node_auth,node_notifications_ui toneMint
class node_admin,node_ai_agent,node_match_ai,node_ai_context,node_ai_provider toneRose
class node_supabase_server,node_push_routes,node_push_lib,node_push_subscribe,node_visitor,node_member toneIndigo
```

## Components

### Football data

- [Public pages](https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)): `src/app/(public)`
- [Match details](https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)/matchs): `src/app/(public)/matchs`
- [Team pages](https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/equipes/%5Bid%5D/page.tsx): `src/app/(public)/equipes/[id]/page.tsx`
- [Cadet competitions](https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/cadets/page.tsx): `src/app/(public)/cadets/page.tsx`
- [Rankings and stats](https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)/classements): `src/app/(public)/classements`

### Predictions and community

- [Prediction pages](https://github.com/bambafall19/nav-stats/tree/main/src/app/(public)/pronostics): `src/app/(public)/pronostics`
- [Community](https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/communaute/page.tsx): `src/app/(public)/communaute/page.tsx`

### User features

- [Profiles](https://github.com/bambafall19/nav-stats/blob/main/src/app/(public)/profil/%5Bid%5D/page.tsx): `src/app/(public)/profil/[id]/page.tsx`
- [Authentication](https://github.com/bambafall19/nav-stats/tree/main/src/app/auth): `src/app/auth`
- [Notification screens](https://github.com/bambafall19/nav-stats/blob/main/src/app/notifications/page.tsx): `src/app/notifications/page.tsx`

### Admin and AI

- [Admin console](https://github.com/bambafall19/nav-stats/tree/main/src/app/admin): `src/app/admin`
- [Admin AI agent](https://github.com/bambafall19/nav-stats/blob/main/src/app/api/ai/agent/route.ts): `src/app/api/ai/agent/route.ts`
- [Match analysis API](https://github.com/bambafall19/nav-stats/blob/main/src/app/api/ai/match-analysis/route.ts): `src/app/api/ai/match-analysis/route.ts`
- [AI context builders](https://github.com/bambafall19/nav-stats/blob/main/src/lib/ai/context.ts): `src/lib/ai/context.ts`
- [xAI client](https://github.com/bambafall19/nav-stats/blob/main/src/lib/ai/xai.ts): `src/lib/ai/xai.ts`

### Data and notifications

- [Server data client](https://github.com/bambafall19/nav-stats/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Push and reminders](https://github.com/bambafall19/nav-stats/tree/main/src/app/api/notifications): `src/app/api/notifications`
- [Web-push service](https://github.com/bambafall19/nav-stats/blob/main/src/lib/push/webpush.ts): `src/lib/push/webpush.ts`
- [Push subscription UI](https://github.com/bambafall19/nav-stats/blob/main/src/components/shared/PushNotificationManager.tsx): `src/components/shared/PushNotificationManager.tsx`

### Other components

- **Visitor**
- **Signed-in member**
- **Supabase**
- **Browser push service**

## Connections

- Visitor → Public pages: browses
- Signed-in member → Authentication: signs in
- Signed-in member → Prediction pages: submits predictions
- Signed-in member → Community: participates
- Signed-in member → Profiles: views profile
- Signed-in member → Notification screens: checks alerts
- Signed-in member → Push subscription UI: manages push
- Admin console → Admin AI agent: requests assistance
- Admin AI agent → Server data client: authenticates
- Admin AI agent → AI context builders: builds context
- Admin AI agent → xAI client: requests response
- Match analysis API → Server data client: reads match data
- Match analysis API → xAI client: requests analysis
- Push and reminders → Server data client: reads and writes
- Push and reminders → Web-push service: dispatches push
- Push subscription UI → Supabase: stores subscription
- Web-push service → Browser push service: sends web push
- Server data client → Supabase: queries data
