Software engineering

Architecture prompt

A copy-and-paste prompt for ChatGPT, Claude or Gemini that gets a professional architecture on the first try, plus the cheapest model that does it well.

What most people type

how should I architect a multi-tenant SaaS app where each customer can have custom fields on their records? we use postgres and node, expect maybe 2000 tenants

It works, but the AI has to guess your entity types, e.g. contacts, orders, row counts and typical and max, so the first answer usually needs another round. The version below asks for exactly what a professional would deliver.

The better prompt

Recommend an architecture for a multi-tenant SaaS app where each tenant can define custom fields on their records. Stack: PostgreSQL and Node.js. Expected scale: about 2000 tenants.

Context I haven't specified (state any assumption you make, and tell me which answers would change if it differs):
- Record types that need custom fields: [entity types, e.g. contacts, orders]
- Expected records per tenant and total: [row counts]
- Custom fields per tenant: [typical and max]
- Need to filter, sort, report on or index custom fields: [yes/no, which]
- Tenant isolation or compliance needs: [requirements]
- Node framework and ORM/query builder: [tools]
- Team size and PostgreSQL hosting: [details]

Please cover:
1. Tenant isolation model: compare shared tables with a tenant_id column (with row-level security), schema per tenant, and database per tenant. Say which fits 2000 tenants and why.
2. Custom field storage: compare JSONB columns, EAV (entity-attribute-value), and per-tenant altered columns. Cover query performance, indexing (e.g. GIN or expression indexes), type validation, and migrations.
3. Recommendation: one primary design with a short schema sketch (key tables and columns) and how the Node layer validates and reads custom fields from a per-tenant field definitions table.
4. Risks and limits: noisy neighbors, connection pooling, backups and restores per tenant, and the point at which the design needs to change.

Give a clear recommendation first, then the comparison as a compact table, then the details. Don't invent benchmarks or numbers; where performance depends on my data, say what to measure.

Replace the [brackets] with your details before you send it: entity types, e.g. contacts, orders, row counts, typical and max, yes/no, which, requirements, tools, details.

What a professional architecture prompt covers

  • Asks for options with trade-offs
  • Data model examples
  • Performance and migration considerations
  • A recommendation

Best AI model for this prompt

This is a everyday task. You don't need the most expensive model. The cheapest model at each company that handles it well:

CompanyModelPer usePer 1,000 uses
AnthropicClaude Sonnet 5.5$0.0047$4.69
OpenAIGPT-6.1 Terra$0.0023$2.35
GoogleGemini 3.8 Flashcheapest$0.0018$1.76

Pay-per-use list prices for this prompt and its expected answer (about 400 tokens). On a monthly chat plan, the same choice shows up as more messages before you hit your limit. See today's AI prices.

Architecture prompt for ChatGPT, Claude and Gemini (Software engineering) · PromptSaver