How mblevu/amplify-next-pages-template-iyashi works
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: _app.tsx Pages app · backend.ts Backend core · resource.ts Data resource · index.tsx Home page
Components 18
Client & Pages
Browser-facing Next.js pages, app shell, and styles.
- Browser · End user running the app in a web browser.
- Pages app · Main frontend application entry and page routing.
pages/_app.tsx - Document · Document-level HTML and head/body setup.
pages/_document.tsx - Home page · Primary landing page for the starter app.
pages/index.tsx - Hello API · Server-side API endpoint exposed through Next.js.
pages/api/hello.ts - Global styles · Shared site-wide styling.
styles/globals.css - App styles · Application-specific styling rules.
styles/app.css - Public assets · Static files served directly by Next.js.
public
Amplify Backend
TypeScript-defined cloud resources and data access layer.
- Backend core · Top-level backend definition that composes cloud resources.
amplify/backend.ts - Auth resource · Authentication subsystem definition.
amplify/auth/resource.ts - Data resource · GraphQL data subsystem definition.
amplify/data/resource.ts
Build & Deploy
Repository-level build, hosting, and compiler configuration.
- Amplify build · Build and deployment definition for the app and backend.
amplify.yml - Next config · Framework behavior and build settings.
next.config.mjs - TS config · Frontend TypeScript boundary and compiler settings.
tsconfig.json - Backend TS config · TypeScript settings for backend code under amplify/.
amplify/tsconfig.json
Managed Services
AWS services used by the backend.
- Cognito · Managed user authentication and session boundary.
- GraphQL API · Query and mutation surface for application data.
- DynamoDB · Persistent storage backing the data layer.
Connections 19
- 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.