|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Purpose |
| 6 | + |
| 7 | +`create-pipedrive-app` is a CLI scaffolding tool for external Pipedrive Marketplace developers. It generates a production-ready integration project via `npx create-pipedrive-app <project-name>`. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +The tool is **CLI-first**, with an **AI plugin layer** built on top: |
| 12 | + |
| 13 | +- **CLI core**: Collects user choices via interactive prompts, then generates a project scaffold from templates. |
| 14 | +- **AI plugin layer** (secondary): Claude/Codex skills that wrap the CLI — guide developers, modify existing projects, and explain generated code. |
| 15 | + |
| 16 | +### Interactive prompts (CLI) |
| 17 | + |
| 18 | +The CLI asks for: |
| 19 | +- Backend: Node.js/Express, Node.js/Fastify, or PHP/Laravel |
| 20 | +- Database: Postgres, MySQL, or SQLite |
| 21 | +- App Extensions frontend: React, Vanilla JS, or none |
| 22 | +- Webhooks: Yes/No |
| 23 | + |
| 24 | +### Generated project structure |
| 25 | + |
| 26 | +``` |
| 27 | +<project-name>/ |
| 28 | + backend/ |
| 29 | + oauth/ # Authorization redirect, callback, token exchange, refresh, state validation |
| 30 | + pipedrive-client/ # Official API client wrapper with preconfigured auth |
| 31 | + database/ # Tenant/account mapping, tokens, scopes, installation status |
| 32 | + webhooks/ # Optional webhook handlers |
| 33 | + frontend/ |
| 34 | + app-extension-ui/ # Optional: React or Vanilla iframe UI with App Extensions SDK |
| 35 | + .env.example |
| 36 | + README.md |
| 37 | + docker-compose.yml |
| 38 | + marketplace-checklist.md |
| 39 | +``` |
| 40 | + |
| 41 | +## MVP Scope |
| 42 | + |
| 43 | +The initial implementation targets: |
| 44 | +- **Runtime**: Node.js + TypeScript |
| 45 | +- **Backend**: Express or Fastify |
| 46 | +- **Database**: Postgres via Docker Compose |
| 47 | +- **Auth**: Full OAuth 2.0 install/callback/token-refresh flow |
| 48 | +- **API client**: Pipedrive Node.js client wrapper |
| 49 | +- **Frontend** (optional): React App Extensions UI |
| 50 | +- Outputs `.env.example` and a Marketplace readiness checklist |
| 51 | + |
| 52 | +PHP and MySQL/SQLite backends come after MVP. |
| 53 | + |
| 54 | +## Core Modules |
| 55 | + |
| 56 | +### OAuth (`backend/oauth/`) |
| 57 | +Full OAuth 2.0: app registration guidance, authorization redirect, callback handling, token exchange, token refresh, state validation. |
| 58 | + |
| 59 | +### Database (`backend/database/`) |
| 60 | +Uses **Drizzle ORM** (`drizzle-orm` + `drizzle-kit`) for schema definition and migrations. Drizzle is chosen because it supports Postgres, MySQL, and SQLite with the same TypeScript API — matching the three database options the CLI offers — and produces readable schema files with no codegen step. |
| 61 | + |
| 62 | +Structure: |
| 63 | +- `schema.ts` — Drizzle table definitions (tenants, oauth_tokens, installations) |
| 64 | +- `migrations/` — SQL migration files managed by `drizzle-kit` |
| 65 | +- `db.ts` — driver setup (selects `postgres-js`, `mysql2`, or `better-sqlite3` based on the chosen DB) |
| 66 | + |
| 67 | +Key packages: `drizzle-orm`, `drizzle-kit`, and the appropriate driver for the selected database. |
| 68 | + |
| 69 | +### Pipedrive API client (`backend/pipedrive-client/`) |
| 70 | +Wrapper around the official Pipedrive Node.js client with preconfigured authentication and helpers for common API calls. |
| 71 | + |
| 72 | +### App Extensions frontend (`frontend/app-extension-ui/`) |
| 73 | +Only generated when the user opts in. Iframe-based UI using the App Extensions SDK, supporting: initialization, resizing, modals, notifications/snackbars, theme handling. |
| 74 | + |
| 75 | +## Development |
| 76 | + |
| 77 | +To test app generation locally: |
| 78 | + |
| 79 | +```bash |
| 80 | +npx tsx src/cli.ts app |
| 81 | +``` |
| 82 | + |
| 83 | +This creates an `app/` directory in the repo root (gitignored via `*-app/`). |
| 84 | + |
| 85 | +## AI Plugin Commands (future layer) |
| 86 | + |
| 87 | +``` |
| 88 | +/pipedrive-new-app |
| 89 | +/pipedrive-add-oauth |
| 90 | +/pipedrive-add-app-extension |
| 91 | +/pipedrive-review-marketplace-readiness |
| 92 | +``` |
0 commit comments