# minami22x3/planio architecture

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

- Interactive diagram: https://gitdiagram.com/minami22x3/planio
- Repository: https://github.com/minami22x3/planio

## Overview

##### Project Type and Purpose
- This is a full-stack Next.js application (“Plan.io”) combining a React/Next.js front end, a GraphQL API layer, and a PostgreSQL database (via Supabase + Drizzle ORM). It provides a To-Do list productivity tool with server-side rendering, client interactivity, migrations, and code-generated GraphQL schema.

##### High-Level System Components
a. Frontend Layer
- Next.js “app” directory (app/page.tsx, app/layout.tsx) for SSR/SSG and client hydration
- React UI components in components/ui
- Global styling (Tailwind via tailwind.config.ts + globals.scss)
- Apollo Client (app/_apollo-provider.tsx) for GraphQL
b. API Layer
- Next.js API Route: /api/graphql (server/graphql.ts + app/api/graphql/route.ts)
- Apollo Server built on Drizzle schema
- Instrumentation (instrumentation.ts) and Sentry (sentry.*.config.ts)
c. Persistence Layer
- Supabase local/PostgreSQL (docker-compose.yml, supabase/config.toml)
- Drizzle ORM for schema definition (db/schema) + Migrations (db/migrations)
- Codegen (codegen.ts, gql/schema.graphql → gql/types.ts + gql/operations)
d. DevOps & Tooling
- Docker Compose for Supabase stack
- Yarn scripts for dev, migrations, codegen
- ESLint/Husky/Prettier configuration

##### Relationships and Data Flows
- User’s Browser ⇄ Next.js Frontend (SSR pages + client GraphQL queries)
- Frontend → Apollo Client → GraphQL Endpoint (Next.js API)
- GraphQL Server → Drizzle ORM → Supabase/Postgres
- Dev tools (Yarn, Drizzle-kit, GraphQL-codegen) operate at build time

##### Architectural Patterns & Principles
- Monolithic full-stack: UI + API co-located in Next.js
- Layered architecture: Presentation → API → Data Access → Database
- Code-first schema: Drizzle definitions → SQL migrations + GraphQL schema
- Type safety end-to-end: TypeScript in frontend, backend, DB, GraphQL

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Runtime Layer
    subgraph "Runtime"
        direction TB
        Browser["User Browser"]:::external
        subgraph "Frontend (Next.js)" 
            direction TB
            SSR["SSR Next.js App"]:::frontend
            CSR["Hydrated React UI"]:::frontend
            ApolloClient["Apollo Client"]:::api
        end
        subgraph "Backend (Next.js API)" 
            direction TB
            GraphQLEndpoint["GraphQL API Route"]:::api
            ApolloServer["Apollo Server"]:::api
            Instrumentation["Instrumentation & Sentry"]:::api
        end
        subgraph "Persistence" 
            direction TB
            DrizzleORM["Drizzle ORM"]:::db
            Postgres["Supabase/PostgreSQL"]:::db
        end

        Browser -->|"HTTPS"| SSR
        SSR -->|"HTML"| Browser
        Browser -->|"hydrate"| CSR
        CSR -->|"GraphQL"| ApolloClient
        ApolloClient -->|"GraphQL"| GraphQLEndpoint
        GraphQLEndpoint -->|"exec()"| ApolloServer
        ApolloServer -->|"SQL"| DrizzleORM
        DrizzleORM -->|"DB Connection"| Postgres
    end

    %% Build & Dev Tools
    subgraph "Build & Dev Tools"
        direction TB
        DockerCompose["Docker Compose"]:::devtools
        Codegen["GraphQL Codegen"]:::devtools
        Migrations["Drizzle-kit Migrations"]:::devtools
        Linting["ESLint & Prettier & Husky"]:::devtools
    end

    Codegen -.->|"generate schema"| gqlFolder["gql/ folder"]:::devtools
    Migrations -.->|"apply migrations"| Postgres
    DockerCompose -.->|"start Supabase"| Postgres
    Linting -.->|"pre-commit"| SSR

    %% External Services
    subgraph "External Services"
        direction TB
        S3["S3 Storage"]:::external
    end
    ApolloServer -->|"error tracking"| S3

    %% Click Events
    click SSR "https://github.com/minami22x3/planio/blob/main/app/page.tsx"
    click CSR "https://github.com/minami22x3/planio/blob/main/app/_apollo-provider.tsx"
    click Browser "https://github.com/minami22x3/planio/blob/main/app/manifest.ts"
    click ApolloClient "https://github.com/minami22x3/planio/blob/main/app/_apollo-provider.tsx"
    click GraphQLEndpoint "https://github.com/minami22x3/planio/blob/main/app/api/graphql/route.ts"
    click ApolloServer "https://github.com/minami22x3/planio/blob/main/server/graphql.ts"
    click Instrumentation "https://github.com/minami22x3/planio/blob/main/instrumentation.ts"
    click DrizzleORM "https://github.com/minami22x3/planio/blob/main/db/schema/index.ts"
    click Migrations "https://github.com/minami22x3/planio/blob/main/db/migrations/20250116135955_init.sql"
    click DockerCompose "https://github.com/minami22x3/planio/blob/main/docker-compose.yml"
    click Codegen "https://github.com/minami22x3/planio/blob/main/codegen.ts"
    click Linting "https://github.com/minami22x3/planio/blob/main/eslint.config.mjs"
    click Browser "https://github.com/minami22x3/planio/blob/main/app/globals.scss"

    %% Styles
    classDef frontend fill:#fabd2f,stroke:#282828,color:#282828
    classDef api fill:#b8bb26,stroke:#282828,color:#282828
    classDef db fill:#8ec07c,stroke:#282828,color:#282828
    classDef devtools fill:#fe8019,stroke:#282828,color:#282828
    classDef external fill:#83a598,stroke:#282828,color:#282828
```
