brainstorm-architecture
docs/plan/ARCHITECTURE.md: the stack and why, the folder layout, the modules and which agent owns each, how data flows through them, shared types and where they live, environment variables, integrations, deployment target, and the decisions with their reasons. Read when planning a new project or a change to how one is put together.
- License 许可
- Apache-2.0
- 所属仓库
- enowdev/enowxcli
- 最近更新
- 2026-10-06
- Stars
- ★ 67
- Forks
- 21
01 前言 Front Matter
- name
- brainstorm-architecture
- description
- docs/plan/ARCHITECTURE.md: the stack and why, the folder layout, the modules and which agent owns each, how data flows through them, shared types and where they live, environment variables, integrations, deployment target, and the decisions with their reasons. Read when planning a new project or a change to how one is put together.
02 资源文件 1
- 参考文档compliance_detection.md4.0 KB
03 SKILL.md 正文
ARCHITECTURE.md: how the project is put together
When four specialists build one project at once, each makes the choices
the others depend on: where shared types live, which folder is whose, how
the page gets its data, what the environment variables are called. Left
unwritten, the frontend reads NEXT_PUBLIC_API_URL, the backend serves on
a path nobody told it about, and two agents create src/types.ts and
src/shared/types.ts. This document fixes those choices once.
1. The template
# Architecture
## Stack
| Layer | Choice | Why |
|---|---|---|
| Frontend | Next.js 15 (App Router), TypeScript, Tailwind | the user asked for Next |
| Backend | Next.js route handlers | one deployable; the API is small |
| Database | Postgres 16 with Drizzle | relational data (orders, items) |
| Hosting | <the user's: Coolify on their VPS> | |
## Layout
src/app/ pages and route handlers (fe: pages; be: src/app/api/**)
src/components/ shared UI components (fe, foundation wave)
src/server/ data access and business logic (be)
src/shared/types.ts types used by client and server (foundation; read-only after)
db/ schema and migrations (db)
tests/ end-to-end tests (test)
## Modules
| Module | Owns | Owner |
|---|---|---|
| Catalogue | src/app/catalogue/**, src/server/products.ts | fe, be |
## Data flow
Browser → page (server component) → src/server/products.ts → Postgres.
Mutations: form → POST /api/cart/items → src/server/cart.ts → Postgres → revalidate /cart.
## Shared
- Types: src/shared/types.ts (Product, Cart, Order). Written in the foundation wave.
- Money: integer minor units with an ISO currency code.
- Dates: ISO 8601 in UTC on the wire; shown in the user's time zone.
- IDs: <uuid v7 | database serial>; slugs for public URLs.
## Environment
| Variable | Used by | Example |
|---|---|---|
| DATABASE_URL | server | postgres://… (never in the client) |
## Integrations
- <payments, email, storage: provider, what for, which module calls it>
## Decisions
- <date> Route handlers instead of a separate API service: one deploy, small API. Revisit if mobile clients come.
2. Choosing, and saying why
- The stack is the user's when they named one, and the project's when
it exists: read
package.json,Cargo.toml,go.mod,pyproject.toml, the framework config. A new project with no stated preference gets the plain default for its kind (a static site: plain HTML and CSS; an app with pages and data: the framework the project's language community uses most), named as a default in the Why column. - Why is one short reason tied to the product, not a slogan.
- Fewer moving parts unless the product needs more: one deployable before two, the framework's own routes before a separate API service, a managed database before a self-run cluster. Say what would change the decision ("revisit if mobile clients come").
3. The layout is the ownership map
- Every folder in Layout names its owner, and those owners are the agents
in
PLAN.md. Two parts of one wave never own the same folder. - Files everything imports (the router, root layout, shared types, the package manifest, the global stylesheet) belong to the foundation wave or to exactly one part, and are read-only for the rest.
- Keep the project's existing conventions in an existing codebase; the document describes them, it does not reorganise them.
4. The shared facts
The conventions every part must use the same way: money, dates, IDs,
errors, pagination, naming (camelCase in JSON, snake_case in SQL).
Write each once here; API.md and ERD.md follow them.
5. Decisions
A short log in the ADR spirit: the date, what was decided, why, and what would reverse it. Read before revisiting a choice; add to it whenever the user or a report changes one.
Check it
- Every folder has one owner, matching
PLAN.md. - Shared types, money, dates and IDs are each defined once.
- Every environment variable is named, with who reads it and whether it is secret.
- Every stack choice has a reason; defaults are called defaults.
Avoid
Stack choices the user did not make written as theirs; microservices for a small product; two homes for shared types; environment variables named differently by different parts; a layout that reorganises an existing project; decisions without reasons.
04 同仓库更多 Skills
demo-skill
Project-scope demo skill for tests.
writing
Writing words people read: the specific thing instead of claims, words to drop, sentences, interface copy (buttons, labels, errors, empty states, confirmations), page copy, notifications and emails, alt text and link text, numbers and dates, words that translate well, documentation and voice. Read before writing a page's copy, an interface's text or a document.
ui
Designing or restyling an interface: direction, layout, type, colour, icons, components, states, responsive behaviour. Read before building a page, a screen or a set of components.
ui-themes
Light and dark themes, and colour that holds in both: tokens with a value per theme, and what each kind of content needs to stay visible (icons, SVG drawings and line art, logos, photos, screenshots, charts, code, maps, borders, shadows, focus, form controls), switching without a flash, and checking both. Read before building a second theme or a theme toggle, and before any drawing, logo or chart on a page that has two themes.
ui-structure
Structure before styling: the blueprint written before any interface code (the screen's job, the regions its kind of page needs, their order and why, the layout skeleton in numbers, the components and their states), the anatomy and order of a homepage, a dashboard, a list, a detail page, settings, a form, sign-in, pricing, docs, an article and a checkout, and how to turn the blueprint into code (tokens, layout primitives, components, sections, page). Read first, before building or rebuilding any page or screen.
ui-stack-vue
Building interfaces in Vue 3 and Nuxt: project layout, script setup with typed defineProps, defineEmits and defineModel, attribute fallthrough, slots and scoped slots, template refs, ref, reactive and computed, watch versus watchEffect, composables and VueUse, provide and inject, Pinia, keyed v-for, transitions, Nuxt 4 (app directory, pages, layouts, useFetch and useAsyncData keys, $fetch in handlers, server routes, runtime config, useSeoMeta, NuxtImg, middleware), VeeValidate forms, Reka UI and Nuxt UI, testing, vue-tsc, and the traps. Read when the project uses Vue or Nuxt.