# sakthirithan/teamskrypton architecture

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

- Interactive diagram: https://gitdiagram.com/sakthirithan/teamskrypton
- Repository: https://github.com/sakthirithan/teamskrypton

## Overview

#### Purpose and Entry Points
Krypton is a role-aware team/workspace management application spanning collaboration, productivity tracking, project-based learning (PBL), monitoring, and administration. The browser client starts at `src/main.tsx`, composes routing/application state in `src/App.tsx`, and is packaged as a Vite web app with an Android Capacitor shell (`capacitor.config.ts`, `android/app/src/main/java/com/teamskrypton/app/MainActivity.java`).

#### Client Shell, Session, and Access Control
Authentication and session state form the primary application boundary: unauthenticated users enter the auth screens; authenticated users receive role- and mode-dependent navigation, dashboards, and workspace capabilities. Shared layout provides desktop/mobile navigation, command access, loading, offline, and refresh behavior.
- `src/hooks/useAuth.tsx`
- `src/pages/Auth.tsx`
- `src/components/layout/GlobalScrollLayout.tsx`

Roles and application modes are centralized client concerns and drive feature visibility across leadership, team-member, guest, and administrative flows.
- `src/lib/roles.ts`
- `src/hooks/useAppMode.tsx`
- `src/components/mode/ModeSwitch.tsx`

#### Grouping Workspace and Team Operations
The grouping area is the main operational workspace: members work with goals/targets, daily entries, habits, sessions, notes, communities, todos, points, skills, and leaderboards. A layout/sidebar boundary organizes these distinct views while hooks encapsulate their backend reads, writes, and subscriptions.
- `src/components/grouping/GroupingLayout.tsx`
- `src/pages/GroupingHome.tsx`
- `src/hooks/useGroupingTargets.tsx`

Role-specific dashboards convert the same workspace data into operational views for captains, strategists, team managers, leadership, and members; task CRUD and assignment are surfaced here.
- `src/components/dashboard/CommandCenter.tsx`
- `src/components/dashboard/TaskCRUD.tsx`
- `src/components/dashboard/LeadershipDashboard.tsx`

#### Monitoring and Alert Automation
Centralized monitoring is a distinct workflow for tracking member status, configuring targets and alert rules, running daily surveys, reviewing history, and applying manual lead/AP changes. It combines interactive monitoring UI with backend-generated reminder and scheduled-alert processing.
- `src/pages/CentralizedMonitoring.tsx`
- `src/components/monitoring/DailySurveyCommandCenter.tsx`
- `src/hooks/useCentralizedMonitoring.ts`

Notification delivery is a cross-cutting output of monitoring, polls, and team activity. Client views compose and display notifications; privileged server functions send in-app, email, and push messages.
- `src/components/notifications/NotificationComposer.tsx`
- `supabase/functions/send-notification/index.ts`
- `supabase/functions/evaluate-daily-reminders/index.ts`

#### PBL, Messaging, and Engagement Domains
PBL is a parallel workspace domain with project lifecycle, task boards, milestones, documentation, staffing, timelines, and analytics.
- `src/components/pbl/PBLLayout.tsx`
- `src/pages/PBLProjects.tsx`
- `src/pages/ProjectDetail.tsx`

Team engagement features include polls, group messaging, skill development/challenges, points, and member-facing notifications. These are separate UI domains but share authenticated Supabase data and role enforcement.
- `src/components/messenger/MessengerConversation.tsx`
- `src/components/polls/PollsPanel.tsx`
- `src/components/grouping/SkillQuestDashboard.tsx`

#### Backend, Data Boundary, and Integrations
Supabase supplies the application backend: the generated client/types are the frontend data boundary; SQL migrations define the evolving schema, indexes, realtime behavior, and row-level-security policies. Edge Functions handle operations that should not rely on direct client privileges, including user lifecycle changes, poll side effects, Google Sheets retrieval, AI skill suggestions, and notification dispatch.
- `src/integrations/supabase/client.ts`
- `src/integrations/supabase/types.ts`
- `supabase/migrations/20260814_monitoring_and_surveys.sql`

External service boundaries include Google Sheets via `supabase/functions/fetch-google-sheet/index.ts`, notification email/push delivery via server functions, and an AI-backed skills suggestion endpoint (`supabase/functions/suggest-skills/index.ts`).

