How shahzain-lab/amplify-oauth2 works
Project type and purpose
• This is a full-stack web application built with Next.js (using the new “app” directory) and AWS Amplify.
• The goal is to serve React pages, handle client-side authentication, and interact with cloud data resources (through Amplify).
File structure
• Top-level Next.js front-end (“app” folder):
• app/layout.tsx, app/page.tsx: root layout and home page
• app/signin/page.tsx + components/Signin.tsx + AuthClient.tsx + amplify-utils.ts: login flow
• globals.css, tailwind.config.ts, postcss.config.mjs: styling with Tailwind CSS
• AWS Amplify configuration (“amplify” folder):
• amplify/auth/resource.ts: Cognito auth resource definitions
• amplify/data/resource.ts: Data store (likely GraphQL/DynamoDB) definitions
• amplify/backend.ts + tsconfig.json + package.json: Amplify backend bootstrap
• Config files: next.config.mjs, tsconfig.json, .eslintrc.json
README
• Confirms a create-next-app scaffold
• Browser / Client (React running in user’s browser)
• Next.js Server (app router + server components)
• AWS Amplify Backend
– Cognito (Authentication)
– Data API (GraphQL or REST backed by DynamoDB)
• Dev tooling (Amplify CLI / Node build process)
1. User → Browser UI (HTTP/HTTPS)
2. Browser UI → Next.js Server (SSR/SSR data fetching)
3. Browser (AuthClient) → AWS Cognito (via Amplify SDK)
4. Browser (amplify-utils) → AWS Data API (GraphQL/REST calls)
5. Next.js Server (if using getServerSideProps or API routes) → Amplify backend (optional server-side calls)
c. Architectural patterns & design principles
• Full-stack separation: front-end (Next.js UI) vs. backend (AWS microservices).
• Server-side rendering (SSR) alongside client-side hydration for auth flows.
• Cloud-native backend using managed services (Cognito + GraphQL/DynamoDB).
• Infrastructure as code via Amplify resource.ts files.
d. Key technologies & libraries
• Next.js 13 (app router, server components)
• React & Tailwind CSS for UI
• AWS Amplify SDK for client-side calls
• AWS Cognito for user pools (authentication)
• AWS AppSync or API Gateway + DynamoDB for data (amplify/data)