# konatsu13/teman architecture

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

- Interactive diagram: https://gitdiagram.com/konatsu13/teman
- Repository: https://github.com/konatsu13/teman

## Overview

TEMAN is a team-management web app. Members sign in, then use routed workspace features to manage competitions, tasks, calendars, members and notifications, or collaborate in global chat. Feature pages call domain services that access Supabase; chat and AI also use Edge Functions. The README documents AI-query safety and chat capabilities, but several page and function implementations were not sampled, so those links are shown only where documented or evidenced. UI components and shared session handling are included as supporting layers.

Main entry points: [`src/App.tsx`](https://github.com/konatsu13/teman/blob/main/src/App.tsx) (Routes and shell), [`src/lib/supabase.ts`](https://github.com/konatsu13/teman/blob/main/src/lib/supabase.ts) (Supabase client), [`src/services/competitionService.ts`](https://github.com/konatsu13/teman/blob/main/src/services/competitionService.ts) (Competition service), [`src/pages/dashboard/OverviewPage.tsx`](https://github.com/konatsu13/teman/blob/main/src/pages/dashboard/OverviewPage.tsx) (Overview)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace experience"]
  node_app["Routes and shell<br/>[App.tsx]"]
  node_login["Sign in<br/>[LoginPage.tsx]"]
  node_overview["Overview<br/>[OverviewPage.tsx]"]
  node_competitions["Competitions"]
  node_competition_detail["Competition detail"]
  node_tasks["Task management<br/>[MyTasksPage.tsx]"]
  node_calendar["Calendar<br/>[CalendarPage.tsx]"]
  node_members["Member directory<br/>[MembersPage.tsx]"]
  node_notifications["Notifications"]
  node_settings["Settings<br/>[SettingsPage.tsx]"]
end

subgraph group_domain["Domain services"]
  node_competition_service["Competition service"]
  node_task_service["Task service<br/>[taskService.ts]"]
  node_calendar_service["Calendar service<br/>[calendarService.ts]"]
  node_member_service["Member service<br/>[memberService.ts]"]
  node_notification_service["Notification service"]
end

subgraph group_collaboration["Chat and AI"]
  node_chat["Global chat<br/>[GlobalChatPage.tsx]"]
  node_chat_state["Chat synchronization<br/>[useGlobalChat.ts]"]
  node_chat_service["Chat persistence<br/>[chatService.ts]"]
  node_chat_ai["Chat AI function<br/>[index.ts]"]
  node_ai_assistant["AI query assistant"]
  node_ai_service["AI query client<br/>[aiQueryService.ts]"]
  node_ai_function["Safe query function<br/>[index.ts]"]
end

subgraph group_platform["Identity and platform"]
  node_auth_context["Session context<br/>[AuthContext.tsx]"]
  node_auth_service["Authentication service<br/>[authService.ts]"]
  node_auth_hook["Auth hook<br/>[useAuth.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_database_types["Database types<br/>[database.types.ts]"]
end

subgraph group_shared["Shared presentation"]
  node_ui["UI components"]
  node_theme["Theme presets<br/>[theme-presets.ts]"]
  node_formatters["Date and value formatting<br/>[formatters.ts]"]
end

node_member(("Workspace member"))
node_supabase[("Supabase")]

node_member -->|"opens"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_overview
node_app -->|"routes to"| node_competitions
node_app -->|"routes to"| node_competition_detail
node_app -->|"routes to"| node_tasks
node_app -->|"routes to"| node_calendar
node_app -->|"routes to"| node_members
node_app -->|"routes to"| node_notifications
node_app -->|"routes to"| node_settings
node_app -->|"routes to"| node_chat
node_login -.->|"signs in through"| node_auth_context
node_auth_context -->|"loads profile"| node_auth_service
node_auth_context -->|"tracks session"| node_supabase_client
node_auth_hook -->|"reads context"| node_auth_context
node_auth_service -->|"queries"| node_supabase_client
node_supabase_client -->|"connects"| node_supabase
node_overview -->|"loads data"| node_competition_service
node_overview -->|"loads data"| node_task_service
node_competitions -->|"loads data"| node_competition_service
node_competitions -->|"loads data"| node_member_service
node_competitions -->|"loads data"| node_task_service
node_tasks -->|"loads and writes"| node_task_service
node_tasks -->|"loads competitions"| node_competition_service
node_tasks -->|"loads members"| node_member_service
node_calendar -->|"loads events"| node_calendar_service
node_calendar -->|"loads competitions"| node_competition_service
node_members -->|"loads members"| node_member_service
node_competition_service -->|"queries"| node_supabase_client
node_task_service -->|"queries"| node_supabase_client
node_calendar_service -->|"queries"| node_supabase_client
node_member_service -.->|"queries"| node_supabase_client
node_notification_service -->|"queries"| node_supabase_client
node_chat -.->|"synchronizes via"| node_chat_state
node_chat_state -->|"loads messages"| node_chat_service
node_chat_state -.->|"requests AI reply"| node_chat_ai
node_chat_service -->|"persists messages"| node_supabase_client
node_ai_assistant -->|"submits question"| node_ai_service
node_ai_service -.->|"invokes function"| node_ai_function
node_ai_function -->|"runs safe queries"| node_supabase
node_chat_ai -->|"loads context and saves reply"| node_supabase
node_overview -.->|"offers assistant"| node_ai_assistant
node_ui -.->|"uses shared formatting"| node_formatters
node_theme -->|"configures user themes"| node_auth_service
node_supabase_client -->|"types client"| node_database_types

click node_app "https://github.com/konatsu13/teman/blob/main/src/App.tsx"
click node_login "https://github.com/konatsu13/teman/blob/main/src/pages/auth/LoginPage.tsx"
click node_overview "https://github.com/konatsu13/teman/blob/main/src/pages/dashboard/OverviewPage.tsx"
click node_competitions "https://github.com/konatsu13/teman/blob/main/src/pages/competitions/CompetitionsPage.tsx"
click node_competition_detail "https://github.com/konatsu13/teman/blob/main/src/pages/competitions/CompetitionDetailPage.tsx"
click node_tasks "https://github.com/konatsu13/teman/blob/main/src/pages/tasks/MyTasksPage.tsx"
click node_calendar "https://github.com/konatsu13/teman/blob/main/src/pages/calendar/CalendarPage.tsx"
click node_members "https://github.com/konatsu13/teman/blob/main/src/pages/members/MembersPage.tsx"
click node_notifications "https://github.com/konatsu13/teman/blob/main/src/pages/notifications/NotificationsPage.tsx"
click node_settings "https://github.com/konatsu13/teman/blob/main/src/pages/settings/SettingsPage.tsx"
click node_competition_service "https://github.com/konatsu13/teman/blob/main/src/services/competitionService.ts"
click node_task_service "https://github.com/konatsu13/teman/blob/main/src/services/taskService.ts"
click node_calendar_service "https://github.com/konatsu13/teman/blob/main/src/services/calendarService.ts"
click node_member_service "https://github.com/konatsu13/teman/blob/main/src/services/memberService.ts"
click node_notification_service "https://github.com/konatsu13/teman/blob/main/src/services/notificationService.ts"
click node_chat "https://github.com/konatsu13/teman/blob/main/src/pages/chat/GlobalChatPage.tsx"
click node_chat_state "https://github.com/konatsu13/teman/blob/main/src/hooks/useGlobalChat.ts"
click node_chat_service "https://github.com/konatsu13/teman/blob/main/src/services/chatService.ts"
click node_chat_ai "https://github.com/konatsu13/teman/blob/main/supabase/functions/chat-ai/index.ts"
click node_ai_assistant "https://github.com/konatsu13/teman/blob/main/src/components/shared/AIQueryAssistant.tsx"
click node_ai_service "https://github.com/konatsu13/teman/blob/main/src/services/aiQueryService.ts"
click node_ai_function "https://github.com/konatsu13/teman/blob/main/supabase/functions/ai-query/index.ts"
click node_auth_context "https://github.com/konatsu13/teman/blob/main/src/contexts/AuthContext.tsx"
click node_auth_service "https://github.com/konatsu13/teman/blob/main/src/services/authService.ts"
click node_auth_hook "https://github.com/konatsu13/teman/blob/main/src/hooks/useAuth.ts"
click node_supabase_client "https://github.com/konatsu13/teman/blob/main/src/lib/supabase.ts"
click node_database_types "https://github.com/konatsu13/teman/blob/main/src/types/database.types.ts"
click node_ui "https://github.com/konatsu13/teman/tree/main/src/components/ui"
click node_theme "https://github.com/konatsu13/teman/blob/main/src/config/theme-presets.ts"
click node_formatters "https://github.com/konatsu13/teman/blob/main/src/utils/formatters.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_app,node_login,node_overview,node_competitions,node_competition_detail,node_tasks,node_calendar,node_members,node_notifications,node_settings toneBlue
class node_competition_service,node_task_service,node_calendar_service,node_member_service,node_notification_service,node_supabase toneAmber
class node_chat,node_chat_state,node_chat_service,node_chat_ai,node_ai_assistant,node_ai_service,node_ai_function toneMint
class node_auth_context,node_auth_service,node_auth_hook,node_supabase_client,node_database_types toneRose
class node_ui,node_theme,node_formatters,node_member toneIndigo
```

## Components

### Workspace experience

- [Routes and shell](https://github.com/konatsu13/teman/blob/main/src/App.tsx): `src/App.tsx`
- [Sign in](https://github.com/konatsu13/teman/blob/main/src/pages/auth/LoginPage.tsx): `src/pages/auth/LoginPage.tsx`
- [Overview](https://github.com/konatsu13/teman/blob/main/src/pages/dashboard/OverviewPage.tsx): `src/pages/dashboard/OverviewPage.tsx`
- [Competitions](https://github.com/konatsu13/teman/blob/main/src/pages/competitions/CompetitionsPage.tsx): `src/pages/competitions/CompetitionsPage.tsx`
- [Competition detail](https://github.com/konatsu13/teman/blob/main/src/pages/competitions/CompetitionDetailPage.tsx): `src/pages/competitions/CompetitionDetailPage.tsx`
- [Task management](https://github.com/konatsu13/teman/blob/main/src/pages/tasks/MyTasksPage.tsx): `src/pages/tasks/MyTasksPage.tsx`
- [Calendar](https://github.com/konatsu13/teman/blob/main/src/pages/calendar/CalendarPage.tsx): `src/pages/calendar/CalendarPage.tsx`
- [Member directory](https://github.com/konatsu13/teman/blob/main/src/pages/members/MembersPage.tsx): `src/pages/members/MembersPage.tsx`
- [Notifications](https://github.com/konatsu13/teman/blob/main/src/pages/notifications/NotificationsPage.tsx): `src/pages/notifications/NotificationsPage.tsx`
- [Settings](https://github.com/konatsu13/teman/blob/main/src/pages/settings/SettingsPage.tsx): `src/pages/settings/SettingsPage.tsx`

### Domain services

- [Competition service](https://github.com/konatsu13/teman/blob/main/src/services/competitionService.ts): `src/services/competitionService.ts`
- [Task service](https://github.com/konatsu13/teman/blob/main/src/services/taskService.ts): `src/services/taskService.ts`
- [Calendar service](https://github.com/konatsu13/teman/blob/main/src/services/calendarService.ts): `src/services/calendarService.ts`
- [Member service](https://github.com/konatsu13/teman/blob/main/src/services/memberService.ts): `src/services/memberService.ts`
- [Notification service](https://github.com/konatsu13/teman/blob/main/src/services/notificationService.ts): `src/services/notificationService.ts`

### Chat and AI

- [Global chat](https://github.com/konatsu13/teman/blob/main/src/pages/chat/GlobalChatPage.tsx): `src/pages/chat/GlobalChatPage.tsx`
- [Chat synchronization](https://github.com/konatsu13/teman/blob/main/src/hooks/useGlobalChat.ts): `src/hooks/useGlobalChat.ts`
- [Chat persistence](https://github.com/konatsu13/teman/blob/main/src/services/chatService.ts): `src/services/chatService.ts`
- [Chat AI function](https://github.com/konatsu13/teman/blob/main/supabase/functions/chat-ai/index.ts): `supabase/functions/chat-ai/index.ts`
- [AI query assistant](https://github.com/konatsu13/teman/blob/main/src/components/shared/AIQueryAssistant.tsx): `src/components/shared/AIQueryAssistant.tsx`
- [AI query client](https://github.com/konatsu13/teman/blob/main/src/services/aiQueryService.ts): `src/services/aiQueryService.ts`
- [Safe query function](https://github.com/konatsu13/teman/blob/main/supabase/functions/ai-query/index.ts): `supabase/functions/ai-query/index.ts`

### Identity and platform

- [Session context](https://github.com/konatsu13/teman/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`
- [Authentication service](https://github.com/konatsu13/teman/blob/main/src/services/authService.ts): `src/services/authService.ts`
- [Auth hook](https://github.com/konatsu13/teman/blob/main/src/hooks/useAuth.ts): `src/hooks/useAuth.ts`
- [Supabase client](https://github.com/konatsu13/teman/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Database types](https://github.com/konatsu13/teman/blob/main/src/types/database.types.ts): `src/types/database.types.ts`

### Shared presentation

- [UI components](https://github.com/konatsu13/teman/tree/main/src/components/ui): `src/components/ui`
- [Theme presets](https://github.com/konatsu13/teman/blob/main/src/config/theme-presets.ts): `src/config/theme-presets.ts`
- [Date and value formatting](https://github.com/konatsu13/teman/blob/main/src/utils/formatters.ts): `src/utils/formatters.ts`

### Other components

- **Workspace member**
- **Supabase**

## Connections

- Workspace member → Routes and shell: opens
- Routes and shell → Sign in: routes to (evidence: `src/App.tsx`)
- Routes and shell → Overview: routes to (evidence: `src/App.tsx`)
- Routes and shell → Competitions: routes to (evidence: `src/App.tsx`)
- Routes and shell → Competition detail: routes to (evidence: `src/App.tsx`)
- Routes and shell → Task management: routes to (evidence: `src/App.tsx`)
- Routes and shell → Calendar: routes to (evidence: `src/App.tsx`)
- Routes and shell → Member directory: routes to (evidence: `src/App.tsx`)
- Routes and shell → Notifications: routes to (evidence: `src/App.tsx`)
- Routes and shell → Settings: routes to (evidence: `src/App.tsx`)
- Routes and shell → Global chat: routes to (evidence: `src/App.tsx`)
- Sign in → Session context: signs in through
- Session context → Authentication service: loads profile (evidence: `src/contexts/AuthContext.tsx`)
- Session context → Supabase client: tracks session (evidence: `src/contexts/AuthContext.tsx`)
- Auth hook → Session context: reads context (evidence: `src/hooks/useAuth.ts`)
- Authentication service → Supabase client: queries (evidence: `src/services/authService.ts`)
- Supabase client → Supabase: connects (evidence: `src/lib/supabase.ts`)
- Overview → Competition service: loads data (evidence: `src/pages/dashboard/OverviewPage.tsx`)
- Overview → Task service: loads data (evidence: `src/pages/dashboard/OverviewPage.tsx`)
- Competitions → Competition service: loads data (evidence: `src/pages/competitions/CompetitionsPage.tsx`)
- Competitions → Member service: loads data (evidence: `src/pages/competitions/CompetitionsPage.tsx`)
- Competitions → Task service: loads data (evidence: `src/pages/competitions/CompetitionsPage.tsx`)
- Task management → Task service: loads and writes (evidence: `src/pages/tasks/MyTasksPage.tsx`)
- Task management → Competition service: loads competitions (evidence: `src/pages/tasks/MyTasksPage.tsx`)
- Task management → Member service: loads members (evidence: `src/pages/tasks/MyTasksPage.tsx`)
- Calendar → Calendar service: loads events (evidence: `src/pages/calendar/CalendarPage.tsx`)
- Calendar → Competition service: loads competitions (evidence: `src/pages/calendar/CalendarPage.tsx`)
- Member directory → Member service: loads members (evidence: `src/pages/members/MembersPage.tsx`)
- Competition service → Supabase client: queries (evidence: `src/services/competitionService.ts`)
- Task service → Supabase client: queries (evidence: `src/services/taskService.ts`)
- Calendar service → Supabase client: queries (evidence: `src/services/calendarService.ts`)
- Member service → Supabase client: queries
- Notification service → Supabase client: queries (evidence: `src/services/notificationService.ts`)
- Global chat → Chat synchronization: synchronizes via
- Chat synchronization → Chat persistence: loads messages (evidence: `src/hooks/useGlobalChat.ts`)
- Chat synchronization → Chat AI function: requests AI reply
- Chat persistence → Supabase client: persists messages (evidence: `src/services/chatService.ts`)
- AI query assistant → AI query client: submits question (evidence: `src/components/shared/AIQueryAssistant.tsx`)
- AI query client → Safe query function: invokes function
- Safe query function → Supabase: runs safe queries
- Chat AI function → Supabase: loads context and saves reply
- Overview → AI query assistant: offers assistant
- UI components → Date and value formatting: uses shared formatting
- Theme presets → Authentication service: configures user themes (evidence: `src/services/authService.ts`)
- Supabase client → Database types: types client (evidence: `src/lib/supabase.ts`)
