Lesson 7 of 8
Mini Project: Full-Stack Architecture Blueprint
This topic documents the architecture blueprint for a production-grade React application - the reference architecture combining all module 9 concepts: TypeScript strict mode, feature-based folders, shared design system package, i18n, a11y, and a documented path to micro-frontends.
Production Architecture Documentation
/**
* PRODUCTION REACT APPLICATION ARCHITECTURE BLUEPRINT
*
* Stack:
* - Framework: Next.js 14 (App Router) with TypeScript strict mode
* - Monorepo: pnpm workspaces + Turborepo
* - UI Library: Radix UI primitives + custom design system package
* - State: Zustand (client), TanStack Query (server), Context (auth/theme)
* - Forms: react-hook-form + Zod
* - Routing: Next.js App Router (RSC + client where needed)
* - i18n: react-i18next with namespace splitting
* - Testing: Vitest, RTL, MSW, Playwright
* - CI: GitHub Actions with Turbo caching
*
* Repository structure:
* my-platform/
* apps/
* web/ ← Next.js customer-facing app
* admin/ ← React admin (Vite, can be MFE later)
* packages/
* ui/ ← Design system (Button, Input, Modal, DataTable)
* api-client/ ← OpenAPI-generated typed client
* utils/ ← Shared formatters, validators, types
* config/
* eslint-config/
* typescript-config/
*
* apps/web/ feature folders:
* src/features/
* auth/ ← Login, Signup, Token refresh, AuthProvider
* products/ ← Catalog, Detail, Search, Filters
* cart/ ← Cart state, Checkout flow
* orders/ ← Order history, Order detail
* user/ ← Profile, Settings, Preferences
* dashboard/ ← Analytics, Stats (admin role only)
*
* Conventions:
* - Feature barrel exports (index.ts) - no internal imports across features
* - Server Components by default, add 'use client' only at interaction boundary
* - Zod validation at API boundary (runtime) + TypeScript (compile time)
* - All API calls through typed api-client package
* - All UI through ui package (never create one-off primitive components)
* - Error boundaries at route level + feature level for graceful degradation
* - 100% accessible: all components pass axe-core + WCAG 2.1 AA
* - All user-facing strings in i18n namespace files (zero hardcoded strings)
*
* Performance budget (measured in CI):
* - LCP < 2.5s (3G slow)
* - CLS < 0.1
* - INP < 200ms
* - Initial JS bundle < 100KB gzipped
* - Lighthouse score > 90 on all four categories
*/
// apps/web/src/app/layout.tsx - root server layout
import { Inter } from 'next/font/google';
import { Providers } from '@/shared/providers/Providers';
import { SkipLink } from '@my-platform/ui';
const inter = Inter({ subsets: ['latin'], variable: '--font-inter' });
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" dir="ltr" className={inter.variable}>
<body>
<SkipLink href="#main" />
<Providers>
<main id="main" tabIndex={-1}>
{children}
</main>
</Providers>
</body>
</html>
);
}
// apps/web/src/shared/providers/Providers.tsx - all providers in one place
'use client';
import { QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { I18nextProvider } from 'react-i18next';
import { AuthProvider } from '@/features/auth';
import { ToastProvider } from '@my-platform/ui';
import { queryClient } from '@/shared/api/queryClient';
import i18n from '@/shared/i18n/i18n';
export function Providers({ children }: { children: React.ReactNode }) {
return (
<QueryClientProvider client={queryClient}>
<I18nextProvider i18n={i18n}>
<AuthProvider>
<ToastProvider>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</ToastProvider>
</AuthProvider>
</I18nextProvider>
</QueryClientProvider>
);
}
// Type-safe environment variables (validated at startup)
// apps/web/src/shared/env.ts
import { z } from 'zod';
const envSchema = z.object({
NEXT_PUBLIC_API_URL: z.string().url(),
NEXT_PUBLIC_APP_URL: z.string().url(),
NODE_ENV: z.enum(['development', 'production', 'test']),
});
export const env = envSchema.parse({
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
NODE_ENV: process.env.NODE_ENV ?? 'development',
});
// Import env.ts in any file - TypeScript knows all env vars are valid stringsTip
Tip
Practice Mini Project FullStack Architecture Blueprint in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Visual architecture and flow for Mini Project: Full-Stack Architecture Blueprint
Practice Task
Note
Practice Task - (1) Write a working example of Mini Project FullStack Architecture Blueprint from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Mini Project FullStack Architecture Blueprint is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react code.
Finished this lesson?