# supercoolpencil/grad architecture

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

- Interactive diagram: https://gitdiagram.com/supercoolpencil/grad
- Repository: https://github.com/supercoolpencil/grad

## Overview

##### Main Components
- Mobile Frontend (Expo App): This is the core of the project, as indicated by the “app” directory, utilizing pages (e.g., tabs, course views, edit pages) that act as different screens in the application.
- Context/State Management: The “context” folder shows that global state is handled via providers (AlertContext, AppContext) making it easier to share data across different components/screens.
- Assets: The “assets” directory holds media (images, fonts) that are used across the app. These resources support the visual design.
- Build and Configuration Files: Files like app.json, package.json, and tsconfig.json indicate project configuration, TypeScript setup, and Expo project settings.

##### Relationships and Data Flow
- Assets and constants should be shown as support elements feeding UI styling and media into the visible components.
- The build and configuration files (app.json, package.json) are responsible for setting up the environment but are typically at a higher configuration level rather than data flow – they can be noted in a separate “Configuration” section.

##### Architectural Patterns
- Component-based Design: The project is clearly modular with a separation between presentation (UI components), business logic (context and hooks), and configuration (constants, types, and assets).
- Routing and Navigation: The “app” directory’s structure (with dynamic routes, e.g., course/[id].tsx and edit-course/[id].tsx) suggests navigation is managed by Expo’s routing, likely with a nested/tab structure.
- React Context for State Management: Instead of a full Redux setup, this project uses React Context to share global state, which simplifies state handling across screens.
- Testing: There is a presence of tests for components (as seen in the __tests__ directories) indicating an emphasis on maintainability and reliability.

##### Final Assembly
- Branch out into a few layers:
1. Presentation Layer – include “Screens” (app directory with tabs, courses, add/edit, etc.).
2. Component Layer – list various UI components and how they are utilized across the screens.
3. State Management – include context (AlertContext, AppContext) and how components connect to these providers.
4. Utility/Support Layer – denote custom hooks, constants, types, and assets.
5. Configuration/Build – note files like app.json, package.json.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["GRAD Mobile App Architecture"]:::main

    %% Mobile Frontend Node
    A --> B["Mobile Frontend (Expo App)"]:::frontend
    click B "https://github.com/supercoolpencil/grad/tree/main/app/"

    %% Presentation Layer (Screens / Navigation)
    subgraph "Presentation Layer"
        T1["Main Tab Layout"]:::screen
        click T1 "https://github.com/supercoolpencil/grad/blob/main/app/(tabs)/_layout.tsx"
        T2["Courses Screen"]:::screen
        click T2 "https://github.com/supercoolpencil/grad/blob/main/app/(tabs)/courses.tsx"
        T3["Settings Screen"]:::screen
        click T3 "https://github.com/supercoolpencil/grad/blob/main/app/(tabs)/settings.tsx"
        T4["Add Course Screen"]:::screen
        click T4 "https://github.com/supercoolpencil/grad/blob/main/app/add-course.tsx"
        T5["Archived Courses Screen"]:::screen
        click T5 "https://github.com/supercoolpencil/grad/blob/main/app/archived-courses.tsx"
        T6["Course Details Screen"]:::screen
        click T6 "https://github.com/supercoolpencil/grad/blob/main/app/course/[id].tsx"
        T7["Edit Course Screen"]:::screen
        click T7 "https://github.com/supercoolpencil/grad/blob/main/app/edit-course/[id].tsx"
        T8["Not Found Screen"]:::screen
        click T8 "https://github.com/supercoolpencil/grad/blob/main/app/+not-found.tsx"
    end

    %% Connect Mobile Frontend to Screens
    B --> T1
    B --> T4
    B --> T5
    B --> T6
    B --> T7
    B --> T8
    T1 --> T2
    T1 --> T3

    %% Component Layer (UI Components)
    subgraph "Component Layer"
        C1["Collapsible Component"]:::component
        click C1 "https://github.com/supercoolpencil/grad/blob/main/components/Collapsible.tsx"
        C2["CustomAlert Component"]:::component
        click C2 "https://github.com/supercoolpencil/grad/blob/main/components/CustomAlert.tsx"
        C3["TopBar Component"]:::component
        click C3 "https://github.com/supercoolpencil/grad/blob/main/components/TopBar.tsx"
        C4["ThemedText Component"]:::component
        click C4 "https://github.com/supercoolpencil/grad/blob/main/components/ThemedText.tsx"
        C5["ThemedView Component"]:::component
        click C5 "https://github.com/supercoolpencil/grad/blob/main/components/ThemedView.tsx"
        C6["UI Subcomponents"]:::component
        click C6 "https://github.com/supercoolpencil/grad/tree/main/components/ui"
    end

    %% Connect Screens to UI Components
    T1 --> C1
    T1 --> C2
    T1 --> C3

    %% State Management Layer (Context Providers)
    subgraph "State Management"
        S1["AlertContext Provider"]:::context
        click S1 "https://github.com/supercoolpencil/grad/blob/main/context/AlertContext.tsx"
        S2["AppContext Provider"]:::context
        click S2 "https://github.com/supercoolpencil/grad/blob/main/context/AppContext.tsx"
    end

    %% Connect Screens to Context Providers
    T1 --> S1
    T1 --> S2

    %% Utility / Support Layer (Hooks, Constants, Types, Assets)
    subgraph "Utility/Support Layer"
        H1["useColorScheme Hook"]:::hook
        click H1 "https://github.com/supercoolpencil/grad/blob/main/hooks/useColorScheme.ts"
        H2["useThemeColor Hook"]:::hook
        click H2 "https://github.com/supercoolpencil/grad/blob/main/hooks/useThemeColor.ts"
        U1["Constants (Colors)"]:::config
        click U1 "https://github.com/supercoolpencil/grad/blob/main/constants/Colors.ts"
        U2["Types Definitions"]:::config
        click U2 "https://github.com/supercoolpencil/grad/blob/main/types/index.ts"
        A1["Assets (Images & Fonts)"]:::asset
        click A1 "https://github.com/supercoolpencil/grad/tree/main/assets/"
    end

    %% Connect Hooks and Constants to illustrate dependency
    T1 --> H1
    H1 --> H2
    H2 --> U1
    C4 --> H2
    C5 --> A1

    %% Configuration / Build Layer
    subgraph "Configuration/Build"
        CFG1["app.json"]:::build
        click CFG1 "https://github.com/supercoolpencil/grad/blob/main/app.json"
        CFG2["package.json"]:::build
        click CFG2 "https://github.com/supercoolpencil/grad/blob/main/package.json"
        CFG3["tsconfig.json"]:::build
        click CFG3 "https://github.com/supercoolpencil/grad/blob/main/tsconfig.json"
        CFG4["eas.json"]:::build
        click CFG4 "https://github.com/supercoolpencil/grad/blob/main/eas.json"
    end

    %% Connect Main Architecture to Configuration
    A --- CFG1
    A --- CFG2
    A --- CFG3
    A --- CFG4

    %% Styles
    classDef main fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef screen fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef component fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef context fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef hook fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef asset fill:#C0C0C0,stroke:#333,stroke-width:2px;
    classDef build fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
