Skip to content

Commit d788eeb

Browse files
committed
document reusable template scaffolding #5
1 parent f46db1b commit d788eeb

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

docs/TEMPLATE_SCAFFOLDING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Template Scaffolding Guide
2+
3+
This repo contains reusable template files that speed up development. This guide explains what each piece is, whether it should be adapted, and what is local-only.
4+
5+
## What is template scaffolding?
6+
7+
Template scaffolding refers to starter files, utility wrappers, and configuration that were carried over from a reusable backend template. These files provide working defaults so contributors do not need to build common infrastructure from scratch.
8+
9+
They are **not product logic**. They are development accelerators that should be adapted as the product evolves.
10+
11+
## Reusable template files
12+
13+
| File | Purpose | Adapt or keep as-is? |
14+
|------|---------|----------------------|
15+
| `src/template/render-starter-email.ts` | Generic HTML email wrapper for transactional emails | Adapt when Access Layer needs branded email layouts |
16+
| `src/utils/mail.utils.ts` | Gmail-based email transport with starter templates | Keep structure, update templates as product flows are added |
17+
| `src/config.ts` | Zod-validated environment config with common variables | Extend with new env vars as needed |
18+
| `src/middlewares/error.middleware.ts` | Global error handler covering Zod, Prisma, JWT, and syntax errors | Keep as-is, extend for new error types |
19+
| `src/middlewares/rate.middleware.ts` | Rate limiting with dev/prod defaults | Keep as-is, tune limits for production |
20+
| `src/middlewares/cors.middleware.ts` | CORS setup using allowed origins from config | Keep as-is |
21+
| `src/utils/prisma.utils.ts` | Prisma singleton with dev-friendly logging | Keep as-is |
22+
| `src/utils/logger.utils.ts` | Pino logger and HTTP status constants | Keep as-is |
23+
| `src/tspec.config.ts` | OpenAPI doc generation config | Keep, update title and description as API grows |
24+
| `src/types/profile.types.ts` | Domain types and a `STARTER_ACCOUNT_SCHEMA` reference string | Adapt types as data model evolves; schema string is a reference, not a migration |
25+
26+
## Local-only and example files
27+
28+
| File | Purpose | Notes |
29+
|------|---------|-------|
30+
| `.env.example` | Safe placeholder environment variables | Copy to `.env` locally. Never commit a real `.env` file |
31+
| `docker-compose.yml` | Local PostgreSQL container | Local development only. Not used in production or CI |
32+
| `nodemon.json` | Auto-reload config for `pnpm dev` | Local development convenience |
33+
| `.husky/` | Git hooks for lint-staged | Runs locally on commit, enforced by `prepare` script |
34+
35+
## Files that are not scaffolding
36+
37+
These are product files, not template carryover:
38+
39+
- `src/modules/` — Application route modules (e.g. `auth`)
40+
- `src/types/auth.types.ts` — Auth domain types
41+
- `prisma/` — Database schema (source of truth for the data model)
42+
- `docs/open-source/issue-backlog.md` — Maintainer issue inventory
43+
- `.github/` — Issue templates, PR template, CI workflow
44+
45+
## How to tell the difference
46+
47+
Template scaffolding files often have comments like:
48+
49+
- `// Copy this to your src/middlewares/...`
50+
- `// Helper function - adjust based on your actual template`
51+
- `// Updated for your existing codebase`
52+
53+
These comments indicate the file originated from the template. The file is still useful — the comment just means it was not written specifically for Access Layer and can be adapted.
54+
55+
## Guidelines for contributors
56+
57+
1. **Do not delete scaffolding** that is still functional. If a utility works, keep it.
58+
2. **Adapt naming** when adding new product-specific logic on top of template files.
59+
3. **Local-only files** (`.env`, `docker-compose.yml`) should never be committed with real credentials or production config.
60+
4. **When in doubt**, check this guide or ask in a discussion before removing or restructuring a template file.

0 commit comments

Comments
 (0)