# aniketcore/sih-app architecture

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

- Interactive diagram: https://gitdiagram.com/aniketcore/sih-app
- Repository: https://github.com/aniketcore/sih-app

## Overview

SIH App supports student profile onboarding and team formation, with authenticated team creation, invitations, membership changes, and an administrative view of users and teams. The main flow is sign-in, profile sync, profile completion, then team operations through the client store and API routes into D1. The README documents rate limiting, freeze controls, and FCFS functionality; the source index also identifies admin, problem-statement, and FCFS modules. Some UI-to-API links are documented rather than visible in sampled call sites.

Main entry points: [`lib/team-store.ts`](https://github.com/aniketcore/sih-app/blob/master/lib/team-store.ts) (Client team store), [`app/api/db.ts`](https://github.com/aniketcore/sih-app/blob/master/app/api/db.ts) (Auth and DB helpers), [`app/page.tsx`](https://github.com/aniketcore/sih-app/blob/master/app/page.tsx) (Profile page), [`lib/auth.ts`](https://github.com/aniketcore/sih-app/blob/master/lib/auth.ts) (Auth and sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_login["Sign-in page<br/>[page.tsx]"]
  node_profile["Profile page<br/>[page.tsx]"]
  node_team_page["Team dashboard route<br/>[page.tsx]"]
  node_auth_panel["Auth dashboard<br/>[auth-panel.tsx]"]
end

subgraph group_identity["Identity and profiles"]
  node_profile_forms["Profile dialogs<br/>[profile-modal.tsx]"]
  node_profile_editor["Profile editor"]
  node_auth["Auth and sync<br/>[auth.ts]"]
  node_firebase_client["Firebase client<br/>[firebase.ts]"]
end

subgraph group_teams["Team lifecycle"]
  node_team_board["Team board<br/>[team-board.tsx]"]
  node_store["Client team store<br/>[team-store.ts]"]
  node_email_rules["Email normalization<br/>[invite-state.ts]"]
end

subgraph group_operations["Administration and FCFS"]
  node_admin_page["Admin console<br/>[page.tsx]"]
  node_problem_data["Problem statements"]
  node_fcfs_card["FCFS claim UI<br/>[fcfs-card.tsx]"]
end

subgraph group_platform["API and persistence"]
  node_teams_api["Team API<br/>[route.ts]"]
  node_invites_api["Invitations API<br/>[route.ts]"]
  node_users_api["Users API<br/>[route.ts]"]
  node_api_db["Auth and DB helpers<br/>[db.ts]"]
  node_d1[("Cloudflare D1")]
  node_admin_api["Admin API<br/>[route.ts]"]
  node_fcfs_api["FCFS API<br/>[route.ts]"]
end

node_student(("Student"))
node_administrator(("Administrator"))
node_identity_service["Google identity lookup"]
node_firebase_auth["Firebase Auth"]

node_student -->|"opens"| node_login
node_login -->|"signs in"| node_auth
node_auth -->|"uses client"| node_firebase_client
node_firebase_client -->|"initializes"| node_firebase_auth
node_auth -->|"syncs user"| node_store
node_store -->|"syncs profile"| node_users_api
node_student -->|"opens"| node_profile
node_profile -->|"observes session"| node_auth
node_profile -->|"loads profile"| node_store
node_profile -->|"renders onboarding"| node_profile_forms
node_profile -->|"renders editor"| node_profile_editor
node_profile_forms -->|"saves profile"| node_store
node_profile_editor -->|"updates profile"| node_store
node_student -->|"opens"| node_team_page
node_team_page -->|"renders"| node_auth_panel
node_auth_panel -->|"observes session"| node_auth
node_auth_panel -->|"loads status"| node_store
node_auth_panel -->|"renders"| node_team_board
node_team_board -->|"manages teams"| node_store
node_store -->|"requests team operations"| node_teams_api
node_store -->|"requests invite operations"| node_invites_api
node_teams_api -->|"uses helpers"| node_api_db
node_invites_api -->|"uses helpers"| node_api_db
node_users_api -->|"uses helpers"| node_api_db
node_invites_api -->|"normalizes email"| node_email_rules
node_teams_api -->|"normalizes email"| node_email_rules
node_store -->|"normalizes email"| node_email_rules
node_api_db -->|"verifies tokens"| node_identity_service
node_api_db -->|"queries and migrates"| node_d1
node_teams_api -->|"reads and writes teams"| node_d1
node_invites_api -->|"reads and writes invites"| node_d1
node_users_api -->|"upserts users"| node_d1
node_administrator -->|"uses"| node_admin_page
node_admin_page -->|"checks session"| node_auth
node_admin_page -->|"loads team data"| node_store
node_admin_page -->|"uses catalog"| node_problem_data
node_admin_api -->|"uses helpers"| node_api_db
node_admin_page -.->|"requests admin operations"| node_admin_api
node_profile -->|"shows claim UI"| node_fcfs_card
node_fcfs_card -->|"uses catalog"| node_problem_data
node_fcfs_card -.->|"claims through"| node_fcfs_api
node_fcfs_api -->|"uses helpers"| node_api_db

click node_login "https://github.com/aniketcore/sih-app/blob/master/app/login/page.tsx"
click node_profile "https://github.com/aniketcore/sih-app/blob/master/app/page.tsx"
click node_team_page "https://github.com/aniketcore/sih-app/blob/master/app/team/page.tsx"
click node_auth_panel "https://github.com/aniketcore/sih-app/blob/master/components/auth-panel.tsx"
click node_team_board "https://github.com/aniketcore/sih-app/blob/master/components/team-board.tsx"
click node_profile_forms "https://github.com/aniketcore/sih-app/blob/master/components/profile-modal.tsx"
click node_profile_editor "https://github.com/aniketcore/sih-app/blob/master/components/edit-profile-modal.tsx"
click node_auth "https://github.com/aniketcore/sih-app/blob/master/lib/auth.ts"
click node_firebase_client "https://github.com/aniketcore/sih-app/blob/master/lib/firebase.ts"
click node_store "https://github.com/aniketcore/sih-app/blob/master/lib/team-store.ts"
click node_email_rules "https://github.com/aniketcore/sih-app/blob/master/lib/invite-state.ts"
click node_teams_api "https://github.com/aniketcore/sih-app/blob/master/app/api/teams/route.ts"
click node_invites_api "https://github.com/aniketcore/sih-app/blob/master/app/api/invites/route.ts"
click node_users_api "https://github.com/aniketcore/sih-app/blob/master/app/api/users/route.ts"
click node_api_db "https://github.com/aniketcore/sih-app/blob/master/app/api/db.ts"
click node_admin_page "https://github.com/aniketcore/sih-app/blob/master/app/admin/page.tsx"
click node_admin_api "https://github.com/aniketcore/sih-app/blob/master/app/api/admin/route.ts"
click node_problem_data "https://github.com/aniketcore/sih-app/blob/master/lib/problem-statements.ts"
click node_fcfs_card "https://github.com/aniketcore/sih-app/blob/master/components/fcfs-card.tsx"
click node_fcfs_api "https://github.com/aniketcore/sih-app/blob/master/app/api/fcfs/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_login,node_profile,node_team_page,node_auth_panel toneBlue
class node_profile_forms,node_profile_editor,node_auth,node_firebase_client toneAmber
class node_team_board,node_store,node_email_rules toneMint
class node_admin_page,node_problem_data,node_fcfs_card toneRose
class node_teams_api,node_invites_api,node_users_api,node_api_db,node_d1,node_admin_api,node_fcfs_api,node_student,node_administrator,node_identity_service,node_firebase_auth toneIndigo
```

## Components

### User experience

- [Sign-in page](https://github.com/aniketcore/sih-app/blob/master/app/login/page.tsx): `app/login/page.tsx`
- [Profile page](https://github.com/aniketcore/sih-app/blob/master/app/page.tsx): `app/page.tsx`
- [Team dashboard route](https://github.com/aniketcore/sih-app/blob/master/app/team/page.tsx): `app/team/page.tsx`
- [Auth dashboard](https://github.com/aniketcore/sih-app/blob/master/components/auth-panel.tsx): `components/auth-panel.tsx`

### Identity and profiles

- [Profile dialogs](https://github.com/aniketcore/sih-app/blob/master/components/profile-modal.tsx): `components/profile-modal.tsx`
- [Profile editor](https://github.com/aniketcore/sih-app/blob/master/components/edit-profile-modal.tsx): `components/edit-profile-modal.tsx`
- [Auth and sync](https://github.com/aniketcore/sih-app/blob/master/lib/auth.ts): `lib/auth.ts`
- [Firebase client](https://github.com/aniketcore/sih-app/blob/master/lib/firebase.ts): `lib/firebase.ts`

### Team lifecycle

- [Team board](https://github.com/aniketcore/sih-app/blob/master/components/team-board.tsx): `components/team-board.tsx`
- [Client team store](https://github.com/aniketcore/sih-app/blob/master/lib/team-store.ts): `lib/team-store.ts`
- [Email normalization](https://github.com/aniketcore/sih-app/blob/master/lib/invite-state.ts): `lib/invite-state.ts`

### Administration and FCFS

- [Admin console](https://github.com/aniketcore/sih-app/blob/master/app/admin/page.tsx): `app/admin/page.tsx`
- [Problem statements](https://github.com/aniketcore/sih-app/blob/master/lib/problem-statements.ts): `lib/problem-statements.ts`
- [FCFS claim UI](https://github.com/aniketcore/sih-app/blob/master/components/fcfs-card.tsx): `components/fcfs-card.tsx`

### API and persistence

- [Team API](https://github.com/aniketcore/sih-app/blob/master/app/api/teams/route.ts): `app/api/teams/route.ts`
- [Invitations API](https://github.com/aniketcore/sih-app/blob/master/app/api/invites/route.ts): `app/api/invites/route.ts`
- [Users API](https://github.com/aniketcore/sih-app/blob/master/app/api/users/route.ts): `app/api/users/route.ts`
- [Auth and DB helpers](https://github.com/aniketcore/sih-app/blob/master/app/api/db.ts): `app/api/db.ts`
- **Cloudflare D1**
- [Admin API](https://github.com/aniketcore/sih-app/blob/master/app/api/admin/route.ts): `app/api/admin/route.ts`
- [FCFS API](https://github.com/aniketcore/sih-app/blob/master/app/api/fcfs/route.ts): `app/api/fcfs/route.ts`

### Other components

- **Student**
- **Administrator**
- **Google identity lookup**
- **Firebase Auth**

## Connections

- Student → Sign-in page: opens (evidence: `README.md`)
- Sign-in page → Auth and sync: signs in (evidence: `app/login/page.tsx`)
- Auth and sync → Firebase client: uses client (evidence: `lib/auth.ts`)
- Firebase client → Firebase Auth: initializes (evidence: `lib/firebase.ts`)
- Auth and sync → Client team store: syncs user (evidence: `lib/auth.ts`)
- Client team store → Users API: syncs profile (evidence: `README.md`)
- Student → Profile page: opens (evidence: `README.md`)
- Profile page → Auth and sync: observes session (evidence: `app/page.tsx`)
- Profile page → Client team store: loads profile (evidence: `app/page.tsx`)
- Profile page → Profile dialogs: renders onboarding (evidence: `app/page.tsx`)
- Profile page → Profile editor: renders editor (evidence: `app/page.tsx`)
- Profile dialogs → Client team store: saves profile (evidence: `components/profile-modal.tsx`)
- Profile editor → Client team store: updates profile (evidence: `components/edit-profile-modal.tsx`)
- Student → Team dashboard route: opens (evidence: `README.md`)
- Team dashboard route → Auth dashboard: renders (evidence: `app/team/page.tsx`)
- Auth dashboard → Auth and sync: observes session (evidence: `components/auth-panel.tsx`)
- Auth dashboard → Client team store: loads status (evidence: `components/auth-panel.tsx`)
- Auth dashboard → Team board: renders (evidence: `components/auth-panel.tsx`)
- Team board → Client team store: manages teams (evidence: `components/team-board.tsx`)
- Client team store → Team API: requests team operations (evidence: `README.md`)
- Client team store → Invitations API: requests invite operations (evidence: `README.md`)
- Team API → Auth and DB helpers: uses helpers (evidence: `app/api/teams/route.ts`)
- Invitations API → Auth and DB helpers: uses helpers (evidence: `app/api/invites/route.ts`)
- Users API → Auth and DB helpers: uses helpers (evidence: `app/api/users/route.ts`)
- Invitations API → Email normalization: normalizes email (evidence: `app/api/invites/route.ts`)
- Team API → Email normalization: normalizes email (evidence: `app/api/teams/route.ts`)
- Client team store → Email normalization: normalizes email (evidence: `lib/team-store.ts`)
- Auth and DB helpers → Google identity lookup: verifies tokens (evidence: `app/api/db.ts`)
- Auth and DB helpers → Cloudflare D1: queries and migrates (evidence: `README.md`)
- Team API → Cloudflare D1: reads and writes teams (evidence: `README.md`)
- Invitations API → Cloudflare D1: reads and writes invites (evidence: `app/api/invites/route.ts`)
- Users API → Cloudflare D1: upserts users (evidence: `README.md`)
- Administrator → Admin console: uses (evidence: `README.md`)
- Admin console → Auth and sync: checks session (evidence: `app/admin/page.tsx`)
- Admin console → Client team store: loads team data (evidence: `app/admin/page.tsx`)
- Admin console → Problem statements: uses catalog (evidence: `app/admin/page.tsx`)
- Admin API → Auth and DB helpers: uses helpers (evidence: `app/api/admin/route.ts`)
- Admin console → Admin API: requests admin operations
- Profile page → FCFS claim UI: shows claim UI (evidence: `app/page.tsx`)
- FCFS claim UI → Problem statements: uses catalog (evidence: `components/fcfs-card.tsx`)
- FCFS claim UI → FCFS API: claims through
- FCFS API → Auth and DB helpers: uses helpers (evidence: `app/api/fcfs/route.ts`)
