Claude Sonnet 4.6 — works with Claude Opus 4.8 for larger decisions. Also compatible with GPT-4o and Gemini 1.5 Pro.Your team just decided to adopt Kafka for event streaming, ditch your REST API for GraphQL, or migrate from a monolith to microservices — and your tech lead needs a proper ADR written before the sprint ends. You have 20 minutes and no template.Developer Tools

مولد سجل القرارات المعمارية

مشاركة:
مولد سجل القرارات المعمارية

Why this prompt matters

Engineering teams without ADRs spend 40-60% of new-hire onboarding time reconstructing why decisions were made — often incorrectly. When the original decision-maker leaves, the institutional knowledge leaves with them. Six months later, engineers rip out a perfectly good system because nobody documented why it was chosen, and the replacement has the exact same failure modes.

What we use it for

Your team just decided to adopt Kafka for event streaming, ditch your REST API for GraphQL, or migrate from a monolith to microservices — and your tech lead needs a proper ADR written before the sprint ends. You have 20 minutes and no template.

Prompt

Act as a senior software architect with 15+ years of experience leading engineering teams at scale.

Context: I am on the engineering team at [COMPANY/TEAM NAME]. We are making a technical decision about [DESCRIBE THE TECHNICAL DECISION IN ONE SENTENCE — e.g., "whether to use PostgreSQL or MongoDB as our primary data store"]. Our system serves [DESCRIBE YOUR SCALE — e.g., "10,000 daily active users with plans to reach 1M in two years"]. Our current stack is [DESCRIBE YOUR STACK — e.g., "Node.js backend, React frontend, running on AWS"].

Task: Generate a complete Architecture Decision Record (ADR) for this decision. The ADR must be honest and rigorous — not a rubber stamp for a predetermined choice.

Constraints:
- Do not assume the decision I am leaning toward is correct. Actively challenge it.
- Every claim must be supported by concrete reasoning, not vague assertions.
- The "Alternatives Considered" section must include at least 3 options with genuine tradeoffs — not strawman comparisons.
- The "Devil's Advocate" section must present the strongest possible argument AGAINST the chosen option.
- Be specific: name actual tools, libraries, failure modes, and real-world examples where relevant.
- Avoid filler phrases like "it depends" without following them with what it depends on.

Output Format:
# ADR-[NUMBER]: [TITLE]

