# aarushk09/satez architecture

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

- Interactive diagram: https://gitdiagram.com/aarushk09/satez
- Repository: https://github.com/aarushk09/satez

## Overview

##### Project Type and Purpose
- SATez is a cross-platform SAT preparation platform (mobile & web) built with React Native (Expo) and TypeScript.
- It offers practice modules (vocab, reading, quizzes), AI-powered tutoring (GROQ API), progress tracking, and user management via Supabase (Auth, PostgreSQL, real-time).

##### File Structure
- **app/**: Expo Router pages & layouts, split into:
- (auth)/ → login & signup flows
- (tabs)/ → main tabbed interface (home, practice, quiz, tutor, resources, stats, profile, etc.)
- context/ → React Context providers (AuthContext, PracticeDataContext)
- components/ → app-specific screen components
- **components/**: reusable UI building blocks (Button, Card, ProgressBar, ChatMessage, SkeletonLoader, etc.)
- **utils/**: data-layer & integration
- supabase.ts → Supabase client setup
- groq.ts → AI tutoring integration
- storage.ts → AsyncStorage utilities
- database_setup.sql, setupSupabaseTables.js → DB schema & provisioning
- **data/**: static content (vocab.json, parsed SAT questions)
- **assets/**: fonts & images
- **scripts/**: project utilities (reset scripts)
- Config files: package.json, tsconfig.json, metro.config.js, eslint.config.js

##### README for Additional Insights
- Technology stack: Expo/React Native, TypeScript, Supabase, React Navigation, React Context, AsyncStorage
- Architectural pattern: client-centric, component-based, context/state management, service integration
- External services: Supabase Auth & DB, real-time subscriptions, GROQ AI API

##### Main Components & Their Relationships
a. **Client (React Native + Expo Router)**
- UI Layer: screens (app/(tabs), app/(auth)), layouts, shared components
- Navigation: Expo Router → handles auth flow and tabbed main flow
- State Management: React Context + custom hooks for auth state, practice data, theme, etc.
- Offline Layer: AsyncStorage for local persistence
- Data Layer: utils/supabase.ts and utils/groq.ts for remote calls
b. **Backend (Supabase)**
- Auth: email/password & OAuth → user_profiles table
- Database (PostgreSQL): practice results tables (vocab_practice_results, reading_practice_results, etc.)
- Real-time: subscriptions for live sync
c. **AI Service (GROQ API)**
- Chat-based tutor interface → ChatMessage component communicates with GROQ via utils/groq.ts
d. **External Assets & Scripts**
- Static data (assets/, data/)
- Provisioning: database_setup.sql, setupSupabaseTables.js

##### Architectural Patterns & Design Principles
- Layered architecture: Presentation → State (Context) → Data (utils) → External services
- Componentization: reusable components (components/ui, components/…)
- Separation of concerns:
- auth vs main flows (app/(auth) vs app/(tabs))
- data integration vs UI
- Offline-first design: AsyncStorage syncing with Supabase

##### Final Checklist
- [ ] Clear labels for each module, service, and data store
- [ ] Note key technologies next to components (e.g., “React Context”, “Expo Router”, “Supabase Auth”)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Expo Router"
            AuthFlow["Auth Flow"]:::frontend
            MainTabsFlow["Main Tabs Flow"]:::frontend
            RootLayout["Root Layout & Not Found"]:::frontend
        end
        StudyStreakBar["StudyStreakBar Component"]:::frontend
        ChatMessage["ChatMessage Component"]:::frontend
    end

    %% State Layer
    subgraph "State Layer"
        AuthContext["AuthContext"]:::state
        PracticeDataContext["PracticeDataContext"]:::state
        subgraph "Custom Hooks"
            useColorScheme["useColorScheme"]:::state
            useHaptics["useHaptics"]:::state
            useThemeColor["useThemeColor"]:::state
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        supabase["Supabase Client"]:::data
        groq["GROQ Integration"]:::data
        storageUtil["AsyncStorage Utils"]:::data
        provisioningSQL["database_setup.sql"]:::data
        provisioningJS["setupSupabaseTables.js"]:::data
    end

    %% Persistence Layer
    persistStor[(AsyncStorage)]:::persist

    %% Services Layer
    subgraph "Services"
        subgraph "Supabase Cloud"
            supAuth["Auth Service"]:::backend
            supDB[(PostgreSQL DB)]:::backend
            supRT["Real-time Service"]:::backend
        end
        groqCloud((GROQ AI API)):::external
    end

    %% Connections
    AuthFlow -->|uses| AuthContext
    MainTabsFlow -->|uses| PracticeDataContext
    StudyStreakBar -->|renders in| MainTabsFlow
    ChatMessage -->|calls| groq
    MainTabsFlow -->|opens tutor UI| ChatMessage

    AuthContext -->|calls| supabase
    PracticeDataContext -->|calls| supabase

    storageUtil <--> persistStor

    supabase -->|auth requests| supAuth
    supabase -->|db queries| supDB
    supabase -->|subscribe| supRT
    groq -->|API calls| groqCloud

    %% Click Events
    click AuthFlow "https://github.com/aarushk09/satez/blob/main/app/(auth)/_layout.tsx"
    click AuthFlow "https://github.com/aarushk09/satez/blob/main/app/(auth)/login.tsx"
    click AuthFlow "https://github.com/aarushk09/satez/blob/main/app/(auth)/signup.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/_layout.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/explore.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/practice.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/vocabpractice.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/readingpractice.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/quiz.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/tutor.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/resources.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/stats.tsx"
    click MainTabsFlow "https://github.com/aarushk09/satez/blob/main/app/(tabs)/profile.tsx"
    click RootLayout "https://github.com/aarushk09/satez/blob/main/app/_layout.tsx"
    click RootLayout "https://github.com/aarushk09/satez/blob/main/app/+not-found.tsx"
    click AuthContext "https://github.com/aarushk09/satez/blob/main/app/context/AuthContext.tsx"
    click PracticeDataContext "https://github.com/aarushk09/satez/blob/main/app/context/PracticeDataContext.tsx"
    click StudyStreakBar "https://github.com/aarushk09/satez/blob/main/app/components/StudyStreakBar.tsx"
    click supabase "https://github.com/aarushk09/satez/blob/main/utils/supabase.ts"
    click groq "https://github.com/aarushk09/satez/blob/main/utils/groq.ts"
    click storageUtil "https://github.com/aarushk09/satez/blob/main/utils/storage.ts"
    click provisioningSQL "https://github.com/aarushk09/satez/blob/main/utils/database_setup.sql"
    click provisioningJS "https://github.com/aarushk09/satez/blob/main/utils/setupSupabaseTables.js"
    click ChatMessage "https://github.com/aarushk09/satez/blob/main/components/ChatMessage.tsx"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef state fill:#BDEBDD,stroke:#00875A
    classDef data fill:#E3DFFD,stroke:#5A4FCF
    classDef persist fill:#F2F0F7,stroke:#6a737d
    classDef backend fill:#D2F0D2,stroke:#22863A
    classDef external fill:#FFE8D0,stroke:#D97706
```
