# gakuto06250177/morningwinner architecture

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

- Interactive diagram: https://gitdiagram.com/gakuto06250177/morningwinner
- Repository: https://github.com/gakuto06250177/morningwinner

## Overview

##### Project type and purpose
- Full-stack (front-heavy) web application built on Next.js (App Router)
- Purpose: Track attendance/late penalties for four members, persisting data in either LocalStorage or Supabase

##### File structure
- Top-level:
– next.config.ts, vercel.json → Vercel deploy
– package.json, tsconfig.json, ESLint, PostCSS, Tailwind configs
- src/app → Entry points (layout.tsx, page.tsx) using Next.js App Router
- src/components → UI building blocks (SunriseLoading animations, attendance controls, summary table)
- src/hooks → Data access abstraction: useLocalStorageData.ts, useSupabaseData.ts
- src/lib → Low-level API clients: database.ts for LocalStorage, supabase.ts for Supabase
- supabase-schema.sql → DB schema for Supabase

##### README for architecture insights
- Dual persistence strategy (LocalStorage vs. Supabase) selectable via environment variables
- Client-side rendering with occasional SSR/SSG by Next.js
- Tailwind CSS for styling
- Vercel for hosting

##### Main components and their interactions
a. Browser / Client
– Next.js pages and React components render UI
– Custom hooks decide storage target
– LocalStorage API or Supabase JS client invoked on user actions
b. Next.js hosting (Vercel)
– Serves static assets and server-side rendered pages
– Environment variables configure Supabase connectivity
c. Supabase (optional backend)
– Hosted PostgreSQL + auto-generated REST / GraphQL endpoints
– Auth & real-time features (not in use but available)
d. LocalStorage (fallback storage)
– Browser’s key/value store; no network calls
e. Shared types and utilities
– src/types define data models
– src/lib contains client abstractions

##### Architectural patterns and design principles
- Layered architecture:
– Presentation (React pages/components in src/app, src/components)
– Data Access (hooks in src/hooks)
– Infrastructure Adapters (src/lib)
- Strategy Pattern:
– StorageStrategy = LocalStorage or Supabase, injected via hooks
- Separation of concerns:
– UI vs. business logic vs. persistence

## Diagram (Mermaid)

```mermaid
graph TB
    %% Hosting Layer
    Vercel["Vercel (Next.js 15 App Router)"]:::infra
    click Vercel "https://github.com/gakuto06250177/morningwinner/blob/main/vercel.json"
    click Vercel "https://github.com/gakuto06250177/morningwinner/blob/main/next.config.ts"

    %% Browser Boundary
    subgraph "Browser / Client"
        direction TB
        subgraph "UI Layer" 
            direction TB
            NextApp["Next.js App Entry Points"]:::ui
            click NextApp "https://github.com/gakuto06250177/morningwinner/blob/main/src/app/layout.tsx"
            click NextApp "https://github.com/gakuto06250177/morningwinner/blob/main/src/app/page.tsx"
            click NextApp "https://github.com/gakuto06250177/morningwinner/blob/main/src/app/globals.css"
            Components["React Components (src/components)"]:::ui
            click Components "https://github.com/gakuto06250177/morningwinner/tree/main/src/components"
        end

        subgraph "Data Access Layer"
            direction TB
            Hooks["Custom Hooks"]:::ui
            click Hooks "https://github.com/gakuto06250177/morningwinner/blob/main/src/hooks/useLocalStorageData.ts"
            click Hooks "https://github.com/gakuto06250177/morningwinner/blob/main/src/hooks/useSupabaseData.ts"
            Types["Shared Types & Models"]:::data
            click Types "https://github.com/gakuto06250177/morningwinner/blob/main/src/types/index.ts"
        end
    end

    %% Decision for storage strategy
    EnvDecision{"ENV NEXT_PUBLIC_SUPABASE_*\nset?"}:::infra

    %% Infrastructure Adapters
    subgraph "Infrastructure Adapters"
        direction TB
        LocalAdapter["LocalStorage Adapter"]:::infra
        click LocalAdapter "https://github.com/gakuto06250177/morningwinner/blob/main/src/lib/database.ts"
        SupabaseAdapter["Supabase Adapter"]:::infra
        click SupabaseAdapter "https://github.com/gakuto06250177/morningwinner/blob/main/src/lib/supabase.ts"
    end

    %% Data Stores
    LocalStore[("LocalStorage")]:::data
    SupabaseDB[("Supabase PostgreSQL")]:::data
    click SupabaseDB "https://github.com/gakuto06250177/morningwinner/blob/main/supabase-schema.sql"

    %% Configuration
    subgraph "Project Configuration"
        direction TB
        TSConfig["tsconfig.json"]:::infra
        ESLint["eslint.config.mjs"]:::infra
        PostCSS["postcss.config.mjs"]:::infra
        Tailwind["Tailwind CSS"]:::infra
    end

    %% Connections
    Vercel -->|"serves UI"| NextApp
    Vercel -->|"SSR/SSG data fetch"| SupabaseAdapter

    NextApp -->|"renders"| Components
    Components -->|"calls hooks"| Hooks
    Hooks -->|"reads/writes"| EnvDecision

    EnvDecision -->|"No (use LocalStorage)"| LocalAdapter
    EnvDecision -->|"Yes (use Supabase)"| SupabaseAdapter

    LocalAdapter -->|"key/value operations"| LocalStore
    SupabaseAdapter -->|"REST/GraphQL calls"| SupabaseDB

    %% Styling
    classDef ui fill:#cfe2f3,stroke:#0366d6,color:#000
    classDef data fill:#d9ead3,stroke:#6aa84f,color:#000
    classDef infra fill:#f2f2f2,stroke:#999,color:#000
    classDef external fill:#ececec,stroke:#777,color:#000
```
