# joaquimpaiva/em-dia-ios architecture

> Architecture diagram of the GitHub repository joaquimpaiva/em-dia-ios, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joaquimpaiva/em-dia-ios
- Repository: https://github.com/joaquimpaiva/em-dia-ios

## Overview

Em Dia is a native iOS school-calendar app. Users sign in or create an account, then browse and search events, manage events according to their role, and access class and user administration; students can join classes with a code, and users can authorize calendar pairing by scanning a TV QR code. Supabase supplies authentication and profile-backed state, while the shared calendar Edge Function serves app requests. The graph preserves documented capabilities whose screens were not excerpted; those links rely on README or source-index references rather than inspected implementations.

Main entry points: [`src/lib/api.ts`](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/api.ts) (Calendar API client), [`src/lib/supabase.ts`](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/supabase.ts) (Supabase client), [`src/app/event-form.tsx`](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/event-form.tsx) (Event publishing), [`src/lib/events.ts`](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/events.ts) (Event retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and access"]
  node_shell["App navigation<br/>[_layout.tsx]"]
  node_auth["Sign in and signup<br/>[auth.tsx]"]
  node_account["Account settings<br/>[account.tsx]"]
  node_pairing["Calendar pairing<br/>[pairing.tsx]"]
  node_scanner["QR scanner<br/>[qr-scanner.tsx]"]
end

subgraph group_calendar["Calendar"]
  node_agenda["Personal agenda<br/>[index.tsx]"]
  node_eventform["Event publishing<br/>[event-form.tsx]"]
  node_eventdata["Event retrieval<br/>[events.ts]"]
end

subgraph group_admin["School administration"]
  node_classtab["Class directory<br/>[classes.tsx]"]
  node_classform["Class management<br/>[class-form.tsx]"]
  node_users["User administration<br/>[users.tsx]"]
  node_userform["User editing<br/>[user-form.tsx]"]
end

subgraph group_platform["Services and shared code"]
  node_authstate["Session and profile<br/>[AuthContext.tsx]"]
  node_api["Calendar API client<br/>[api.ts]"]
  node_config["Service configuration<br/>[config.ts]"]
  node_supabaseclient["Supabase client<br/>[supabase.ts]"]
  node_theme["Theme selection<br/>[theme.ts]"]
  node_ui["Shared interface<br/>[UI.tsx]"]
end

node_user(("App user"))
node_supabase[("Supabase")]
node_calendarservice["Calendar Edge Function"]
node_securestore[("iOS Keychain storage")]

node_user -->|"opens app"| node_shell
node_shell -->|"provides session"| node_authstate
node_auth -->|"authenticates"| node_supabaseclient
node_auth -->|"refreshes profile"| node_authstate
node_auth -->|"renders with"| node_ui
node_authstate -->|"loads profile"| node_supabaseclient
node_supabaseclient -->|"uses auth and data"| node_supabase
node_supabaseclient -->|"persists session"| node_securestore
node_user -->|"browses events"| node_agenda
node_agenda -->|"loads visible events"| node_eventdata
node_eventdata -->|"requests events"| node_api
node_eventdata -->|"reads RLS fallback"| node_supabaseclient
node_user -->|"publishes or edits"| node_eventform
node_eventform -->|"saves event"| node_api
node_eventform -->|"loads event"| node_eventdata
node_classtab -->|"loads classes"| node_api
node_user -->|"manages classes"| node_classform
node_classform -->|"manages class"| node_api
node_users -->|"manages users"| node_api
node_userform -->|"updates user"| node_api
node_user -->|"scans TV code"| node_scanner
node_scanner -->|"authorizes pairing"| node_pairing
node_pairing -->|"requests pairing"| node_api
node_api -->|"uses endpoint config"| node_config
node_api -->|"gets session token"| node_supabaseclient
node_api -->|"sends requests"| node_calendarservice
node_account -->|"updates profile settings"| node_supabaseclient
node_theme -->|"reads profile theme"| node_authstate
node_agenda -->|"renders with"| node_ui
node_classform -.->|"renders with"| node_ui
node_eventform -.->|"renders with"| node_ui

click node_shell "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/_layout.tsx"
click node_auth "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/auth.tsx"
click node_account "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/account.tsx"
click node_pairing "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/pairing.tsx"
click node_scanner "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/qr-scanner.tsx"
click node_agenda "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/(tabs)/index.tsx"
click node_eventform "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/event-form.tsx"
click node_eventdata "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/events.ts"
click node_classtab "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/(tabs)/classes.tsx"
click node_classform "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/class-form.tsx"
click node_users "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/(tabs)/users.tsx"
click node_userform "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/user-form.tsx"
click node_authstate "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/AuthContext.tsx"
click node_api "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/api.ts"
click node_config "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/config.ts"
click node_supabaseclient "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/supabase.ts"
click node_theme "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/theme.ts"
click node_ui "https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/components/UI.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_shell,node_auth,node_account,node_pairing,node_scanner,node_user toneBlue
class node_agenda,node_eventform,node_eventdata,node_supabase,node_securestore toneAmber
class node_classtab,node_classform,node_users,node_userform toneMint
class node_authstate,node_api,node_config,node_supabaseclient,node_theme,node_ui toneRose
class node_calendarservice toneIndigo
```

## Components

### App and access

- [App navigation](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/_layout.tsx): `src/app/_layout.tsx`
- [Sign in and signup](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/auth.tsx): `src/app/auth.tsx`
- [Account settings](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/account.tsx): `src/app/account.tsx`
- [Calendar pairing](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/pairing.tsx): `src/app/pairing.tsx`
- [QR scanner](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/qr-scanner.tsx): `src/app/qr-scanner.tsx`

### Calendar

- [Personal agenda](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/(tabs)/index.tsx): `src/app/(tabs)/index.tsx`
- [Event publishing](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/event-form.tsx): `src/app/event-form.tsx`
- [Event retrieval](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/events.ts): `src/lib/events.ts`

### School administration

- [Class directory](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/(tabs)/classes.tsx): `src/app/(tabs)/classes.tsx`
- [Class management](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/class-form.tsx): `src/app/class-form.tsx`
- [User administration](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/(tabs)/users.tsx): `src/app/(tabs)/users.tsx`
- [User editing](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/app/user-form.tsx): `src/app/user-form.tsx`

### Services and shared code

- [Session and profile](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/AuthContext.tsx): `src/lib/AuthContext.tsx`
- [Calendar API client](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Service configuration](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/config.ts): `src/lib/config.ts`
- [Supabase client](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Theme selection](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/lib/theme.ts): `src/lib/theme.ts`
- [Shared interface](https://github.com/joaquimpaiva/em-dia-ios/blob/main/src/components/UI.tsx): `src/components/UI.tsx`

### Other components

- **App user**
- **Supabase**
- **Calendar Edge Function**
- **iOS Keychain storage**

## Connections

- App user → App navigation: opens app (evidence: `README.md`)
- App navigation → Session and profile: provides session (evidence: `src/app/_layout.tsx`)
- Sign in and signup → Supabase client: authenticates (evidence: `src/app/auth.tsx`)
- Sign in and signup → Session and profile: refreshes profile (evidence: `src/app/auth.tsx`)
- Sign in and signup → Shared interface: renders with (evidence: `src/app/auth.tsx`)
- Session and profile → Supabase client: loads profile (evidence: `src/lib/AuthContext.tsx`)
- Supabase client → Supabase: uses auth and data (evidence: `src/lib/supabase.ts`)
- Supabase client → iOS Keychain storage: persists session (evidence: `README.md`)
- App user → Personal agenda: browses events (evidence: `README.md`)
- Personal agenda → Event retrieval: loads visible events (evidence: `src/app/(tabs)/index.tsx`)
- Event retrieval → Calendar API client: requests events (evidence: `src/lib/events.ts`)
- Event retrieval → Supabase client: reads RLS fallback (evidence: `src/lib/events.ts`)
- App user → Event publishing: publishes or edits (evidence: `README.md`)
- Event publishing → Calendar API client: saves event (evidence: `src/app/event-form.tsx`)
- Event publishing → Event retrieval: loads event (evidence: `src/app/event-form.tsx`)
- Class directory → Calendar API client: loads classes (evidence: `src/app/(tabs)/classes.tsx`)
- App user → Class management: manages classes (evidence: `README.md`)
- Class management → Calendar API client: manages class (evidence: `src/app/class-form.tsx`)
- User administration → Calendar API client: manages users (evidence: `src/app/(tabs)/users.tsx`)
- User editing → Calendar API client: updates user (evidence: `src/app/user-form.tsx`)
- App user → QR scanner: scans TV code (evidence: `README.md`)
- QR scanner → Calendar pairing: authorizes pairing (evidence: `README.md`)
- Calendar pairing → Calendar API client: requests pairing (evidence: `src/app/pairing.tsx`)
- Calendar API client → Service configuration: uses endpoint config (evidence: `src/lib/api.ts`)
- Calendar API client → Supabase client: gets session token (evidence: `src/lib/api.ts`)
- Calendar API client → Calendar Edge Function: sends requests (evidence: `README.md`)
- Account settings → Supabase client: updates profile settings (evidence: `src/app/account.tsx`)
- Theme selection → Session and profile: reads profile theme (evidence: `src/lib/theme.ts`)
- Personal agenda → Shared interface: renders with (evidence: `src/app/(tabs)/index.tsx`)
- Class management → Shared interface: renders with (evidence: `src/app/class-form.tsx`)
- Event publishing → Shared interface: renders with (evidence: `src/app/event-form.tsx`)
