# kaishoya/drink-counter architecture

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

- Interactive diagram: https://gitdiagram.com/kaishoya/drink-counter
- Repository: https://github.com/kaishoya/drink-counter

## Overview

##### Project Type and Purpose
- This is a full-stack web application built with Nuxt 3 (Vue) on the front end and Supabase on the back end.
- Key features: user authentication (Supabase Auth), drink counter pages, charting, and CRUD operations on drinks and labels via Supabase.

##### File-Structure Analysis
- Top-Level:
- nuxt.config.ts, package.json, pnpm-lock.yaml: Nuxt & dependency config.
- compose.yaml: likely Docker Compose setup for local Supabase.
- supabase/: database migrations, seed data, config.toml.
- app/: Nuxt application folder containing pages, components, layouts, plugins, middleware, assets, utils.
- store/: Pinia state management, split into data (models mirroring Supabase tables), pages (composed view models), supabase client store, and user store.
- i18n/: internationalization config and locale files.
- public/: static files (e.g., verification HTML).
- GitHub workflows: CI, linting, release, staging/production deploy, migration.

- Patterns:
- Atomic design for components (atoms, molecules, domain-based grouping).
- Pinia layered stores: data stores → page stores → component view usage.
- Supabase CLI and migrations for schema management.
- Environment configuration (.env.template).

##### Insights from README
- Confirms atomic/component structure, Pinia usage, and supabase folder roles.
- Development flow: supabase start → pnpm dev.
- Release and branching conventions.
- Clarifies responsibilities for each top-level folder.

##### Main Components
a. Frontend Application
- Nuxt 3 Server and Client
- Vue Pages (pages/), Components (atoms→molecules→domain), Layouts, Plugins, Middleware.
- Pinia Store Modules: data models, page stores, supabase store, user store.
- i18n.

b. API Layer
- Supabase-JS client initiated in a Pinia supabase store.
- REST/RPC calls to Supabase PostgREST, Auth, and Functions (if any).

c. Backend Services
- Supabase Postgres Database with tables (drinks, drink_counters, drink_labels, user_settings) and RLS policies.
- Supabase Auth for user management.
- Supabase Functions (serverless) if used for custom logic (not present in file tree but reserved).
- Migration service (CLI applying SQL in supabase/migrations).

d. External Services and Infrastructure
- CI/CD: GitHub Actions (lint, tests, migrate, release).
- Hosting: Vercel (Nuxt deployed), Supabase hosted DB.
- supabase CLI & local Docker compose for local dev.
- GitHub (repo, versioning).

##### Interactions and Data Flows
- User opens Nuxt app in browser → requests page from Nuxt server or static host.
- Nuxt page triggers Pinia actions → calls Supabase-JS client with user’s access token.
- Supabase Auth endpoint verifies user → returns session.
- Pinia data store performs CRUD via Supabase REST/RPC → database tables.
- Query results flow back through Pinia into Vue components → rendered charts/tables/UI.
- CI pipeline triggers on push → runs lint, tests, supabase migration (production/staging), deploys to Vercel.

##### Architectural Patterns and Principles
- Component-based UI with atomic/molecular design.
- Layered state management: data models abstract raw DB, page stores compose multiple data models.
- Clear separation between presentation (Vue), state (Pinia), and persistence (Supabase).
- Use of environment configurations for API keys and endpoints.
- Infrastructure as code for migrations (SQL files) and CI workflows.

##### Elements
- Frontend (Vue/Nuxt)
- State Management (Pinia)
- Backend Services (Supabase)
- CI/CD & Hosting
- Environment artifacts (.env, compose.yaml) near Supabase components to show local dev setup.
- Migration flow: SQL files → applied to DB.

