Next.js App Router Structure
Relevant source files
The following files were used as context for generating this wiki page:
The Next.js App Router structure in superglue provides the architectural foundation for the web-based AI integration platform. It organizes the frontend into a hierarchy of layouts and pages that manage global configurations, user onboarding, and system environment validation. The structure separates global provider logic in the root layout from specific application states like initial setup and tenant welcome flows.
Sources: packages/web/src/app/layout.tsx, CLAUDE.md
Root Layout and Global Configuration
The RootLayout serves as the entry point for the entire application, defining the HTML structure and initializing global providers. It configures the environment by injecting API endpoints and authentication keys into a ClientWrapper.
Metadata and Environment Initialization
The layout defines application-wide metadata including SEO titles, descriptions, and OpenGraph settings. It retrieves the API_ENDPOINT and AUTH_TOKEN from environment variables to establish the base configuration for the superglue client.
Sources: packages/web/src/app/layout.tsx:10-54
Global State Injection
The application uses a config object to pass server-side environment variables to client-side components. This includes PostHog analytics keys and a default serverSession for the Open Source (OSS) version.
| Config Key | Source Variable | Description |
|---|---|---|
superglueApiKey | AUTH_TOKEN / NEXT_PUBLIC_SUPERGLUE_API_KEY | Primary API authentication |
apiEndpoint | API_ENDPOINT (Default: port 3002) | Target REST API URL |
postHogKey | NEXT_PUBLIC_POSTHOG_KEY | Analytics integration key |
Sources: packages/web/src/app/layout.tsx:55-75
Onboarding and Tenant Management
The router includes a dedicated /welcome route used for initial user acquisition and workspace setup. This flow captures user email information and manages tenant-specific state via cookies and API calls.
Welcome Flow Logic
The WelcomePage uses a conditional redirect strategy. If the welcome screen is disabled via NEXT_PUBLIC_DISABLE_WELCOME_SCREEN or if the user has already provided an email, the router redirects the user to the home page.
The diagram shows the logic for determining whether a user sees the onboarding screen or is redirected to the main application dashboard.
Sources: packages/web/src/app/welcome/page.tsx:32-113
Environment and Setup Validation
The /setup route provides a diagnostic interface for developers to verify the server's environment configuration. It visualizes the status of critical infrastructure components.
Configuration Sections
The setup page categorizes environment variables into four primary groups:
- Auth & Endpoints: Validates
AUTH_TOKENand exposes REST API base URLs. - Model Provider: Displays active LLM configuration (e.g., OpenAI, Anthropic) based on
LLM_PROVIDER. - Datastore: Confirms PostgreSQL connection details.
- Object Storage: Verifies S3-compatible storage (AWS or MinIO) for knowledge base files.
Sources: packages/web/src/app/setup/page.tsx:215-325
Validation States
The UI uses specific visual indicators to represent the health of the configuration:
- OK: Variable is set and valid.
- Warning: Optional variable is missing or potentially misconfigured.
- Missing/Required: Critical variable is absent, preventing full functionality.
Sources: packages/web/src/app/setup/page.tsx:199-213
Application Navigation and UI Components
The application structure follows a standard sidebar-based navigation pattern described in the agent prompts and UI guidelines.
Primary Navigation Routes
| Route | Component/Section | Purpose |
|---|---|---|
/ | Dashboard/Landscape | Visual graph of tools and systems |
/tools | Tool List | Management of saved integration workflows |
/systems | System List | Configuration of external API credentials |
/control-panel | Admin Suite | Runs history, API keys, and RBAC settings |
Sources: packages/web/src/lib/agent/agent-prompts.ts:47-60
Component Architecture
UI primitives are located in packages/web/src/components/ui/, utilizing shadcn/Radix components. Components leverage a cn() utility for conditional class merging and maintain a consistent design system across the App Router routes.
Sources: CLAUDE.md:120-130
Summary
The Next.js App Router structure in superglue provides a robust framework for managing environment-aware deployments. By utilizing the root layout for global state injection and dedicated routes for onboarding and diagnostics, the architecture ensures that the AI integration platform remains configurable across different LLM providers and storage backends.