# melonps/puchiyakusoku architecture

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

- Interactive diagram: https://gitdiagram.com/melonps/puchiyakusoku
- Repository: https://github.com/melonps/puchiyakusoku

## Overview

##### Project Type and Purpose
- This is a full‐stack application designed as a “promise sharing” app that operates entirely within LINE. Users can share promises, and there is no login or installation required.
- The README emphasizes that the app works on LINE, while the file structure shows a modern JavaScript stack (Next.js) for the frontend and several backend components, including API endpoints, GraphQL operations, and additional microservices (in both TypeScript and Python).

##### Main Components and Their Locations
- Frontend UI (Next.js App):
– Located in the src/app directory with subfolders for pages, layout, and UI components (e.g., “Badge.tsx”, “Header.tsx”, “ImageWrapper.tsx”).
– Related elements include themes, providers (LiffProvider for LINE integration), hooks, and contexts.
- API Endpoints & GraphQL:
– Found under src/app/api (including authentication endpoints under nextauth and GraphQL queries/mutations in src/app/graphql and src/graphql).
– The generated schemas (in src/generated) indicate a GraphQL-based communication with the backend.
- Database and ORM:
– The prisma folder (including schema.prisma and migration scripts) shows usage of Prisma as the ORM to interact with the database.
– There’s also a seed file and multiple migrations indicating a structured database evolution.
- Additional Microservices:
- Reminder/Python Services:
– The reminder folder contains subprojects (define-task and remind) implemented in Python with their own .gitignore, .gcloudignore, and dependencies (requirements.txt, pyproject.toml). They handle task definitions and reminder functionality (likely scheduled or event-driven tasks).
- Supabase Functions:
– The supabase/functions folder holds deno-based functions named sendLineMessage and sendMessage. These functions appear to be used for sending messages via LINE, likely triggered either by the application or some scheduled service.
- External Services:
- LINE Integration:
– Overarching theme from the README (“LINE上で完結”) and the use of LIFF providers suggests deep integration with LINE’s platform.

##### Relationships and Data Flow
- The Browser/LINE Client:
– Interacts with the frontend Next.js app (via pages and UI components) which is the main interface.
- Frontend to API Communication:
– The Next.js pages, through hooks and context, send requests to API routes (including NextAuth for authentication and GraphQL endpoints for data operations).
- API to Database:
– API endpoints leverage the Prisma layer (in src/lib/prisma and prisma schema) to read/write persistent data.
- Integration with External Messaging:
- Supabase functions (sendLineMessage/sendMessage) and embedded Python microservices handle interaction with LINE’s messaging APIs. They may get triggered by events or schedules (as hinted by the naming in the “reminder” folder and deno functions).
- Internal Communication:
– The GraphQL schema and generated types indicate internal data contracts, while the next-auth endpoints mediate user session management.

##### Architectural Patterns and Design Principles
- Full-Stack Separation:
– Clear delineation between frontend (Next.js), backend APIs (Next.js API routes and GraphQL), and auxiliary services (Python reminder services, Supabase functions).
- Microservice and Modular Design:
– The reminder functionality is separated into a distinct Python module, indicating a microservice approach for scheduling/reminder tasks.
– Supabase functions for messaging suggest serverless or function-based components that operate independently yet trigger core application workflows.
- Use of Standard Frameworks and Best Practices:
– Next.js for server-side rendering and routing.
– Prisma as a clear ORM layer that abstracts the database.
– NextAuth for authentication.
– GraphQL for structured API communication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A1["Browser/LINE Client"]:::external
        B1["Frontend (Next.js App)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        C1["API Endpoints"]:::backend
        C2["GraphQL (App)"]:::backend
        C3["GraphQL (Core)"]:::backend
        C4["GraphQL Schema"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        D1["Prisma Config"]:::database
        D2["Prisma Client"]:::database
    end

    %% Auxiliary Services
    subgraph "Auxiliary Services"
        E1["Define Task (Python)"]:::microservice
        E2["Remind Service (Python)"]:::microservice
        F1["sendLineMessage (Supabase)"]:::messaging
        F2["sendMessage (Supabase)"]:::messaging
    end

    %% External Integration
    subgraph "External Integration"
        G1["LINE Platform"]:::external
    end

    %% Connections
    A1 --> B1
    B1 --> C1
    B1 --> C2
    B1 --> C3
    B1 --> C4
    C1 --> D1
    C1 --> D2
    C1 --> E1
    C1 --> E2
    C1 --> F1
    C1 --> F2
    E1 --> G1
    E2 --> G1
    F1 --> G1
    F2 --> G1

    %% Click Events
    click B1 "https://github.com/melonps/puchiyakusoku/tree/master/src/app"
    click C1 "https://github.com/melonps/puchiyakusoku/tree/master/src/app/api"
    click C2 "https://github.com/melonps/puchiyakusoku/tree/master/src/app/graphql"
    click C3 "https://github.com/melonps/puchiyakusoku/tree/master/src/graphql"
    click C4 "https://github.com/melonps/puchiyakusoku/tree/master/src/generated"
    click D1 "https://github.com/melonps/puchiyakusoku/tree/master/src/prisma"
    click D2 "https://github.com/melonps/puchiyakusoku/blob/master/src/lib/prisma.ts"
    click E1 "https://github.com/melonps/puchiyakusoku/tree/master/reminder/define-task"
    click E2 "https://github.com/melonps/puchiyakusoku/tree/master/reminder/remind"
    click F1 "https://github.com/melonps/puchiyakusoku/tree/master/supabase/functions/sendLineMessage"
    click F2 "https://github.com/melonps/puchiyakusoku/tree/master/supabase/functions/sendMessage"

    %% Styles
    classDef frontend fill:#FFEBEE,stroke:#C62828,stroke-width:2px;
    classDef backend fill:#E3F2FD,stroke:#1565C0,stroke-width:2px;
    classDef database fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px;
    classDef microservice fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px;
    classDef messaging fill:#FFFDE7,stroke:#F9A825,stroke-width:2px;
    classDef external fill:#E0F7FA,stroke:#00695C,stroke-width:2px;
```
