# mblevu/amplify-next-pages-template-iyashi architecture

> Architecture diagram of the GitHub repository mblevu/amplify-next-pages-template-iyashi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mblevu/amplify-next-pages-template-iyashi
- Repository: https://github.com/mblevu/amplify-next-pages-template-iyashi

## Overview

1. This repository is a full-stack starter built around two main boundaries: a Next.js app using the Pages Router on the frontend, and an AWS Amplify-managed backend defined in TypeScript under the `amplify/` directory.

2. The user-facing application lives in `pages/`. `pages/index.tsx` is the main landing page, while `pages/_app.tsx` and `pages/_document.tsx` provide the global app shell and document-level setup. Styling is split across `styles/globals.css` and `styles/app.css`, with static assets served from `public/`.

3. Next.js also provides a small server-side API surface in `pages/api/hello.ts`. This is a separate execution path from the Amplify backend: it runs as a Next.js API route rather than through AppSync or DynamoDB.

4. The backend is modeled in `amplify/backend.ts`, which composes the application’s cloud resources. The presence of `amplify/auth/resource.ts` and `amplify/data/resource.ts` indicates the backend is split into explicit authentication and data subsystems, each defined as code rather than configured manually in the console.

5. Authentication is handled by AWS Cognito through the Amplify auth resource. In the architecture diagram, this is the identity boundary for sign-in, session management, and any authenticated user context the frontend consumes.

6. Application data access is handled by the Amplify data resource, which the README describes as a GraphQL API backed by AWS AppSync and Amazon DynamoDB. This is the main persistence and query layer for the app, and likely the primary path for client-side data operations.

7. The typical data flow is: browser renders the Next.js pages, the app initializes its client-side state, users authenticate through Cognito, and the frontend then calls the Amplify GraphQL/data layer for reads and writes against DynamoDB. That separates presentation, identity, API, and storage into distinct layers.

8. The repository includes `amplify.yml`, which is the deployment/build definition used by Amplify hosting. That file is the bridge between source control and AWS deployment, and it orchestrates how the Next.js app and backend resources are built and published.

9. Tooling and project-level configuration are standard but important for the architecture: `next.config.mjs` controls Next.js behavior, `tsconfig.json` and `amplify/tsconfig.json` define TypeScript boundaries for the app and backend code, and `.eslintrc.json` enforces code quality across the repo.

10. In diagram form, the clearest top-level components are: client browser, Next.js Pages app, Next.js API route, Amplify auth service, Amplify GraphQL/data service, and DynamoDB storage. The strongest separation is between frontend rendering and cloud backend resources defined in `amplify/`, with Amplify acting as the integration layer between them.

