Bash
Overview
The Architecture Pipeline
+----------------+ +----------------+ +----------------+
| Browser | | Next.js BFF | | Backend APIs |
| | | | | |
| Pages & |---->| API Routes |---->| Surabaya API |
| Components | | /api/data/ | | BASE_API_URL |
| | | | | |
| React Query | | Axios + Sign | | WebDisplay API |
| TanStack | | Header Proxy | | API_URL_WD |
+----------------+ +----------------+ +----------------+
Step One: Project Setup
Environment Configuration
Env
Project Structure
frontend/
├── components/ # Reusable UI components
│ ├── header.tsx
│ ├── footer.tsx
│ ├── layout.tsx
│ ├── home.section1.tsx ... home.section7.tsx
│ ├── carousel.*.tsx
│ ├── news.*.tsx
│ ├── media.*.tsx
│ ├── wisata.tsx
│ ├── infografis.*.tsx
│ ├── search.tsx
│ ├── pagination.tsx
│ └── accessibility.tsx
├── pages/
│ ├── index.tsx
│ ├── berita/
│ ├── agenda/
│ ├── wisata/
│ ├── infografis/
│ ├── photos/
│ ├── videos/
│ ├── podcasts/
│ └── api/data/ # BFF proxy layer
│ ├── news.tsx
│ ├── agenda.tsx
│ ├── menu.tsx
│ └── webdisplay.tsx
├── hooks/
├── contexts/
├── types/
└── utils/
├── axios.config.tsx
└── services/
Step Two: Backend-for-Frontend Pattern
Axios Configuration
Typescript
BFF Proxy Route Example
Typescript
Step Three: Data Fetching with React Query
Service Layer
Typescript
Using React Query in Components
Typescript
Step Four: Page Routing
Route Map
/ Home page
/berita News list
/berita/[slug] News detail
/agenda City events list
/wisata Tourism information
/infografis Infographics list
/photos Photo gallery
/videos Video gallery
/podcasts Podcast gallery
/api/data/news BFF: news proxy
/api/data/agenda BFF: agenda proxy
/api/data/menu BFF: navigation menu proxy
/api/data/webdisplay BFF: webdisplay proxy
Dynamic Route Example
Typescript
Step Five: Key Components
Layout Wrapper
Typescript
Component Reference
Step Six: Docker Deployment
Docker Compose
Yaml
Dockerfile Multi-Stage Build
Dockerfile
Docker Configuration
Optimization Tips
React Query Caching Strategy
Typescript
Security Headers
Javascript