# elvismutinda/mkr-sports-client-portal architecture

> Architecture diagram of the GitHub repository elvismutinda/mkr-sports-client-portal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elvismutinda/mkr-sports-client-portal
- Repository: https://github.com/elvismutinda/mkr-sports-client-portal

## Overview

MKR Sports Client Portal is a sports participation portal for players and teams. Users can register and verify accounts, discover matches, teams, tournaments, and turfs, then manage squads and participate in competitions. The sampled match detail page fetches match data from its API; squad management fetches roster and team data. API handlers use a shared Drizzle database, and authentication also uses that database. The README provides no product detail, so several listed capabilities are represented from the file tree; their unsampled wiring is not asserted.

Main entry points: [`lib/db/db.ts`](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/db/db.ts) (PostgreSQL data), [`app/(landing)/matches/[id]/page.tsx`](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/%5Bid%5D/page.tsx) (Match details), [`app/app/dashboard/page.tsx`](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/dashboard/page.tsx) (Dashboard page), [`app/app/squad/page.tsx`](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/squad/page.tsx) (Squad management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Accounts"]
  node_register_ui["Registration form<br/>[RegisterForm.tsx]"]
  node_register_action["Registration action<br/>[actions.ts]"]
  node_auth_service["Authentication<br/>[auth.ts]"]
  node_auth_pages["Login and verification"]
end

subgraph group_discovery["Sports discovery"]
  node_match_detail["Match details<br/>[page.tsx]"]
  node_match_form["Match registration"]
  node_match_actions["Match actions<br/>[actions.ts]"]
  node_match_api["Match API"]
  node_team_discovery["Team discovery"]
  node_turf_ui["Turf discovery"]
  node_turf_api["Turf API<br/>[route.ts]"]
end

subgraph group_competition["Competition"]
  node_challenge_ui["Team challenge"]
  node_challenge_api["Challenge API<br/>[route.ts]"]
  node_tournament_ui["Tournament listings"]
  node_tournament_api["Tournament API<br/>[route.ts]"]
  node_tournament_register["Tournament registration<br/>[route.ts]"]
end

subgraph group_player["Player portal"]
  node_dashboard_page["Dashboard page<br/>[page.tsx]"]
  node_dashboard_view["Dashboard view<br/>[Dasboard.tsx]"]
  node_squad_page["Squad management<br/>[page.tsx]"]
  node_roster_api["Player roster API<br/>[route.ts]"]
  node_team_mine_api["My team API<br/>[route.ts]"]
  node_settings_page["Player settings<br/>[page.tsx]"]
end

subgraph group_platform["Platform services"]
  node_database[("PostgreSQL data<br/>[db.ts]")]
  node_schema["Sports data schema<br/>[schema.ts]"]
  node_mail["Email delivery<br/>[mail.ts]"]
  node_mpesa_callback["M-Pesa callback<br/>[route.ts]"]
end

node_player_actor(("Player"))

node_player_actor -->|"registers"| node_register_ui
node_register_ui -->|"submits to"| node_register_action
node_player_actor -->|"signs in"| node_auth_pages
node_auth_service -->|"uses"| node_database
node_auth_service -->|"adapts"| node_schema
node_player_actor -->|"views"| node_match_detail
node_match_detail -->|"fetches match"| node_match_api
node_match_detail -->|"renders"| node_match_form
node_match_form -->|"submits to"| node_match_actions
node_match_api -->|"queries"| node_database
node_player_actor -.->|"discovers teams"| node_team_discovery
node_player_actor -.->|"challenges team"| node_challenge_ui
node_challenge_api -->|"authenticates"| node_auth_service
node_challenge_api -->|"reads and updates"| node_database
node_player_actor -.->|"explores tournaments"| node_tournament_ui
node_tournament_ui -.->|"loads listings"| node_tournament_api
node_tournament_api -->|"queries"| node_database
node_tournament_register -.->|"uses"| node_database
node_player_actor -.->|"searches turfs"| node_turf_ui
node_turf_ui -.->|"loads results"| node_turf_api
node_turf_api -->|"queries"| node_database
node_player_actor -.->|"opens dashboard"| node_dashboard_page
node_dashboard_page -->|"renders"| node_dashboard_view
node_dashboard_page -->|"queries"| node_database
node_player_actor -.->|"manages squad"| node_squad_page
node_squad_page -->|"fetches roster"| node_roster_api
node_squad_page -->|"fetches team"| node_team_mine_api
node_roster_api -.->|"uses"| node_database
node_team_mine_api -.->|"uses"| node_database
node_player_actor -.->|"updates profile"| node_settings_page
node_mpesa_callback -->|"updates payments"| node_database
node_mpesa_callback -->|"sends email"| node_mail
node_database -->|"uses schema"| node_schema

click node_register_ui "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/components/auth/RegisterForm.tsx"
click node_register_action "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(auth)/register/actions.ts"
click node_auth_service "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/auth.ts"
click node_auth_pages "https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(auth)"
click node_match_detail "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/%5Bid%5D/page.tsx"
click node_match_form "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/(components)/RegisterMatchForm.tsx"
click node_match_actions "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/actions.ts"
click node_match_api "https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/api/matches"
click node_team_discovery "https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/teams"
click node_challenge_ui "https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/teams/%5Bid%5D/challenge"
click node_challenge_api "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/challenges/route.ts"
click node_tournament_ui "https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/tournaments"
click node_tournament_api "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/tournaments/route.ts"
click node_tournament_register "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/tournaments/%5Bid%5D/register/route.ts"
click node_turf_ui "https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/turfs"
click node_turf_api "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/turfs/route.ts"
click node_dashboard_page "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/dashboard/page.tsx"
click node_dashboard_view "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/components/Dasboard.tsx"
click node_squad_page "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/squad/page.tsx"
click node_roster_api "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/player/roster/route.ts"
click node_team_mine_api "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/team/mine/route.ts"
click node_settings_page "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/settings/page.tsx"
click node_database "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/db/db.ts"
click node_schema "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/db/schema.ts"
click node_mail "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/mail.ts"
click node_mpesa_callback "https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/mpesa/callback/route.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_register_ui,node_register_action,node_auth_service,node_auth_pages toneBlue
class node_match_detail,node_match_form,node_match_actions,node_match_api,node_team_discovery,node_turf_ui,node_turf_api toneAmber
class node_challenge_ui,node_challenge_api,node_tournament_ui,node_tournament_api,node_tournament_register toneMint
class node_dashboard_page,node_dashboard_view,node_squad_page,node_roster_api,node_team_mine_api,node_settings_page toneRose
class node_database,node_schema,node_mail,node_mpesa_callback,node_player_actor toneIndigo
```

## Components

### Accounts

- [Registration form](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/components/auth/RegisterForm.tsx): `components/auth/RegisterForm.tsx`
- [Registration action](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(auth)/register/actions.ts): `app/(auth)/register/actions.ts`
- [Authentication](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/auth.ts): `auth.ts`
- [Login and verification](https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(auth)): `app/(auth)`

### Sports discovery

- [Match details](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/%5Bid%5D/page.tsx): `app/(landing)/matches/[id]/page.tsx`
- [Match registration](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/(components)/RegisterMatchForm.tsx): `app/(landing)/matches/(components)/RegisterMatchForm.tsx`
- [Match actions](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/(landing)/matches/actions.ts): `app/(landing)/matches/actions.ts`
- [Match API](https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/api/matches): `app/api/matches`
- [Team discovery](https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/teams): `app/(landing)/teams`
- [Turf discovery](https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/turfs): `app/(landing)/turfs`
- [Turf API](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/turfs/route.ts): `app/api/turfs/route.ts`

### Competition

- [Team challenge](https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/teams/%5Bid%5D/challenge): `app/(landing)/teams/[id]/challenge`
- [Challenge API](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/challenges/route.ts): `app/api/challenges/route.ts`
- [Tournament listings](https://github.com/elvismutinda/mkr-sports-client-portal/tree/main/app/(landing)/tournaments): `app/(landing)/tournaments`
- [Tournament API](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/tournaments/route.ts): `app/api/tournaments/route.ts`
- [Tournament registration](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/tournaments/%5Bid%5D/register/route.ts): `app/api/tournaments/[id]/register/route.ts`

### Player portal

- [Dashboard page](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/dashboard/page.tsx): `app/app/dashboard/page.tsx`
- [Dashboard view](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/components/Dasboard.tsx): `components/Dasboard.tsx`
- [Squad management](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/squad/page.tsx): `app/app/squad/page.tsx`
- [Player roster API](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/player/roster/route.ts): `app/api/player/roster/route.ts`
- [My team API](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/team/mine/route.ts): `app/api/team/mine/route.ts`
- [Player settings](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/app/settings/page.tsx): `app/app/settings/page.tsx`

### Platform services

- [PostgreSQL data](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/db/db.ts): `lib/db/db.ts`
- [Sports data schema](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/db/schema.ts): `lib/db/schema.ts`
- [Email delivery](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/lib/mail.ts): `lib/mail.ts`
- [M-Pesa callback](https://github.com/elvismutinda/mkr-sports-client-portal/blob/main/app/api/mpesa/callback/route.ts): `app/api/mpesa/callback/route.ts`

### Other components

- **Player**

## Connections

- Player → Registration form: registers (evidence: `components/auth/RegisterForm.tsx`)
- Registration form → Registration action: submits to (evidence: `components/auth/RegisterForm.tsx`)
- Player → Login and verification: signs in (evidence: `app/(auth)/login/page.tsx`)
- Authentication → PostgreSQL data: uses (evidence: `auth.ts`)
- Authentication → Sports data schema: adapts (evidence: `auth.ts`)
- Player → Match details: views (evidence: `app/(landing)/matches/[id]/page.tsx`)
- Match details → Match API: fetches match (evidence: `app/(landing)/matches/[id]/page.tsx`)
- Match details → Match registration: renders (evidence: `app/(landing)/matches/[id]/page.tsx`)
- Match registration → Match actions: submits to (evidence: `app/(landing)/matches/(components)/RegisterMatchForm.tsx`)
- Match API → PostgreSQL data: queries (evidence: `app/api/matches/route.ts`)
- Player → Team discovery: discovers teams
- Player → Team challenge: challenges team
- Challenge API → Authentication: authenticates (evidence: `app/api/challenges/route.ts`)
- Challenge API → PostgreSQL data: reads and updates (evidence: `app/api/challenges/route.ts`)
- Player → Tournament listings: explores tournaments
- Tournament listings → Tournament API: loads listings
- Tournament API → PostgreSQL data: queries (evidence: `app/api/tournaments/route.ts`)
- Tournament registration → PostgreSQL data: uses
- Player → Turf discovery: searches turfs
- Turf discovery → Turf API: loads results
- Turf API → PostgreSQL data: queries (evidence: `app/api/turfs/route.ts`)
- Player → Dashboard page: opens dashboard
- Dashboard page → Dashboard view: renders (evidence: `app/app/dashboard/page.tsx`)
- Dashboard page → PostgreSQL data: queries (evidence: `app/app/dashboard/page.tsx`)
- Player → Squad management: manages squad
- Squad management → Player roster API: fetches roster (evidence: `app/app/squad/page.tsx`)
- Squad management → My team API: fetches team (evidence: `app/app/squad/page.tsx`)
- Player roster API → PostgreSQL data: uses
- My team API → PostgreSQL data: uses
- Player → Player settings: updates profile
- M-Pesa callback → PostgreSQL data: updates payments (evidence: `app/api/mpesa/callback/route.ts`)
- M-Pesa callback → Email delivery: sends email (evidence: `app/api/mpesa/callback/route.ts`)
- PostgreSQL data → Sports data schema: uses schema (evidence: `lib/db/db.ts`)