Main entry points: [`pages/_app.tsx`](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/_app.tsx) (Pages app), [`amplify/backend.ts`](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/backend.ts) (Backend core), [`amplify/data/resource.ts`](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/data/resource.ts) (Data resource), [`pages/index.tsx`](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/index.tsx) (Home page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client & Pages"]
  node_browser(("Browser<br/>user agent"))
  node_pages_app["Pages app<br/>Next.js Pages Router<br/>[_app.tsx]"]
  node_pages_doc["Document<br/>[_document.tsx]"]
  node_landing["Home page<br/>Next.js page<br/>[index.tsx]"]
  node_api_hello["Hello API<br/>Next.js API route<br/>[hello.ts]"]
  node_styles_global["Global styles<br/>CSS<br/>[globals.css]"]
  node_styles_app["App styles<br/>CSS<br/>[app.css]"]
  node_static_assets["Public assets<br/>static files"]
end

subgraph group_backend["Amplify Backend"]
  node_amplify_backend["Backend core<br/>Amplify composition<br/>[backend.ts]"]
  node_auth_resource["Auth resource<br/>Amplify auth<br/>[resource.ts]"]
  node_data_resource["Data resource<br/>Amplify data<br/>[resource.ts]"]
end

subgraph group_deploy["Build & Deploy"]
  node_amplify_hosting["Amplify build<br/>hosting pipeline<br/>[amplify.yml]"]
  node_next_config["Next config<br/>Next.js config<br/>[next.config.mjs]"]
  node_tsconfig_root["TS config<br/>TypeScript config<br/>[tsconfig.json]"]
  node_tsconfig_amplify["Backend TS config<br/>TypeScript config<br/>[tsconfig.json]"]
end

subgraph group_external["Managed Services"]
  node_cognito{{"Cognito<br/>identity service"}}
  node_appsync{{"GraphQL API<br/>managed API"}}
  node_dynamo[("DynamoDB<br/>database")]
end

node_browser -->|"loads"| node_pages_app
node_pages_app -->|"renders"| node_landing
node_pages_app -->|"wraps"| node_pages_doc
node_landing -->|"uses"| node_styles_global
node_landing -->|"uses"| node_styles_app
node_pages_app -->|"serves"| node_static_assets
node_browser -->|"calls"| node_api_hello
node_amplify_backend -->|"composes"| node_auth_resource
node_amplify_backend -->|"composes"| node_data_resource
node_auth_resource -->|"provisions"| node_cognito
node_data_resource -->|"exposes"| node_appsync
node_data_resource -->|"stores"| node_dynamo
node_pages_app -->|"consumes"| node_auth_resource
node_pages_app -->|"queries"| node_data_resource
node_amplify_hosting -->|"builds"| node_pages_app
node_amplify_hosting -->|"deploys"| node_amplify_backend
node_next_config -->|"configures"| node_pages_app
node_tsconfig_root -->|"types"| node_pages_app
node_tsconfig_amplify -->|"types"| node_amplify_backend

click node_pages_app "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/_app.tsx"
click node_pages_doc "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/_document.tsx"
click node_landing "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/index.tsx"
click node_api_hello "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/api/hello.ts"
click node_styles_global "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/styles/globals.css"
click node_styles_app "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/styles/app.css"
click node_static_assets "https://github.com/mblevu/amplify-next-pages-template-iyashi/tree/main/public"
click node_amplify_backend "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/backend.ts"
click node_auth_resource "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/auth/resource.ts"
click node_data_resource "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/data/resource.ts"
click node_amplify_hosting "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify.yml"
click node_next_config "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/next.config.mjs"
click node_tsconfig_root "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/tsconfig.json"
click node_tsconfig_amplify "https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/tsconfig.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_pages_app,node_pages_doc,node_landing,node_api_hello,node_styles_global,node_styles_app,node_static_assets toneBlue
class node_amplify_backend,node_auth_resource,node_data_resource toneAmber
class node_amplify_hosting,node_next_config,node_tsconfig_root,node_tsconfig_amplify toneMint
class node_cognito,node_appsync,node_dynamo toneRose
```

## Components

### Client & Pages

Browser-facing Next.js pages, app shell, and styles.

- **Browser**: user agent · End user running the app in a web browser.
- [Pages app](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/_app.tsx): Next.js Pages Router · Main frontend application entry and page routing. · `pages/_app.tsx`
- [Document](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/_document.tsx): Next.js document · Document-level HTML and head/body setup. · `pages/_document.tsx`
- [Home page](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/index.tsx): Next.js page · Primary landing page for the starter app. · `pages/index.tsx`
- [Hello API](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/pages/api/hello.ts): Next.js API route · Server-side API endpoint exposed through Next.js. · `pages/api/hello.ts`
- [Global styles](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/styles/globals.css): CSS · Shared site-wide styling. · `styles/globals.css`
- [App styles](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/styles/app.css): CSS · Application-specific styling rules. · `styles/app.css`
- [Public assets](https://github.com/mblevu/amplify-next-pages-template-iyashi/tree/main/public): static files · Static files served directly by Next.js. · `public`

### Amplify Backend

TypeScript-defined cloud resources and data access layer.

- [Backend core](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/backend.ts): Amplify composition · Top-level backend definition that composes cloud resources. · `amplify/backend.ts`
- [Auth resource](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/auth/resource.ts): Amplify auth · Authentication subsystem definition. · `amplify/auth/resource.ts`
- [Data resource](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/data/resource.ts): Amplify data · GraphQL data subsystem definition. · `amplify/data/resource.ts`

### Build & Deploy

Repository-level build, hosting, and compiler configuration.

- [Amplify build](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify.yml): hosting pipeline · Build and deployment definition for the app and backend. · `amplify.yml`
- [Next config](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/next.config.mjs): Next.js config · Framework behavior and build settings. · `next.config.mjs`
- [TS config](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/tsconfig.json): TypeScript config · Frontend TypeScript boundary and compiler settings. · `tsconfig.json`
- [Backend TS config](https://github.com/mblevu/amplify-next-pages-template-iyashi/blob/main/amplify/tsconfig.json): TypeScript config · TypeScript settings for backend code under amplify/. · `amplify/tsconfig.json`

### Managed Services

AWS services used by the backend.

- **Cognito**: identity service · Managed user authentication and session boundary.
- **GraphQL API**: managed API · Query and mutation surface for application data.
- **DynamoDB**: database · Persistent storage backing the data layer.

## Connections

- Browser → Pages app: loads · Browser requests the Next.js application shell.
- Pages app → Home page: renders · The app shell mounts the landing page.
- Pages app → Document: wraps · Document setup surrounds the rendered app.
- Home page → Global styles: uses · Landing page relies on shared global styles.
- Home page → App styles: uses · Landing page pulls in app-specific styles.
- Pages app → Public assets: serves · Frontend uses public static assets.
- Browser → Hello API: calls · Client can hit the Next.js API route separately from Amplify.
- Backend core → Auth resource: composes · Backend core includes auth definition.
- Backend core → Data resource: composes · Backend core includes data definition.
- Auth resource → Cognito: provisions · Amplify auth maps to AWS Cognito.
- Data resource → GraphQL API: exposes · Data resource provides a GraphQL API surface.
- Data resource → DynamoDB: stores · GraphQL data is persisted in DynamoDB.
- Pages app → Auth resource: consumes · Frontend uses authentication context for sign-in and session state.
- Pages app → Data resource: queries · Client reads and writes through the Amplify data layer.
- Amplify build → Pages app: builds · Hosting pipeline builds the Next.js application.
- Amplify build → Backend core: deploys · Hosting pipeline also deploys backend resources.
- Next config → Pages app: configures · Controls Next.js runtime and build behavior.
- TS config → Pages app: types · Defines the frontend TypeScript boundary.
- Backend TS config → Backend core: types · Defines the backend TypeScript boundary.
