Next.js 14 application with TypeScript focusing on text generation workflows. Key features:
- AI-powered text completion endpoints
- File upload processing
- Internationalization (i18n) support
- Monaco Editor integration
- Batch processing capabilities
- Framework: Next.js 14.1.1
- Language: TypeScript 4.9.5
- Styling: Tailwind CSS 3.2.7 + SCSS
- State Management: SWR 2.1.0 + Immer 9.0.19
- Internationalization: i18next 22.4.13
- UI: HeadlessUI 1.7.13 + Heroicons 2.0.16
- Text Processing: React-Markdown 8.0.6 + KaTeX
- Data Handling: Axios 1.3.5 + PapaParse 4.1.0
- Code Editing: Monaco Editor 4.6.0
- Utilities: classnames, uuid, copy-to-clipboard
├── app/ # Next.js app router
│ ├── api/ # API endpoints
│ │ ├── completion-messages/
│ │ ├── file-upload/
│ │ └── workflows/
│ └── components/ # Reusable components
│ ├── base/ # UI primitives
│ └── result/ # Display components
├── i18n/ # Localization config
│ └── lang/ # Translation files
├── public/ # Static assets
│ └── vs/ # Monaco Editor resources
├── service/ # API client layer
└── types/ # Type definitions
# Install dependencies
yarn install
# Start dev server
yarn dev
# Production build
yarn build && yarn start
# Linting
yarn lint # Check for issues
yarn fix # Auto-fix lint errors-
API Design:
- REST endpoints under
/app/api - Dify client integration for AI completions
- File upload processing with streaming support
- REST endpoints under
-
Internationalization:
- Bilingual support (en/zh)
- Server/client split translations
- React-i18next hooks
-
Code Quality:
- ESLint with strict TypeScript rules
- Pre-commit hooks (Husky)
- Error boundary wrappers
FROM --platform=linux/amd64 node:19-bullseye-slim
WORKDIR /app
COPY . .
RUN yarn install && yarn build
EXPOSE 3000
CMD ["yarn","start"]-
Base Components (
/components/base):- Headless UI primitives (Button, Select, Tooltip)
- Icon system with Heroicons
- Form elements (ImageUploader, MarkdownEditor)
- Loading states and error boundaries
-
Feature Components:
- Text Generation Interface (
/components/run-once) - Batch Processing UI (
/components/run-batch) - Result Visualization (
/components/result) - Configuration Management (
/components/config-scence)
- Text Generation Interface (
- Compound Components: Used in complex UI elements (e.g., TabHeader)
- Component Composition: Base components combined in feature components
- State Management:
- Local state with
useState/useReducer - Global UI state via Context API
- Form state management with uncontrolled components
- Local state with
- Tailwind CSS utility classes
- CSS Modules for component-scoped styles
- Responsive design hooks (
useBreakpoints) - Animation transitions with Headless UI
- Location:
components/config-scence(variable configuration setup)components/run-once(runtime input collection)
- Dynamic form generation from
prompt_variablesconfiguration - Input types supported:
- Text inputs (string variables)
- Number inputs (number variables)
- File uploads (image variables via
image-uploadercomponents)
- State Management:
- Form state tracked via React
useState - Input values stored in key-value pairs mapped to variable names
- Form state tracked via React
- Validation:
- Required field checking
- Type validation (numeric ranges, string formats)
- Real-time validation feedback
- Styling:
- Tailwind classes for input styling
- CSS Modules for layout structure
- Error states using border colors and text styles
- Monaco Editor for code editing
- React-Tooltip for interactive hints
- Floating UI for positioning
- React-Syntax-Highlighter for code display
-
Component Structure:
- Presentational components in
/components/base - Feature components in
/components/[feature] - CSS Modules for component styling
- Presentational components in
-
State Management:
- SWR for data fetching/caching
- Context API for global state
- Immer for immutable updates
-
Testing:
- TypeScript compiler as primary validation
- Interactive testing via dev server