# baba-ti/automatic_product_management architecture

> Architecture diagram of the GitHub repository baba-ti/automatic_product_management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baba-ti/automatic_product_management
- Repository: https://github.com/baba-ti/automatic_product_management

## Overview

Automatic Product Management is an n8n workflow that accepts questions through chat, Slack, or a calling workflow, normalizes them, queries a PostgreSQL database with AI-assisted table selection and SQL generation, and returns an answer through the configured output channel. Its README also documents a separate example-data preparation capability: a notebook defines the sample schema, and a Python generator inserts test data. Workflow internals are represented from README descriptions; the workflow JSON and notebook were not sampled, so their detailed wiring is not independently verified.

Main entry points: [`product_management.json`](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json) (Common response), [`insert_tables_for_supabase.py`](https://github.com/baba-ti/automatic_product_management/blob/main/insert_tables_for_supabase.py) (Sample data generator), [`create_tables_for_supabase.ipynb`](https://github.com/baba-ti/automatic_product_management/blob/main/create_tables_for_supabase.ipynb) (Example schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Input adapters"]
  node_chat["n8n Chat"]
  node_slackin["Slack Input"]
  node_subtrigger["Sub-workflow input"]
end

subgraph group_query["Shared query flow"]
  node_context["Request Context"]
  node_tables["Table selection"]
  node_schema["Schema lookup"]
  node_sql["SQL generation"]
  node_querydb["Read query"]
  node_answer["Answer writing"]
end

subgraph group_outputs["Output adapters"]
  node_response["Common response"]
  node_chatout["Chat response"]
  node_slackout["Reply Slack"]
  node_returner["Caller return"]
end

subgraph group_sampledata["Sample data setup"]
  node_schema_notebook["Example schema"]
  node_generator["Sample data generator"]
end

node_user(("Questioner"))
node_caller(("Workflow caller"))
node_postgres[("PostgreSQL")]
node_openai["OpenAI API"]

node_user -->|"asks via"| node_chat
node_user -->|"messages via"| node_slackin
node_caller -->|"calls with request"| node_subtrigger
node_chat -->|"normalizes request"| node_context
node_slackin -->|"normalizes request"| node_context
node_subtrigger -->|"normalizes request"| node_context
node_context -->|"passes request"| node_tables
node_tables -->|"selects tables for"| node_schema
node_schema -->|"reads metadata"| node_postgres
node_schema -->|"provides schema"| node_sql
node_tables -->|"selects tables with"| node_openai
node_sql -->|"generates SQL with"| node_openai
node_sql -->|"passes query"| node_querydb
node_querydb -->|"reads data"| node_postgres
node_querydb -->|"returns results"| node_answer
node_answer -->|"writes answer with"| node_openai
node_answer -->|"returns answer"| node_response
node_response -->|"routes Chat response"| node_chatout
node_response -->|"routes Slack reply"| node_slackout
node_response -->|"returns to caller"| node_returner
node_chatout -->|"delivers answer"| node_user
node_slackout -->|"sends reply"| node_user
node_returner -->|"returns answer"| node_caller
node_schema_notebook -->|"creates example tables"| node_postgres
node_generator -->|"inserts test data"| node_postgres
node_generator -->|"generates sample text with"| node_openai

click node_chat "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_slackin "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_subtrigger "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_context "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_tables "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_schema "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_sql "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_querydb "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_answer "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_response "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_chatout "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_slackout "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_returner "https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json"
click node_schema_notebook "https://github.com/baba-ti/automatic_product_management/blob/main/create_tables_for_supabase.ipynb"
click node_generator "https://github.com/baba-ti/automatic_product_management/blob/main/insert_tables_for_supabase.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_chat,node_slackin,node_subtrigger toneBlue
class node_context,node_tables,node_schema,node_sql,node_querydb,node_answer,node_postgres toneAmber
class node_response,node_chatout,node_slackout,node_returner,node_openai toneMint
class node_schema_notebook,node_generator toneRose
class node_user,node_caller toneIndigo
```

## Components

### Input adapters

- [n8n Chat](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Slack Input](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Sub-workflow input](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`

### Shared query flow

- [Request Context](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Table selection](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Schema lookup](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [SQL generation](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Read query](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Answer writing](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`

### Output adapters

- [Common response](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Chat response](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Reply Slack](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`
- [Caller return](https://github.com/baba-ti/automatic_product_management/blob/main/product_management.json): `product_management.json`

### Sample data setup

- [Example schema](https://github.com/baba-ti/automatic_product_management/blob/main/create_tables_for_supabase.ipynb): `create_tables_for_supabase.ipynb`
- [Sample data generator](https://github.com/baba-ti/automatic_product_management/blob/main/insert_tables_for_supabase.py): `insert_tables_for_supabase.py`

### Other components

- **Questioner**
- **Workflow caller**
- **PostgreSQL**
- **OpenAI API**

## Connections

- Questioner → n8n Chat: asks via (evidence: `README.md`)
- Questioner → Slack Input: messages via (evidence: `README.md`)
- Workflow caller → Sub-workflow input: calls with request (evidence: `README.md`)
- n8n Chat → Request Context: normalizes request (evidence: `README.md`)
- Slack Input → Request Context: normalizes request (evidence: `README.md`)
- Sub-workflow input → Request Context: normalizes request (evidence: `README.md`)
- Request Context → Table selection: passes request (evidence: `README.md`)
- Table selection → Schema lookup: selects tables for (evidence: `README.md`)
- Schema lookup → PostgreSQL: reads metadata (evidence: `README.md`)
- Schema lookup → SQL generation: provides schema (evidence: `README.md`)
- Table selection → OpenAI API: selects tables with (evidence: `README.md`)
- SQL generation → OpenAI API: generates SQL with (evidence: `README.md`)
- SQL generation → Read query: passes query (evidence: `README.md`)
- Read query → PostgreSQL: reads data (evidence: `README.md`)
- Read query → Answer writing: returns results (evidence: `README.md`)
- Answer writing → OpenAI API: writes answer with (evidence: `README.md`)
- Answer writing → Common response: returns answer (evidence: `README.md`)
- Common response → Chat response: routes Chat response (evidence: `README.md`)
- Common response → Reply Slack: routes Slack reply (evidence: `README.md`)
- Common response → Caller return: returns to caller (evidence: `README.md`)
- Chat response → Questioner: delivers answer (evidence: `README.md`)
- Reply Slack → Questioner: sends reply (evidence: `README.md`)
- Caller return → Workflow caller: returns answer (evidence: `README.md`)
- Example schema → PostgreSQL: creates example tables (evidence: `README.md`)
- Sample data generator → PostgreSQL: inserts test data (evidence: `insert_tables_for_supabase.py`)
- Sample data generator → OpenAI API: generates sample text with (evidence: `README.md`)