**Date**: [TODAY'S DATE]
**Status**: Proposed | Accepted | Deprecated | Superseded

## Context
[2-4 sentences: What problem are we solving? What forces are at play? What constraints exist?]

## Decision
[1-3 sentences: What we decided and the primary reason]

## Decision Drivers
- [Driver 1: specific technical or business constraint]
- [Driver 2]
- [Driver 3]

## Alternatives Considered

### Option A: [NAME] ✅ (Selected)
**Pros**: [specific, concrete pros]
**Cons**: [honest cons — not trivial ones]
**Why selected**: [specific reasoning]

### Option B: [NAME]
**Pros**: [...]
**Cons**: [...]
**Why not selected**: [specific reasoning]

### Option C: [NAME]
**Pros**: [...]
**Cons**: [...]
**Why not selected**: [specific reasoning]

## Consequences

### Positive
- [Concrete positive outcome]
- [Another concrete positive]

### Negative
- [Honest negative consequence]
- [Another honest negative]

## Devil's Advocate
[The strongest argument AGAINST this decision — 2-4 sentences. Be intellectually honest.]

## Review Date
[When should this decision be revisited? Under what conditions would we change course?]

Result

ADR-007: Use PostgreSQL as the Primary Data Store for Helios SaaS Platform

Date: 2026-06-03
Status: Accepted

Context

Helios is a B2B SaaS platform for project portfolio management, currently serving 52,000 daily active users across 1,400 enterprise customers. We are running on a Node.js/Express backend, React frontend, deployed on AWS ECS with an RDS MySQL 5.7 instance as our primary store. MySQL 5.7 reaches end-of-life in October 2026 and we must migrate. Simultaneously, our product roadmap calls for highly flexible project metadata schemas — customers increasingly want custom fields, nested attributes, and dynamic reporting dimensions that fight our current rigid schema. We evaluated whether this is the right moment to switch to a document database (MongoDB) rather than upgrading to MySQL 8 or migrating to PostgreSQL.

Decision

We will migrate from MySQL 5.7 to PostgreSQL 16 as our primary relational store. PostgreSQL's JSONB column type gives us the schema flexibility we need for custom fields without surrendering ACID transactions, mature tooling, or the relational model our reporting layer depends on.

Decision Drivers

  • EOL forcing function: MySQL 5.7 support ends October 2026; inaction is not an option.
  • Custom metadata flexibility: Customers require 10-200 dynamic custom fields per project entity; current rigid schema requires schema migrations for every new field type.
  • Reporting integrity: Finance and PMO teams run complex multi-table JOINs and window functions for cross-project analytics; losing ACID and JOIN semantics would require rebuilding the entire reporting layer.
  • Operational familiarity: 4 of 5 backend engineers have PostgreSQL production experience; 0 have MongoDB production experience beyond toy projects.
  • AWS RDS support: PostgreSQL 16 is fully supported on Amazon RDS with automated failover; no infrastructure re-architecture required.

Alternatives Considered

Option A: PostgreSQL 16 ✅ (Selected)

Pros: Full ACID compliance with row-level locking; JSONB with GIN indexes allows sub-5ms queries on custom field data at our scale; pg_trgm extension supports full-text search without Elasticsearch for our current needs; logical replication to read replicas is production-tested; pgvector available for future AI features; RDS Proxy reduces connection overhead from our 800-instance ECS fleet.

Cons: JSONB schema validation is application-enforced, not database-enforced (unlike SQL CHECK constraints on typed columns); migration from MySQL requires careful handling of MySQL-specific functions (GROUP_CONCAT → STRING_AGG, etc.) and implicit type coercions; no native horizontal write sharding without Citus.

Why selected: The JSONB approach directly solves our custom fields problem while preserving JOIN semantics for reporting. pgAdmin and AWS RDS tooling are mature. The migration path from MySQL via pgloader is well-documented, and we can run both databases in parallel during the cutover window.

Option B: MongoDB 7.0 (Atlas)

Pros: Native document model eliminates the custom fields schema problem entirely; horizontal sharding is built-in; Atlas Search provides Lucene-backed full-text search; Change Streams simplify real-time notification pipelines.

Cons: No multi-document ACID transactions across collections without significant performance penalty (MongoDB 4.0+ has them but they degrade throughput 3-5x at volume); our reporting queries require cross-collection $lookup aggregations that are slower and more brittle than SQL JOINs; rewriting 340+ SQL queries and the Sequelize ORM layer is estimated at 8-12 weeks of engineering; Atlas pricing at our data volume is ~2.3x our current RDS cost; zero production MongoDB experience on the team means we absorb operational risk simultaneously with a major migration.

Why not selected: The JOIN-heavy reporting layer is a first-class product feature, not legacy debt we can eliminate. Rewriting it in aggregation pipelines would take longer than the MySQL EOL deadline and introduce regression risk in our highest-revenue feature set.

Option C: MySQL 8.0 (In-Place Upgrade)

Pros: Minimal migration risk — in-place upgrade path is well-tested; zero query rewriting; team knows MySQL deeply; RDS supports MySQL 8.0 with automated minor version upgrades through 2030+.

Cons: MySQL 8.0 JSON type does not support GIN-equivalent indexes (only generated columns with functional indexes — significantly more verbose and less flexible than PostgreSQL JSONB); custom fields problem is not solved, only deferred; MySQL's window function implementation has known edge-case bugs in versions before 8.0.26; we would be back in the same position when MySQL 8.0 reaches EOL.

Why not selected: MySQL 8.0 solves the EOL problem but not the schema flexibility problem. We would be choosing a shorter runway over a harder migration that solves both problems at once.

Consequences

Positive

  • Custom fields for project entities can be stored as JSONB without schema migrations; new field types ship in hours instead of days.
  • Reporting queries retain full SQL expressiveness; no rewrite of the analytics layer required.
  • pgvector support positions us for AI-powered project similarity and recommendation features on the roadmap for Q3 2027.
  • Estimated 15-20% query performance improvement on complex reporting workloads based on internal benchmarks (PostgreSQL's planner handles our LEFT OUTER JOIN patterns better than MySQL 5.7).
  • Migration eliminates technical debt: MySQL-specific SQL quirks (implicit GROUP BY, lenient type casting) are replaced with standard SQL.

Negative

  • One-time migration engineering cost: estimated 6 weeks for a team of 2 engineers (schema translation, query rewriting, pgloader ETL pipeline, parallel run validation, cutover playbook).
  • All 340+ queries and stored procedures must be audited; approximately 40 contain MySQL-specific functions requiring rewriting.
  • Custom field validation logic moves to the application layer (Zod schemas in our Node.js service) — this is enforced by code review discipline, not the database itself.
  • PostgreSQL connection model (process-per-connection) requires RDS Proxy to handle our ECS connection count; adds ~$180/month in infrastructure cost.

Devil's Advocate

The strongest argument against this decision is that we are solving the custom fields problem with a workaround rather than the right tool. PostgreSQL JSONB is powerful, but we are essentially bolting a document store onto a relational database and will spend the next two years writing application-layer validation code that a proper document database would handle structurally. MongoDB's document model is correct for entities with 10-200 dynamic attributes — PostgreSQL JSONB becomes unwieldy when customers start querying across custom fields in reports, and we will end up with partial indexes on JSONB paths that are fragile and hard to maintain. The 8-12 week rewrite estimate for the reporting layer may be pessimistic; if it is actually 4-6 weeks, the MongoDB option pays for itself within a year through reduced schema maintenance overhead. We may be choosing the comfortable option over the correct one.

Review Date

Revisit this decision in 18 months (December 2027) or earlier if: (a) JSONB query performance degrades below our 200ms p95 SLA as data volume grows past 500GB, (b) custom field reporting complexity requires more than 3 partial indexes per entity type, or (c) a major product pivot makes the reporting layer less central to the product value proposition. At that point, evaluate whether a hybrid architecture (PostgreSQL for relational data + a dedicated document store for project metadata) makes sense.

سجل القرارات المعمارية (ADR) هو مستند قصير يوثق قرارًا تقنيًا مهمًا: ما تم اتخاذه، ولماذا تم اتخاذه، وما هي العواقب. من الناحية النظرية، يجب أن يكون لدى كل فريق هندسي هذه السجلات. عمليًا، معظم الفرق إما تتخطاها تمامًا أو تكتب سجلات غامضة لدرجة أنها غير مفيدة. النتيجة هي قاعدة أكواد مليئة بالخيارات الغامضة — ذاكرة تخزين مؤقت من Redis لا يجرؤ أحد على لمسها، حدود خدمة مصغرة لا معنى لها، مخطط قاعدة بيانات يحارب كل ميزة جديدة. توجد ADRs لمنع هذا. ولكن كتابة سجل جيد يتطلب تفكيرًا منظمًا، ونزاهة فكرية، ووقتًا كافيًا لتوضيح المقايضات بوضوح.

ما يميز هذا الموجه عن قالب ADR فارغ هو الطبقة الخصومية المضمنة. معظم قوالب ADR تأكيدية — تطلب منك ملء ما قررته ولماذا هو جيد. هذا الموجه يُجبر النموذج على تحدي القرار المقترح بشكل فعال، ويتطلب بدائل ملموسة بمقايضات حقيقية (وليست وهمية)، ويكتب قسم محامي الشيطان الذي يقدم أقوى حجة ممكنة ضد الخيار المختار. النتيجة هي سجل ADR يمكنه تحمل مراجعة الأقران ويُعلم القرارات المستقبلية — وليس فقط توثيق القرارات السابقة.

  1. املأ العناصر النائبة بين قوسين: اسم شركتك/فريقك، القرار التقني في جملة واحدة، نطاقك (الحالي والمستهدف)، ومجموعتك التقنية الحالية.
  2. الصق الموجه المكتمل في Claude أو GPT-4o أو Gemini 1.5 Pro.
  3. راجع قسم محامي الشيطان أولاً — إذا كانت الحجج فيه أقوى من تلك الموجودة في قسم القرار، فأعد النظر في اختيارك قبل توثيقه.
  4. شارك مسودة سجل ADR مع فريقك لمراجعة مدتها 15 دقيقة. استخدم قسم البدائل التي تم النظر فيها كجدول أعمال.
  5. احفظ سجل ADR النهائي في مستودعك (مثل: /docs/decisions/ADR-001.md) واربطه من README أو معمارية الويكي الخاصة بك.

للحصول على أفضل النتائج، كن محددًا قدر الإمكان عند وصف نطاقك ومجموعتك التقنية. المدخلات الغامضة تنتج سجلات ADR غامضة. إذا كنت تختار بين خيارين، قم بتشغيل الموجه مرتين — مرة مع اختيار الخيار أ، ومرة مع اختيار الخيار ب — وقارن بين قسمي محامي الشيطان. الحجة الأضعف لمحامي الشيطان تشير عادةً إلى القرار الأفضل. ضع في اعتبارك أيضًا تغيير معلمة النطاق: القرار الصحيح لـ 10,000 مستخدم قد يكون خاطئًا لـ 1,000,000 مستخدم، وهذا الموجه سيُظهر هذا التوتر بشكل صريح.

software-engineeringdecision-makingdocumentationarchitectureadr
مشاركة: