# bevanlewis/note-wall architecture

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

- Interactive diagram: https://gitdiagram.com/bevanlewis/note-wall
- Repository: https://github.com/bevanlewis/note-wall

## Overview

##### Project Type and Purpose
- Wall is a full-stack application with a focus on providing digital sticky notes functionality. It emphasizes simplicity for users—quick note creation, automatic saving, and seamless access across devices.
- The README highlights features like ease of use, quick note-taking, and automatic saving, while the file structure confirms a modern React/Next.js approach with components, hooks, and Supabase integration for the backend.

##### File Structure
- Top-Level Structure and Key Directories:
- The project includes typical configuration files (package.json, tsconfig.json, eslint.config.mjs) and Next.js configuration (next.config.ts).
- The "src/app" folder contains the primary application routing, layouts, pages (e.g., page.tsx), and even an "auth" section including callback routes for authentication.
- There is a clear separation of UI components in both "src/app/components" and "src/components/ui" (note cards and various form elements).
- Business logic and shared state management are handled within "src/contexts" (AuthContext.tsx) and "src/hooks" (useNotes.ts) for note operations.
- Data access is encapsulated in "src/lib", where Supabase integration (supabase.ts) and other utility functions are defined.
- Additionally, type definitions are organized in "src/types", keeping the data contracts clear.

##### Key Components and Their Roles
a. Frontend/User Interface:
- Layer: Next.js pages (src/app/page.tsx and layout.tsx) along with components for rendering notes (NoteCard, AddNoteForm, etc.) and UI elements in the "src/components/ui" folder.
- Interaction Components: Components like AuthForm for login and other feedback UI elements for user prompts.
b. Authentication & Routing:
- The authentication routing under "src/app/auth" and "src/app/auth/callback" manages user sign-in/sign-out and possibly user authorization with external OAuth or Supabase’s auth services.
- AuthContext (in src/contexts) facilitates session management and state sharing throughout the app.
c. Business Logic:
- Custom hooks (e.g., useNotes) handle note operations, their states, and triggers for saving or deletion.
d. Data Access & Persistence:
- The "src/lib/supabase.ts" module is responsible for interacting with the Supabase backend, effectively acting as the data layer for storing and retrieving notes.
- Utility functions in "src/lib/utils.ts" support data formatting or common functionality.
e. External Integrations:
- Supabase serves as the primary backend/data service, handling the database and perhaps authentication.

##### Relationships and Interactions
- Users interact with the frontend (browser) that is rendered through Next.js pages and components.
- UI components trigger business logic via custom hooks (e.g., useNotes) and state management via React Context (AuthContext).
- Authentication flows are managed through dedicated routes and callback components.
- When data (notes) is created, updated, or deleted, the business logic communicates with the Supabase service via the dedicated lib module.

##### Architectural Patterns and Design Principles
- Separation of concerns is clearly evident, with UI components, state management, business logic, and data access separated into distinctive directories.
- The design follows a component-based architecture typical of modern React/Next.js applications.
- There is a clear MVC-like separation: View (components/UI), Controller/logic (hooks and context), and Model (data layer using Supabase).
- The file structure also supports scalability by isolating UI and functionality in modular components and utilities.

## Diagram (Mermaid)

