# Building Wild App This document describes the architecture and tooling used to build the Wild App, the web-based interface for managing Wild Cloud instances, hosted on Wild Central. ## Principles - Stick with well known standards. - Keep it simple. - Use popular, well-maintained libraries. - Use components wherever possible to avoid reinventing the wheel. - Use TypeScript for type safety. ### Tooling ## Dev Environment Requirements - Node.js 20+ - pnpm for package management - vite for build tooling - React + TypeScript - Tailwind CSS for styling - shadcn/ui for ready-made components - radix-ui for accessible components - eslint for linting - tsc for type checking - vitest for unit tests #### Makefile commands - Build application: `make app-build` - Run locally: `make app-run` - Format code: `make app-fmt` - Lint and typecheck: `make app-check` - Test installation: `make app-test` ### Scaffolding apps It is important to start an app with a good base structure to avoid difficult to debug config issues. This is a recommended setup. #### Install pnpm if necessary: ```bash curl -fsSL https://get.pnpm.io/install.sh | sh - ``` #### Install a React + Speedy Web Compiler (SWC) + TypeScript + TailwindCSS app with vite: ``` pnpm create vite@latest my-app -- --template react-swc-ts ``` #### Reconfigure to use shadcn/ui (radix + tailwind components) (see https://ui.shadcn.com/docs/installation/vite) ##### Add tailwind. ```bash pnpm add tailwindcss @tailwindcss/vite ``` ##### Replace everything in src/index.css with a tailwind import: ```bash echo "@import \"tailwindcss\";" > src/index.css ``` ##### Edit tsconfig files The current version of Vite splits TypeScript configuration into three files, two of which need to be edited. Add the baseUrl and paths properties to the compilerOptions section of the tsconfig.json and tsconfig.app.json files: tsconfig.json ```json { "files": [], "references": [ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ], "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./src/*"] } } } ``` tsconfig.app.json ```json { "compilerOptions": { // ... "baseUrl": ".", "paths": { "@/*": [ "./src/*" ] } // ... } } ``` ##### Update vite.config.ts ```bash pnpm add -D @types/node ``` Then edit vite.config.ts to include the node types: ```ts import path from "path" import tailwindcss from "@tailwindcss/vite" import react from "@vitejs/plugin-react" import { defineConfig } from "vite" // https://vite.dev/config/ export default defineConfig({ plugins: [react(), tailwindcss()], resolve: { alias: { "@": path.resolve(__dirname, "./src"), }, }, }) ``` ##### Run the cli ```bash pnpm dlx shadcn@latest init ``` ##### Add components ```bash pnpm dlx shadcn@latest add button pnpm dlx shadcn@latest add alert-dialog ``` You can then use components with `import { Button } from "@/components/ui/button"` ### UX Principles These principles ensure consistent, intuitive interfaces that align with Wild Cloud's philosophy of simplicity and clarity. Use them as quality control when building new components. #### Navigation & Structure - **Use shadcn AppSideBar** as the main navigation: https://ui.shadcn.com/docs/components/sidebar - **Card-Based Layout**: Group related content in Card components - Primary cards: `p-6` padding - Nested cards: `p-4` padding with subtle shadows - Use cards to create visual hierarchy through nesting - **Spacing Rhythm**: Maintain consistent vertical spacing - Major sections: `space-y-6` - Related items: `space-y-4` - Form fields: `space-y-3` - Inline elements: `gap-2`, `gap-3`, or `gap-4` #### Visual Design - **Dark Mode**: Support both light and dark modes using Tailwind's `dark:` prefix - Test all components in both modes for contrast and readability - Use semantic color tokens that adapt to theme - **Status Color System**: Use semantic left border colors to categorize content - Blue (`border-l-blue-500`): Configuration sections - Green (`border-l-green-500`): Network/infrastructure - Red (`border-l-red-500`): Errors and warnings - Cyan: Educational content - **Icon-Text Pairing**: Pair important text with Lucide icons - Place icons in colored containers: `p-2 bg-primary/10 rounded-lg` - Provides visual anchors and improves scannability - **Technical Data Display**: Show technical information clearly - Use `font-mono` class for IPs, domains, configuration values - Display in `bg-muted rounded-md p-2` containers #### Component Patterns - **Edit/View Mode Toggle**: For configuration sections - Read-only: Display in `bg-muted rounded-md font-mono` containers with Edit button - Edit mode: Replace with form inputs in-place - Provides lightweight editing without context switching - **Drawers for Complex Forms**: Use side panels for detailed input - Maintains context with main content - Better than modals for forms that benefit from seeing related data - **Educational Content**: Use gradient cards for helpful information - Background: `from-cyan-50 to-blue-50 dark:from-cyan-900/20 dark:to-blue-900/20` - Include book icon and clear, concise guidance - Makes learning feel integrated, not intrusive - **Empty States**: Center content with clear next actions - Large icon: `h-12 w-12 text-muted-foreground` - Descriptive title and explanation - Suggest action to resolve empty state #### Section Headers Structure all major section headers consistently: ```tsx
Brief description of section purpose