How goitacademy/nextjs-course-code works
Purpose and Runtime
This is a Next.js App Router administrative UI for viewing and managing companies and their promotions, plus a dashboard of business summaries. It runs as a React/TypeScript web application, with the Next.js server/runtime handling route rendering and navigation. Styling is global CSS plus Tailwind configuration.
Primary application entry points are src/app/layout.tsx, src/app/page.tsx, and the admin shell at src/app/(admin)/layout.tsx.
Application Shell and Navigation
The root layout establishes cross-route application concerns; the admin route group supplies the management-area frame. Shared navigation and page chrome are componentized around header, sidebar, and toolbar primitives.
Key paths:
• src/app/layout.tsx
• src/app/(admin)/layout.tsx
• src/app/components/header.tsx
• src/app/components/sidebar.tsx
Dashboard Composition
/dashboard is a composite route using App Router parallel routes. Its layout renders independently supplied slots for categories, countries, promotions, sales, and stats, allowing dashboard panels to be fetched/rendered in isolation and to have localized loading/error behavior where implemented.
Key paths:
• src/app/(admin)/dashboard/layout.tsx
• src/app/(admin)/dashboard/@stats/page.tsx
• src/app/(admin)/dashboard/@sales/page.tsx
• src/app/(admin)/dashboard/error.tsx
Dashboard display is built from reusable summary/card components, notably src/app/components/dashboard-card.tsx and src/app/components/summary-table.tsx.
Companies Domain and Detail Flow
The companies route is the central CRUD-oriented domain. The list route presents company rows/table data; dynamic [id] routes render a company detail page and its promotion-related context. A route-level not-found boundary supports invalid or missing company identifiers.
Key paths:
• src/app/(admin)/companies/page.tsx
• src/app/(admin)/companies/[id]/page.tsx
• src/app/(admin)/companies/[id]/not-found.tsx
• src/app/components/company-table.tsx
• src/app/components/company-info.tsx
• src/app/components/company-promotions.tsx
Modal, Toolbar, and Header Route Slots
The companies layout uses parallel route slots (@header, @toolbar, @modal) to vary surrounding UI by list, detail, creation, and promotion-creation state. Intercepting modal routes—such as (.)new and (.)new-promotion—overlay forms during in-app navigation while canonical /new and /[id]/new-promotion routes remain directly addressable.
Key paths:
• src/app/(admin)/companies/layout.tsx
• src/app/(admin)/companies/@modal/(.)new/page.tsx
• src/app/(admin)/companies/@modal/[id]/(.)new-promotion/page.tsx
• src/app/(admin)/companies/new/page.tsx
• src/app/(admin)/companies/[id]/new-promotion/page.tsx
Mutation UI and Data Boundary
Company and promotion creation/editing are represented by dedicated form and modal components. UI components should remain consumers of the repository’s API abstraction rather than coupling directly to a backend transport. getQueryClient and providers indicate a client-side query/cache provider boundary, while api.ts is the likely external data-service integration point.
Key paths:
• src/app/components/company-form.tsx
• src/app/components/promotion-form.tsx
• src/app/components/providers.tsx
• src/lib/api.ts
• src/lib/utils/getQueryClient.ts
Failure and Asset Boundaries
Global and dashboard-specific error boundaries prevent rendering failures from collapsing the whole application. Static visual assets are served from Next’s public directory; uploaded company logos are handled through a dedicated UI component, with persistence/service behavior expected behind the API layer.
Key paths:
• src/app/global-error.tsx
• src/app/(admin)/dashboard/error.tsx
• src/app/components/logo-uploader.tsx
• public/images
Main entry points: companies/layout.tsx Companies layout · api.ts API abstraction · app/layout.tsx Root layout · (admin)/layout.tsx Admin shell
Components 23
App Shell
- Root layout
src/app/layout.tsx - Admin shell · Management-area frame.
src/app/(admin)/layout.tsx - Header & sidebar
src/app/components/header.tsx - Global error boundary
src/app/global-error.tsx
Dashboard
- Dashboard layout · Composes independently rendered dashboard slots.
src/app/(admin)/dashboard/layout.tsx - Dashboard slots · Stats, sales, categories, countries, and promotions panels.
src/app/(admin)/dashboard/@stats/page.tsx - Dashboard summaries
src/app/components/dashboard-card.tsx - Dashboard error boundary
src/app/(admin)/dashboard/error.tsx
Companies
- Companies layout · Hosts header, toolbar, and modal slots.
src/app/(admin)/companies/layout.tsx - Companies list
src/app/(admin)/companies/page.tsx - Company table
src/app/components/company-table.tsx - Company detail
src/app/(admin)/companies/[id]/page.tsx - Company detail views · Company information and promotions context.
src/app/components/company-info.tsx - Company not found
src/app/(admin)/companies/[id]/not-found.tsx - Creation routes · Directly addressable company and promotion creation pages.
src/app/(admin)/companies/new/page.tsx - Intercepting modals · Overlays creation forms during in-app navigation.
src/app/(admin)/companies/@modal/(.)new/page.tsx - Company & promotion forms
src/app/components/company-form.tsx
Data & Assets
- Query providers · Supplies client query and cache context.
src/app/components/providers.tsx - Query client
src/lib/utils/getQueryClient.ts - API abstraction · External data-service boundary.
src/lib/api.ts - Logo uploader
src/app/components/logo-uploader.tsx - Public images
public/images
Other components
- Next.js App Router · Renders routes and manages navigation.
Connections 26
- Next.js App Router → Root layout: renders
- Root layout → Admin shell: wraps admin routes
- Root layout → Query providers: provides
- Root layout → Global error boundary: guards
- Admin shell → Header & sidebar: renders chrome
- Admin shell → Dashboard layout: hosts
- Admin shell → Companies layout: hosts
- Query providers → Query client: initializes
- Dashboard layout → Dashboard slots: renders slots
- Dashboard slots → Dashboard summaries: composes
- Dashboard layout → Dashboard error boundary: guards
- Dashboard slots → API abstraction: loads summaries
- Companies layout → Companies list: renders
- Companies layout → Company detail: renders dynamic route
- Companies layout → Creation routes: hosts canonical routes
- Companies layout → Intercepting modals: renders modal slot
- Companies list → Company table: displays
- Company detail → Company detail views: composes
- Company detail → Company not found: falls back
- Intercepting modals → Company & promotion forms: overlays
- Creation routes → Company & promotion forms: renders
- Company & promotion forms → API abstraction: mutates through
- Company table → API abstraction: loads through
- Company detail views → API abstraction: loads through
- Logo uploader → API abstraction: uploads through
- Public images → Logo uploader: serves visual assets