Summary
– Capture the atomic component hierarchy, Pinia store layering, Supabase roles, and CI/CD pipeline.
– This will give a comprehensive, accurate representation of the drink-counter system architecture.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Browser["Browser Client"]:::external
        NuxtApp["Nuxt 3 App"]:::frontend
        Pages["Vue Pages"]:::frontend
        Components["Vue Components"]:::frontend
        Layouts["Layouts"]:::frontend
        Plugins["Plugins"]:::frontend
        Middleware["Middleware"]:::frontend
        Assets["Assets & Styles"]:::frontend
        Utils["Utilities"]:::frontend
        I18n["Internationalization"]:::frontend
    end

    %% State Layer
    subgraph "State Layer (Pinia Stores)"
        direction TB
        AppStore["App Store"]:::state
        DataStores["Data Stores"]:::state
        PageStores["Page Stores"]:::state
        SupabaseStore["Supabase Client Store"]:::state
        UserStore["User Store"]:::state
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        SupabaseJS["Supabase-JS Client"]:::api
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        Auth["Supabase Auth"]:::backend
        Postgres["Supabase Postgres"]:::backend
        Migrations["Migrations & Seed"]:::backend
        Functions["Supabase Functions"]:::backend
    end

    %% Infrastructure Layer
    subgraph "DevOps & Hosting"
        direction TB
        DockerCompose["Docker Compose (Local)"]:::infra
        EnvTemplate[".env.template"]:::infra
        GitHubActions["GitHub Actions"]:::infra
        Vercel["Vercel Hosting"]:::infra
    end

    %% Connections
    Browser -->|"HTTPS"| NuxtApp
    NuxtApp -->|"initializes"| AppStore
    NuxtApp -->|"renders"| Pages
    Pages --> Components
    Pages --> Layouts
    NuxtApp --> Plugins
    NuxtApp --> Middleware
    NuxtApp --> Assets
    NuxtApp --> Utils
    NuxtApp --> I18n

    AppStore --> DataStores
    AppStore --> PageStores
    AppStore --> SupabaseStore
    AppStore --> UserStore

    DataStores --> SupabaseJS
    PageStores --> SupabaseJS
    SupabaseStore --> SupabaseJS
    UserStore --> SupabaseJS

    SupabaseJS -->|"Auth/API calls"| Auth
    SupabaseJS -->|"REST/RPC"| Postgres
    SupabaseJS -->|"Invoke"| Functions
    Migrations -->|"apply SQL"| Postgres
    DockerCompose --> Auth
    DockerCompose --> Postgres
    EnvTemplate --> Auth
    EnvTemplate --> Postgres

    GitHubActions --> Migrations
    GitHubActions --> Vercel
    GitHubActions -->|"CI/CD pipeline"| NuxtApp
    Vercel --> NuxtApp

    %% Click Events
    click NuxtApp "https://github.com/kaishoya/drink-counter/blob/main/nuxt.config.ts"
    click Pages "https://github.com/kaishoya/drink-counter/tree/main/app/pages/"
    click Components "https://github.com/kaishoya/drink-counter/tree/main/app/components/base/"
    click Components "https://github.com/kaishoya/drink-counter/tree/main/app/components/common/"
    click Components "https://github.com/kaishoya/drink-counter/tree/main/app/components/domain/"
    click Layouts "https://github.com/kaishoya/drink-counter/blob/main/app/layouts/custom.vue"
    click Plugins "https://github.com/kaishoya/drink-counter/blob/main/app/plugins/error.client.ts"
    click Plugins "https://github.com/kaishoya/drink-counter/blob/main/app/plugins/vue-draggable.client.ts"
    click Middleware "https://github.com/kaishoya/drink-counter/blob/main/app/middleware/auth.ts"
    click Assets "https://github.com/kaishoya/drink-counter/blob/main/app/assets/scss/index.scss"
    click Utils "https://github.com/kaishoya/drink-counter/blob/main/app/utils/common.ts"
    click Utils "https://github.com/kaishoya/drink-counter/blob/main/app/utils/customError.ts"
    click Utils "https://github.com/kaishoya/drink-counter/blob/main/app/utils/toast.ts"
    click Utils "https://github.com/kaishoya/drink-counter/blob/main/app/utils/locales.ts"
    click Utils "https://github.com/kaishoya/drink-counter/blob/main/app/utils/common.spec.ts"
    click I18n "https://github.com/kaishoya/drink-counter/blob/main/i18n/i18n.config.ts"
    click I18n "https://github.com/kaishoya/drink-counter/blob/main/i18n/locales/en.yaml"
    click I18n "https://github.com/kaishoya/drink-counter/blob/main/i18n/locales/ja.yaml"
    click AppStore "https://github.com/kaishoya/drink-counter/blob/main/store/app/index.ts"
    click AppStore "https://github.com/kaishoya/drink-counter/blob/main/store/app/state.ts"
    click AppStore "https://github.com/kaishoya/drink-counter/blob/main/store/app/actions.ts"
    click AppStore "https://github.com/kaishoya/drink-counter/blob/main/store/app/getters.ts"
    click DataStores "https://github.com/kaishoya/drink-counter/blob/main/store/data/drinks/index.ts"
    click DataStores "https://github.com/kaishoya/drink-counter/blob/main/store/data/drinkCounters/index.ts"
    click DataStores "https://github.com/kaishoya/drink-counter/blob/main/store/data/drinkLabels/index.ts"
    click DataStores "https://github.com/kaishoya/drink-counter/blob/main/store/data/userSettings/index.ts"
    click PageStores "https://github.com/kaishoya/drink-counter/tree/main/store/pages/index/"
    click PageStores "https://github.com/kaishoya/drink-counter/tree/main/store/pages/drinks/"
    click PageStores "https://github.com/kaishoya/drink-counter/tree/main/store/pages/labels/"
    click PageStores "https://github.com/kaishoya/drink-counter/tree/main/store/pages/data/"
    click PageStores "https://github.com/kaishoya/drink-counter/blob/main/store/pages/settings/index.ts"
    click SupabaseStore "https://github.com/kaishoya/drink-counter/blob/main/store/supabase/index.ts"
    click SupabaseStore "https://github.com/kaishoya/drink-counter/blob/main/store/supabase/state.ts"
    click SupabaseStore "https://github.com/kaishoya/drink-counter/blob/main/store/supabase/actions.ts"
    click SupabaseStore "https://github.com/kaishoya/drink-counter/blob/main/store/supabase/getters.ts"
    click UserStore "https://github.com/kaishoya/drink-counter/blob/main/store/user/index.ts"
    click UserStore "https://github.com/kaishoya/drink-counter/blob/main/store/user/state.ts"
    click UserStore "https://github.com/kaishoya/drink-counter/blob/main/store/user/actions.ts"
    click UserStore "https://github.com/kaishoya/drink-counter/blob/main/store/user/getters.ts"
    click SupabaseJS "https://github.com/kaishoya/drink-counter/blob/main/database.types.ts"
    click SupabaseJS "https://github.com/kaishoya/drink-counter/blob/main/store/supabase/index.ts"
    click Migrations "https://github.com/kaishoya/drink-counter/blob/main/supabase/config.toml"
    click Migrations "https://github.com/kaishoya/drink-counter/tree/main/supabase/migrations/"
    click Migrations "https://github.com/kaishoya/drink-counter/blob/main/supabase/seed.sql"
    click DockerCompose "https://github.com/kaishoya/drink-counter/blob/main/compose.yaml"
    click EnvTemplate "https://github.com/kaishoya/drink-counter/blob/main/.env.template"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/ci-supabase.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/migrate-production.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/staging.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/production.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/lint.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/check-version.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/create-release-note.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/update-version.yaml"
    click GitHubActions "https://github.com/kaishoya/drink-counter/blob/main/.github/workflows/codacy-analysis.yaml"
    click Vercel "https://github.com/kaishoya/drink-counter/blob/main/vercel-ignore-build-step.sh"
    click Vercel "https://github.com/kaishoya/drink-counter/blob/main/package.json"
    click Vercel "https://github.com/kaishoya/drink-counter/blob/main/pnpm-lock.yaml"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#2196F3,color:#0D47A1
    classDef state fill:#E8F5E9,stroke:#4CAF50,color:#1B5E20
    classDef api fill:#FFF3E0,stroke:#FF9800,color:#E65100
    classDef backend fill:#F3E5F5,stroke:#9C27B0,color:#4A148C
    classDef infra fill:#ECEFF1,stroke:#607D8B,color:#263238
    classDef external fill:#FFFFFF,stroke:#000000,color:#000000
```
