# z-me/syncprojectsekainotion architecture

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

- Interactive diagram: https://gitdiagram.com/z-me/syncprojectsekainotion
- Repository: https://github.com/z-me/syncprojectsekainotion

## Overview

##### Project Type and Purpose
- It is an integration project that connects NotionDB and Google Sheets using GAS.
- The purpose is to manage and synchronize data between these two systems. This is evidenced by the README details for production and development environments (with specific spreadsheet and GAS project IDs) and the presence of components such as “connectNotion” and “setSpreadSheet”.

##### Analyzing the File Structure
- The repository’s top-level files (like package.json, tsconfig.json, build.js) support the TypeScript build process and project configuration.
- The src folder contains:
- appsscript.json: This file configures the GAS project.
- main.ts: Likely the central entry point.
- components folder: Contains individual modules:
- connectNotion.ts – Manages connection to Notion.
- customFunctions.ts – Provides functions that may be available as spreadsheet custom functions.
- menu.ts – Sets up a custom menu in Google Sheets.
- setSpreadSheet.ts – Handles spreadsheet-specific operations.
- lib folder: Includes a custom fetch.ts (likely a wrapper around GAS URL fetch) and types.ts (for type definitions).
- This clearly shows an architectural pattern where responsibilities are separated by functionality in distinct modules.

##### Insights from the README
- The README explains how to deploy to development or production environments, including build and push scripts, highlighting the build-to-deploy pipeline.
- The “NPMスクリプト” section describes commands to format code (via prettier), build the GAS code, and deploy changes. This reinforces that the build process is a central part of the architecture.

a. Main Components:
- Build Process:
- Build.js and npm scripts that transform the TypeScript source to GAS-compatible code.
- Application Core (GAS Code):
- Main module (main.ts)
- Components:
▪ connectNotion (managing Notion DB connection)
▪ customFunctions (spreadsheet custom functions)
▪ menu (for UI integration in Google Sheets)
▪ setSpreadSheet (to interact with the spreadsheet)
- Library layer:
▪ fetch.ts (HTTP requests abstraction)
▪ types.ts (type definitions)
- External Systems:
- NotionDB (as a data source/target)
- Google Spreadsheet (GSS) which is directly interacted with via GAS.
- Deployment Environments:
- Separate Prod and Dev configurations (as shown in the README).

b. Relationships and Interactions:
- The Build Process (npm and build.js) compiles the TypeScript files (including the main file and component modules) into GAS-ready code.
- The main.ts orchestrates the different components (menu, custom functions, Notion connection, and spreadsheet operations).
- The connectNotion module will manage API calls to Notion, potentially using the fetch.ts functions from the library.
- The setSpreadSheet component is responsible for reading/writing to the Google spreadsheet.
- Custom functions provide user-accessible features inside Google Sheets.
- Menus integrate the custom functions into the Google Sheets UI.
- The project interacts externally with Notion and the Google Spreadsheet, with clear environment-specific endpoints (both for the spreadsheet and the GAS project settings).

c. Architectural Patterns and Design Principles:
- Modular design / separation of concerns: Each component (Notion connection, UI menus, spreadsheet integration) is separated into its own module.
- Clear build and deployment pipeline: Leveraging npm scripts to build, push, and deploy for different environments.
- Layered architecture: With a lib layer for utilities and types, and a higher-level components layer that encapsulates business logic.

d. Relevant Technologies/Frameworks:
- Google Apps Script as the runtime environment.
- TypeScript as the primary language.
- Prettier for code formatting.
- Notion API (implied by module functionality and the project’s description).
- Google Sheets as the front-end user interface and data store.
- Node.js (via npm scripts) for the build and deployment process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    BP("Build & Deployment Pipeline"):::build
    GPC("GAS Project Configuration"):::gas

    subgraph "GAS Core Modules"
        MC("Main Controller (main.ts)"):::gas
        CN("Connect Notion Module (connectNotion.ts)"):::comp
        CF("Custom Functions Module (customFunctions.ts)"):::comp
        MN("Menu Module (menu.ts)"):::comp
        SS("Spreadsheet Interface Module (setSpreadSheet.ts)"):::comp
    end

    subgraph "Utility Library"
        FL("HTTP Requests/Fetch Wrapper (fetch.ts)"):::lib
        TDN("Type Definitions (types.ts)"):::lib
    end

    ND(("Notion Database")):::external
    GS(("Google Spreadsheet")):::external

    %% Build Process Flow
    BP --> GPC
    GPC --> MC

    %% Core Modules Interactions
    MC --> CN
    MC --> CF
    MC --> MN
    MC --> SS

    %% Utility Usage
    CN --> FL

    %% External Systems Interactions
    CN -->|"NotionAPI"| ND
    SS -->|"SpreadsheetIO"| GS
    CF -->|"CustomFunction"| GS
    MN -->|"MenuUI"| GS

    %% Styles
    classDef build fill:#f9d776,stroke:#000,stroke-width:2px;
    classDef gas fill:#aed6f1,stroke:#154360,stroke-width:2px;
    classDef comp fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef lib fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef external fill:#f9e79f,stroke:#ac7339,stroke-width:2px;

    %% Click Events
    click BP "https://github.com/z-me/syncprojectsekainotion/blob/main/build.js"
    click BP "https://github.com/z-me/syncprojectsekainotion/blob/main/package.json"
    click GPC "https://github.com/z-me/syncprojectsekainotion/blob/main/src/appsscript.json"
    click MC "https://github.com/z-me/syncprojectsekainotion/blob/main/src/main.ts"
    click CN "https://github.com/z-me/syncprojectsekainotion/blob/main/src/components/connectNotion.ts"
    click CF "https://github.com/z-me/syncprojectsekainotion/blob/main/src/components/customFunctions.ts"
    click MN "https://github.com/z-me/syncprojectsekainotion/blob/main/src/components/menu.ts"
    click SS "https://github.com/z-me/syncprojectsekainotion/blob/main/src/components/setSpreadSheet.ts"
    click FL "https://github.com/z-me/syncprojectsekainotion/blob/main/src/lib/fetch.ts"
    click TDN "https://github.com/z-me/syncprojectsekainotion/blob/main/src/lib/types.ts"
```