```mermaid
graph TD
    UserBrowser("User Web Browser"):::browser

    subgraph "Next.js Application Shell"
        AppDir["App Directory (src/app)"]:::nextjs
        Layout["Layout (layout.tsx)"]:::nextjs
        Page["Page (page.tsx)"]:::nextjs
    end

    subgraph "UI Components Layer"
        NotesComponent["Notes Component (Notes.tsx)"]:::ui
        NoteCard["NoteCard (NoteCard.tsx)"]:::ui
        AddNoteForm["Add Note Form (AddNoteForm.tsx)"]:::ui
        AuthForm["Auth Form (AuthForm.tsx)"]:::ui
        FeedbackMsg["Feedback Message (FeedbackMessage.tsx)"]:::ui
        UILibrary["UI Library (src/components/ui)"]:::ui
    end

    subgraph "Business Logic"
        UseNotes["useNotes Hook (useNotes.ts)"]:::logic
        AuthContext["Auth Context (AuthContext.tsx)"]:::logic
    end

    subgraph "Authentication Module"
        AuthRoutes["Auth Routes (src/app/auth)"]:::auth
        AuthCallback["Auth Callback (route.ts)"]:::auth
    end

    subgraph "Data Layer"
        Supabase["Supabase Integration (supabase.ts)"]:::data
        Utilities["Utilities (utils.ts)"]:::data
    end

    TypeDefs["Type Definitions (notes.ts)"]:::types

    %% Connections between layers
    UserBrowser --> AppDir
    AppDir --> Layout
    Layout --> Page
    Page --> NotesComponent

    %% UI Components interactions
    NotesComponent -->|"triggers"| UseNotes
    NoteCard -->|"updates"| UseNotes
    AddNoteForm -->|"creates"| UseNotes
    AuthForm -->|"initiates"| AuthRoutes
    FeedbackMsg -->|"notifies"| AuthContext

    %% Business Logic to Data Layer and Types
    UseNotes -->|"persists"| Supabase
    AuthContext -->|"manages"| Supabase
    UseNotes -->|"utilizes"| TypeDefs

    %% Authentication flows
    AuthRoutes -->|"callback"| AuthCallback
    AuthContext -->|"controls"| AuthRoutes

    %% Click Events for Next.js Application Shell
    click AppDir "https://github.com/bevanlewis/note-wall/tree/main/src/app"
    click Layout "https://github.com/bevanlewis/note-wall/blob/main/src/app/layout.tsx"
    click Page "https://github.com/bevanlewis/note-wall/blob/main/src/app/page.tsx"

    %% Click Events for UI Components Layer
    click NotesComponent "https://github.com/bevanlewis/note-wall/blob/main/src/app/components/Notes.tsx"
    click NoteCard "https://github.com/bevanlewis/note-wall/blob/main/src/components/NoteCard.tsx"
    click AddNoteForm "https://github.com/bevanlewis/note-wall/blob/main/src/components/AddNoteForm.tsx"
    click AuthForm "https://github.com/bevanlewis/note-wall/blob/main/src/components/AuthForm.tsx"
    click FeedbackMsg "https://github.com/bevanlewis/note-wall/blob/main/src/components/FeedbackMessage.tsx"
    click UILibrary "https://github.com/bevanlewis/note-wall/tree/main/src/components/ui"

    %% Click Events for Business Logic
    click UseNotes "https://github.com/bevanlewis/note-wall/blob/main/src/hooks/useNotes.ts"
    click AuthContext "https://github.com/bevanlewis/note-wall/blob/main/src/contexts/AuthContext.tsx"

    %% Click Events for Authentication Module
    click AuthRoutes "https://github.com/bevanlewis/note-wall/tree/main/src/app/auth"
    click AuthCallback "https://github.com/bevanlewis/note-wall/blob/main/src/app/auth/callback/route.ts"

    %% Click Events for Data Layer
    click Supabase "https://github.com/bevanlewis/note-wall/blob/main/src/lib/supabase.ts"
    click Utilities "https://github.com/bevanlewis/note-wall/blob/main/src/lib/utils.ts"

    %% Click Event for Type Definitions
    click TypeDefs "https://github.com/bevanlewis/note-wall/blob/main/src/types/notes.ts"

    %% Styles
    classDef browser fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef nextjs fill:#92DCE5,stroke:#333,stroke-width:2px;
    classDef ui fill:#BDE0FE,stroke:#333,stroke-width:2px;
    classDef logic fill:#FFB4A2,stroke:#333,stroke-width:2px;
    classDef auth fill:#B5EAD7,stroke:#333,stroke-width:2px;
    classDef data fill:#C7CEEA,stroke:#333,stroke-width:2px;
    classDef types fill:#F7D6E0,stroke:#333,stroke-width:2px;

    class UserBrowser browser;
    class AppDir,Layout,Page nextjs;
    class NotesComponent,NoteCard,AddNoteForm,AuthForm,FeedbackMsg,UILibrary ui;
    class UseNotes,AuthContext logic;
    class AuthRoutes,AuthCallback auth;
    class Supabase,Utilities data;
    class TypeDefs types;
```
