A Next.js application demonstrating a 3-tier microservice architecture simulation using the App Router and TypeScript.
This application simulates a microservice pipeline with three services:
- Location:
app/page.tsx - Purpose: User interface with a "Start Data Pipeline" button
- Action: Initiates the pipeline by calling Service B at
http://localhost:3000/api/process - Technology: Next.js Client Component with React hooks
- Location:
app/api/process/route.ts - Purpose: Processes requests and forwards them to Service C
- Actions:
- Logs "Service B: Received request"
- Simulates processing with a 300ms delay
- Forwards request to Service C at
http://localhost:3000/api/store
- Technology: Next.js API Route with standard Web Request/Response APIs
- Location:
app/api/store/route.ts - Purpose: Persists data (simulates CloudWatch storage)
- Actions:
- Logs "Service C: Persisting data to CloudWatch"
- Returns JSON success message:
{ status: 'Data Saved' }
- Technology: Next.js API Route with standard Web Request/Response APIs
- ✅ Full absolute URLs for internal service-to-service calls (
http://localhost:3000) - ✅ TypeScript for type safety
- ✅ Tailwind CSS for modern, responsive UI
- ✅ App Router architecture
- ✅ Console logging for request tracing
- ✅ Error handling for all services
- Node.js 18.x or higher
- npm
- Navigate to the project directory:
cd microserviceapp- Install dependencies (already done during setup):
npm install- Run the development server:
npm run dev- Open your browser and navigate to:
http://localhost:3000
- Click the "Start Data Pipeline" button on the homepage
- Watch the status update as the request flows through the pipeline
- Check the terminal console to see the logs from each service:
- "Service B: Received request"
- "Service C: Persisting data to CloudWatch"
User Click → Service A (Frontend)
↓ POST http://localhost:3000/api/process
Service B (Processor)
↓ 300ms delay
↓ POST http://localhost:3000/api/store
Service C (Storage)
↓ Returns: { status: 'Data Saved' }
Service B ← Response
↓
Service A ← Response
↓
User sees success message
All internal service-to-service calls use full absolute URLs (http://localhost:3000) instead of relative paths. This ensures that OpenTelemetry tracing can properly capture each "hop" in the microservice pipeline.
microserviceapp/
├── app/
│ ├── api/
│ │ ├── process/
│ │ │ └── route.ts # Service B - Processor
│ │ └── store/
│ │ └── route.ts # Service C - Storage
│ ├── page.tsx # Service A - Frontend
│ ├── layout.tsx # Root layout
│ └── globals.css # Global styles
├── public/ # Static assets
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
├── tailwind.config.ts # Tailwind config
└── next.config.ts # Next.js config
- Framework: Next.js 16.1.6 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- Runtime: Node.js
- Package Manager: npm
To build for production:
npm run buildTo start the production server:
npm start- The application uses Turbopack for faster development builds
- All API routes use standard Web Request/Response APIs
- Console logs help track the request flow through the pipeline
- The 300ms delay in Service B simulates real-world processing time
This is a demonstration project for learning microservice architectures with Next.js.