#### Deployment and Native Delivery
The frontend is configured for web deployment with redirect support and Vercel configuration, while the Android project embeds the built web client through Capacitor. PWA assets support installability; native push/deep-link behavior is mediated by client utilities and Capacitor runtime configuration.
- `vercel.json`
- `public/manifest.json`
- `src/lib/push.ts`

Main entry points: [`src/lib/roles.ts`](https://github.com/sakthirithan/teamskrypton/blob/main/src/lib/roles.ts) (Roles and modes), [`src/integrations/supabase/client.ts`](https://github.com/sakthirithan/teamskrypton/blob/main/src/integrations/supabase/client.ts) (Supabase client), [`src/App.tsx`](https://github.com/sakthirithan/teamskrypton/blob/main/src/App.tsx) (Application shell), [`src/components/messenger/MessengerConversation.tsx`](https://github.com/sakthirithan/teamskrypton/blob/main/src/components/messenger/MessengerConversation.tsx) (Messaging and engagement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_entry["Vite entry<br/>web entry<br/>[main.tsx]"]
  node_app["Application shell<br/>routing and state<br/>[App.tsx]"]
  node_auth["Session boundary<br/>auth hook<br/>[useAuth.tsx]"]
  node_auth_ui["Authentication screens<br/>page<br/>[Auth.tsx]"]
  node_layout["Global layout<br/>responsive shell"]
  node_roles_modes["Roles and modes<br/>access state<br/>[roles.ts]"]
end

subgraph group_domains["Workspace domains"]
  node_grouping["Grouping workspace<br/>operational workspace<br/>[GroupingLayout.tsx]"]
  node_grouping_data["Grouping data<br/>workspace hook"]
  node_dashboards["Role dashboards<br/>operations UI<br/>[CommandCenter.tsx]"]
  node_monitoring["Central monitoring<br/>monitoring UI"]
  node_pbl["PBL workspace<br/>project workspace<br/>[PBLLayout.tsx]"]
  node_engagement["Messaging and engagement<br/>collaboration UI"]
end

subgraph group_backend["Supabase backend"]
  node_supabase_client[("Supabase client<br/>frontend data boundary<br/>[client.ts]")]
  node_schema[("Schema and RLS<br/>SQL migrations")]
  node_reminders["Reminder evaluation<br/>edge function<br/>[index.ts]"]
  node_notifications["Notification dispatch<br/>edge function<br/>[index.ts]"]
  node_integrations["Privileged integrations<br/>edge functions<br/>[index.ts]"]
end

subgraph group_delivery["Delivery"]
  node_web_deploy["Web deployment<br/>Vercel config<br/>[vercel.json]"]
  node_pwa_push["PWA and push<br/>client delivery<br/>[push.ts]"]
  node_android["Android shell<br/>Capacitor activity<br/>[MainActivity.java]"]
end

node_entry -->|"boots"| node_app
node_app -->|"establishes session"| node_auth
node_auth -->|"unauthenticated"| node_auth_ui
node_auth -->|"authenticated"| node_layout
node_layout -->|"applies access state"| node_roles_modes
node_roles_modes -->|"enables workspace"| node_grouping
node_roles_modes -->|"selects views"| node_dashboards
node_roles_modes -->|"guards workflow"| node_monitoring
node_roles_modes -->|"guards workflow"| node_pbl
node_roles_modes -->|"guards features"| node_engagement
node_grouping -->|"uses"| node_grouping_data
node_grouping_data -->|"data access"| node_supabase_client
node_dashboards -->|"tasks and workspace data"| node_supabase_client
node_monitoring -->|"monitoring data"| node_supabase_client
node_pbl -->|"project data"| node_supabase_client
node_engagement -->|"messages, polls, skills"| node_supabase_client
node_supabase_client -->|"queries under RLS"| node_schema
node_monitoring -->|"configures rules"| node_reminders
node_reminders -->|"triggers delivery"| node_notifications
node_engagement -->|"activity notifications"| node_notifications
node_engagement -->|"AI and Sheets requests"| node_integrations
node_app -.->|"deployed as web app"| node_web_deploy
node_app -->|"uses push runtime"| node_pwa_push
node_web_deploy -.->|"web bundle embedded by"| node_android

click node_entry "https://github.com/sakthirithan/teamskrypton/blob/main/src/main.tsx"
click node_app "https://github.com/sakthirithan/teamskrypton/blob/main/src/App.tsx"
click node_auth "https://github.com/sakthirithan/teamskrypton/blob/main/src/hooks/useAuth.tsx"
click node_auth_ui "https://github.com/sakthirithan/teamskrypton/blob/main/src/pages/Auth.tsx"
click node_layout "https://github.com/sakthirithan/teamskrypton/blob/main/src/components/layout/GlobalScrollLayout.tsx"
click node_roles_modes "https://github.com/sakthirithan/teamskrypton/blob/main/src/lib/roles.ts"
click node_grouping "https://github.com/sakthirithan/teamskrypton/blob/main/src/components/grouping/GroupingLayout.tsx"
click node_grouping_data "https://github.com/sakthirithan/teamskrypton/blob/main/src/hooks/useGroupingTargets.tsx"
click node_dashboards "https://github.com/sakthirithan/teamskrypton/blob/main/src/components/dashboard/CommandCenter.tsx"
click node_monitoring "https://github.com/sakthirithan/teamskrypton/blob/main/src/pages/CentralizedMonitoring.tsx"
click node_pbl "https://github.com/sakthirithan/teamskrypton/blob/main/src/components/pbl/PBLLayout.tsx"
click node_engagement "https://github.com/sakthirithan/teamskrypton/blob/main/src/components/messenger/MessengerConversation.tsx"
click node_supabase_client "https://github.com/sakthirithan/teamskrypton/blob/main/src/integrations/supabase/client.ts"
click node_schema "https://github.com/sakthirithan/teamskrypton/blob/main/supabase/migrations/20260814_monitoring_and_surveys.sql"
click node_reminders "https://github.com/sakthirithan/teamskrypton/blob/main/supabase/functions/evaluate-daily-reminders/index.ts"
click node_notifications "https://github.com/sakthirithan/teamskrypton/blob/main/supabase/functions/send-notification/index.ts"
click node_integrations "https://github.com/sakthirithan/teamskrypton/blob/main/supabase/functions/fetch-google-sheet/index.ts"
click node_web_deploy "https://github.com/sakthirithan/teamskrypton/blob/main/vercel.json"
click node_pwa_push "https://github.com/sakthirithan/teamskrypton/blob/main/src/lib/push.ts"
click node_android "https://github.com/sakthirithan/teamskrypton/blob/main/android/app/src/main/java/com/teamskrypton/app/MainActivity.java"

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_entry,node_app,node_auth,node_auth_ui,node_layout,node_roles_modes toneBlue
class node_grouping,node_grouping_data,node_dashboards,node_monitoring,node_pbl,node_engagement toneAmber
class node_supabase_client,node_schema,node_reminders,node_notifications,node_integrations toneMint
class node_web_deploy,node_pwa_push,node_android toneRose
```

## Components

### Browser client

- [Vite entry](https://github.com/sakthirithan/teamskrypton/blob/main/src/main.tsx): web entry · `src/main.tsx`
- [Application shell](https://github.com/sakthirithan/teamskrypton/blob/main/src/App.tsx): routing and state · `src/App.tsx`
- [Session boundary](https://github.com/sakthirithan/teamskrypton/blob/main/src/hooks/useAuth.tsx): auth hook · Controls authenticated application access. · `src/hooks/useAuth.tsx`
- [Authentication screens](https://github.com/sakthirithan/teamskrypton/blob/main/src/pages/Auth.tsx): page · `src/pages/Auth.tsx`
- [Global layout](https://github.com/sakthirithan/teamskrypton/blob/main/src/components/layout/GlobalScrollLayout.tsx): responsive shell · Provides navigation, offline, loading, and refresh behavior. · `src/components/layout/GlobalScrollLayout.tsx`
- [Roles and modes](https://github.com/sakthirithan/teamskrypton/blob/main/src/lib/roles.ts): access state · Determines navigation and feature visibility. · `src/lib/roles.ts`

### Workspace domains

- [Grouping workspace](https://github.com/sakthirithan/teamskrypton/blob/main/src/components/grouping/GroupingLayout.tsx): operational workspace · Goals, daily work, habits, sessions, and team engagement views. · `src/components/grouping/GroupingLayout.tsx`
- [Grouping data](https://github.com/sakthirithan/teamskrypton/blob/main/src/hooks/useGroupingTargets.tsx): workspace hook · Reads, writes, and subscribes to targets. · `src/hooks/useGroupingTargets.tsx`
- [Role dashboards](https://github.com/sakthirithan/teamskrypton/blob/main/src/components/dashboard/CommandCenter.tsx): operations UI · Role-specific team views and task assignment. · `src/components/dashboard/CommandCenter.tsx`
- [Central monitoring](https://github.com/sakthirithan/teamskrypton/blob/main/src/pages/CentralizedMonitoring.tsx): monitoring UI · Tracks status, targets, alerts, surveys, and history. · `src/pages/CentralizedMonitoring.tsx`
- [PBL workspace](https://github.com/sakthirithan/teamskrypton/blob/main/src/components/pbl/PBLLayout.tsx): project workspace · Projects, boards, milestones, staffing, and analytics. · `src/components/pbl/PBLLayout.tsx`
- [Messaging and engagement](https://github.com/sakthirithan/teamskrypton/blob/main/src/components/messenger/MessengerConversation.tsx): collaboration UI · Messaging, polls, skills, points, and notifications. · `src/components/messenger/MessengerConversation.tsx`

### Supabase backend

- [Supabase client](https://github.com/sakthirithan/teamskrypton/blob/main/src/integrations/supabase/client.ts): frontend data boundary · `src/integrations/supabase/client.ts`
- [Schema and RLS](https://github.com/sakthirithan/teamskrypton/blob/main/supabase/migrations/20260814_monitoring_and_surveys.sql): SQL migrations · Defines data model, realtime behavior, indexes, and access policies. · `supabase/migrations/20260814_monitoring_and_surveys.sql`
- [Reminder evaluation](https://github.com/sakthirithan/teamskrypton/blob/main/supabase/functions/evaluate-daily-reminders/index.ts): edge function · Runs scheduled monitoring reminder and alert processing. · `supabase/functions/evaluate-daily-reminders/index.ts`
- [Notification dispatch](https://github.com/sakthirithan/teamskrypton/blob/main/supabase/functions/send-notification/index.ts): edge function · Sends in-app, email, and push notifications. · `supabase/functions/send-notification/index.ts`
- [Privileged integrations](https://github.com/sakthirithan/teamskrypton/blob/main/supabase/functions/fetch-google-sheet/index.ts): edge functions · Google Sheets retrieval and AI skill suggestions. · `supabase/functions/fetch-google-sheet/index.ts`

### Delivery

- [Web deployment](https://github.com/sakthirithan/teamskrypton/blob/main/vercel.json): Vercel config · Hosts the web client with redirect support. · `vercel.json`
- [PWA and push](https://github.com/sakthirithan/teamskrypton/blob/main/src/lib/push.ts): client delivery · Installability and native push/deep-link mediation. · `src/lib/push.ts`
- [Android shell](https://github.com/sakthirithan/teamskrypton/blob/main/android/app/src/main/java/com/teamskrypton/app/MainActivity.java): Capacitor activity · Embeds the built web application. · `android/app/src/main/java/com/teamskrypton/app/MainActivity.java`

## Connections

- Vite entry → Application shell: boots
- Application shell → Session boundary: establishes session
- Session boundary → Authentication screens: unauthenticated
- Session boundary → Global layout: authenticated
- Global layout → Roles and modes: applies access state
- Roles and modes → Grouping workspace: enables workspace
- Roles and modes → Role dashboards: selects views
- Roles and modes → Central monitoring: guards workflow
- Roles and modes → PBL workspace: guards workflow
- Roles and modes → Messaging and engagement: guards features
- Grouping workspace → Grouping data: uses
- Grouping data → Supabase client: data access
- Role dashboards → Supabase client: tasks and workspace data
- Central monitoring → Supabase client: monitoring data
- PBL workspace → Supabase client: project data
- Messaging and engagement → Supabase client: messages, polls, skills
- Supabase client → Schema and RLS: queries under RLS
- Central monitoring → Reminder evaluation: configures rules
- Reminder evaluation → Notification dispatch: triggers delivery
- Messaging and engagement → Notification dispatch: activity notifications
- Messaging and engagement → Privileged integrations: AI and Sheets requests
- Application shell → Web deployment: deployed as web app
- Application shell → PWA and push: uses push runtime
- Web deployment → Android shell: web bundle embedded by
