Folder layout
web/
├── app/ # everything Next.js serves
│ ├── layout.js # the shared HTML frame: "Trinity" header
│ ├── page.js # the / page: list + form
│ ├── actions.js # Server Actions: add, delete
│ ├── globals.css # styles and colours (light and dark)
│ └── api/health/route.js # GET /api/health
├── components/
│ ├── ProductList.js # the product table
│ └── ProductForm.js # the add form (client component)
├── lib/
│ └── products.js # API calls, and nothing else
├── __tests__/ # one test file per code file
├── Dockerfile.dev # development image
├── Dockerfile.prod # production image
├── .gitlab-ci.yml # web:lint, web:test, web:build jobs
├── .env.example # expected variables, without real values
├── next.config.mjs # output: 'standalone'
├── jest.config.mjs # Jest + coverage reports
└── eslint.config.mjs # Next.js rulesThe layout rule
| Folder | Contains | May call |
|---|---|---|
app/ | pages, routes and actions | components/, lib/ |
components/ | display components | app/actions.js (for forms) |
lib/ | API access logic | fetch, nothing else |
Why isolate the API in lib/? If the API address or format changes, only one file needs editing. And tests can replace that single module with a .
Tests
| File | Tests |
|---|---|
health.test.js | app/api/health/route.js |
products.test.js | lib/products.js |
actions.test.js | app/actions.js |
page.test.js | app/page.js |
ProductList.test.js | components/ProductList.js |
ProductForm.test.js | components/ProductForm.js |