Skip to main content

System Architecture Document: [Project Name]

Last Updated: [YYYY-MM-DD]
Related PRD: ./prd.md


1. High-Level Overview​

2–3 sentences explaining how the browser, backend (if any), and database fit together.

[User Browser (Frontend)] ──HTTPS/JSON──▶ [Backend API / Server] ──▶ [Database]

2. Selected Tech Stack​

LayerChoiceWhy This Fits Our MVP
Frontend[e.g., React / Next.js / Plain HTML+JS][Simple reason]
Backend[e.g., Node/Express / FastAPI / Full-stack framework][Simple reason]
Database[e.g., SQLite / PostgreSQL][Simple reason]
Hosting[e.g., Standard cloud host + managed DB][Simple reason]

3. Project Folder Structure​

project-name/
├── docs/ # PRD, design direction, architecture, plans
├── src/ # Application code
│ ├── routes/ # Pages & API endpoints
│ ├── services/ # Business logic & validation
│ ├── db/ # Database connection, schema & migrations
│ └── components/ # Reusable UI elements
├── tests/ # Automated unit & integration tests
├── .env.example # Required environment variable names (NO real values)
├── .gitignore # Excludes .env, node_modules, build artifacts
└── README.md

4. Data Model (Entities & Relationships)​

[Entity Name, e.g., User / Bookmark / Habit]​

  • id: Unique identifier (Primary Key)
  • [field_name]: [type, required?, constraints—e.g., text, max 120 chars]
  • created_at: Timestamp

(Repeat for each core entity in the MVP.)


5. API Boundaries & Core Actions​

ActionMethod & PathAuth Required?Validation & Authorization Rule
List itemsGET /api/items[Yes / No][Filter by logged-in user_id on server]
Create itemPOST /api/items[Yes / No][Validate non-empty title; attach user_id from session]
Delete itemDELETE /api/items/:id[Yes / No][Verify record belongs to current_user_id before deleting]

6. Authentication, Authorization & Security Notes​

  • Authentication ("Who are you?"): [None in v1 / Session cookies via standard library]
  • Authorization ("What can you access?"): [Every private query filters by server-verified user_id; never trust user IDs sent from browser inputs.]
  • Secrets Management: All API keys, DB URLs, and session secrets live in .env locally and host environment variables in production—never in code or frontend bundles.

7. Key Technical Decisions Log (ADRs)​

Decision 1: [e.g., Use PostgreSQL instead of local JSON files]​

  • Context: [Why we needed a decision]
  • Options Considered: [Option A, Option B]
  • Decision & Rationale: [What we chose and why]
  • Tradeoffs: [What extra setup or limits we accepted]