A Next.js Web Application for Document Viewing - ProjectDuck (Project Document's phonetic pun)
ProjectDuck is a modern file browser and document viewer built on the Next.js 15 full-stack framework. It provides an intuitive dual-panel interface specifically designed for viewing and browsing documents in server-side specified directories, with rich rendering capabilities especially for Markdown files.
- π― Modern Full-Stack Architecture: Based on Next.js 15 + App Router, supports SSR/SSG
- π¨ Intuitive Dual-Panel Design: File tree on the left + content viewer on the right, with adjustable split ratios
- π Enhanced Markdown Support: GitHub Flavored Markdown + Mermaid chart rendering + Markmap mind map visualization
- π Theme Switching: Dark/light modes based on Ant Design theme system
- π Internationalization: Default Traditional Chinese with multi-language support
- β‘ Performance Optimization: API response caching, lazy loading, dynamic imports
- π Smart Search: Real-time file tree search and filtering
- π Hot Reload Configuration: Automatically detects changes to projects.json and updates configuration
- π± Responsive Design: Adapts to desktop, tablet, and other screen sizes
- Next.js 15.4.6 - Full-stack React framework (App Router + API Routes)
- React 18.3.1 - Modern frontend library
- TypeScript 5.x - Static type support
- Ant Design 5.26.7 - Enterprise-class UI component library
- Allotment 1.20.4 - Resizable split panels
- Tailwind CSS 4 - Utility-first CSS framework
- CSS Modules - Component style isolation
- react-markdown 10.1.0 - Markdown to React component conversion
- remark-gfm 4.0.1 - GitHub Flavored Markdown support
- react-syntax-highlighter 15.6.1 - Code syntax highlighting
- rehype-highlight 7.0.2 - Code highlighting in Markdown
- Mermaid - Flowchart and diagram rendering
- next-i18next 15.4.2 - Next.js internationalization support
- i18next 25.3.2 - Multi-language framework
- fs-extra 11.3.1 - Enhanced file system operations
- mime-types 3.0.1 - MIME type detection
- chokidar 4.x - Cross-platform file watching for configuration hot reload
| File Type | Supported Features |
|---|---|
Markdown (.md, .markdown) |
GFM syntax, tables, task lists, syntax highlighting, Mermaid charts |
| Code Files | JavaScript, TypeScript, Python, Java, C++, Go, Rust and 190+ languages |
| JSON | Formatted display with syntax highlighting |
| Images | JPG, PNG, GIF, SVG, WebP and other formats |
| Videos | MP4, WebM, MOV and browser-supported formats |
| Plain Text | TXT, LOG and other text files |
ProjectDuck/
βββ src/
β βββ app/ # Next.js App Router
β β βββ api/ # API routes
β β β βββ directory/ # Directory listing API
β β β βββ file/ # File operations API
β β β βββ projects/ # Project configuration API
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Home page
β βββ components/
β β βββ layout/AppLayout.tsx # Main app layout
β β βββ fileTree/FileTree.tsx # File tree component
β β βββ contentViewer/ # Content viewer components
β β β βββ ContentViewer.tsx # Main content viewer
β β β βββ MarkdownViewer.tsx # Markdown renderer
β β β βββ CodeViewer.tsx # Code syntax highlighter
β β β βββ MediaViewer.tsx # Image/video viewer
β β βββ project/ # Project management components
β β βββ WarningSupressor.tsx # SSR hydration warning handler
β βββ lib/
β β βββ services/ # API and utility services
β β βββ providers/ # Context providers (theme, project)
β β βββ hooks/ # Custom React hooks
β β βββ i18n/ # Internationalization config
β β βββ types.ts # TypeScript type definitions
β βββ styles/ # Component styles
βββ public/
β βββ locales/ # Translation files
βββ docker/ # Docker configuration and scripts
βββ example/ # Example files directory
βββ projects.json # Project configuration file
βββ next.config.ts # Next.js configuration
βββ next-i18next.config.js # Internationalization config
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
- Node.js 18.0 or higher
- npm, yarn, pnpm, or bun
- Install Dependencies
npm install
# or
yarn install
# or
pnpm install- Start Development Server
npm run dev
# or
yarn dev
# or
pnpm dev- Open Browser Navigate to http://localhost:3000 to view the application
# Development mode (with Turbopack support)
npm run dev
# Production build
npm run build
# Start production server
npm start
# Linting
npm run lintCopy .env.example to .env.local and configure as needed:
# Claude Code Integration (default: false)
# Set to 'true' to enable Claude Code features (chat panel, AI assistance)
ENABLE_CLAUDE_CODE=false
# File browsing configuration
BASE_PATH=/path/to/your/files
# Claude Code settings (when enabled)
CLAUDE_SSE_BUFFER_SIZE_MB=5
CLAUDE_MAX_RESPONSE_SIZE_MB=10
CLAUDE_CONNECTION_TIMEOUT_MS=30000
# File processing
MAX_FILE_SIZE_MB=10
MAX_PREVIEW_SIZE_MB=5
# Security
ENABLE_PATH_VALIDATION=true
# Performance
ENABLE_VIRTUALIZATION=false
VIRTUALIZATION_THRESHOLD=1000See .env.example for all available configuration options.
Configure languages in next-i18next.config.js:
module.exports = {
i18n: {
defaultLocale: "zh_tw", // Default Traditional Chinese
locales: ["en", "zh_tw"], // Supported languages
},
};By default, browses files in the /example directory. Can be modified via the BASE_PATH environment variable.
- Left Panel: File tree browser with expand/collapse and search filtering
- Right Panel: Dynamic content viewer that automatically switches rendering modes based on file type
- Adjustable: Drag to adjust the width ratio between left and right panels
- β Full GitHub Flavored Markdown support
- β Code block syntax highlighting (190+ languages)
- β Automatic Mermaid chart rendering (flowcharts, sequence diagrams, Gantt charts, etc.)
- β Markmap mind map visualization - One-click toggle to view Markdown files as interactive mind maps
- β Tables, task lists, strikethrough and other extended syntax
- π‘ Section collapsing functionality (in development)
- API Caching: Smart caching mechanism reduces duplicate requests
- Lazy Loading: Dynamic loading of file tree and components
- Hot Configuration Reload: Automatically detects and applies changes to projects.json without restart
- Memory-based Config Cache: Lightning-fast project configuration access
- Responsive: Adapts to different screen sizes
- Theme Switching: One-click toggle between dark/light modes
- Search Functionality: Real-time filename search with highlighting
- TypeScript: Strict mode, path alias
@/* - ESLint: Next.js + TypeScript rule set
- Tailwind CSS: Coexisting configuration with Ant Design
Add handling logic in src/components/contentViewer/ContentViewer.tsx:
const getContentType = (file: FileItem) => {
if (file.extension === ".your-extension") {
return "your-custom-type";
}
// ... other type checks
};Create new route files in the src/app/api/ directory:
// src/app/api/your-endpoint/route.ts
import { NextRequest, NextResponse } from "next/server";
export async function GET(request: NextRequest) {
// Processing logic
return NextResponse.json({ success: true, data: result });
}ProjectDuck is containerized and available as kelithius/projectduck Docker image.
Important: ProjectDuck requires a projects.json configuration file. The application automatically monitors this file for changes and updates the configuration without requiring a restart.
# Create required configuration
echo '{
"version": "1.0",
"projects": [
{
"name": "My Documents",
"path": "/workspace/docs"
}
]
}' > projects.json
# Pull and run with configuration
docker run -d -p 3000:3000 \
--name projectduck \
-v $(pwd)/projects.json:/app/projects.json \
-v /path/to/your/workspace:/workspace \
kelithius/projectduck:latest
# You can now edit projects.json and changes will be detected automatically
# Simply refresh the page to see updated project configurationsMount your workspace directory containing all projects:
docker run -d -p 3000:3000 \
--name projectduck \
-v /path/to/your/workspace:/workspace \
-v $(pwd)/projects.json:/app/projects.json \
kelithius/projectduck:latestCreate a custom projects.json file and mount it:
# Create custom projects.json
cat > my-projects.json << EOF
{
"version": "1.0",
"projects": [
{
"name": "My Documentation",
"path": "/workspace/docs"
},
{
"name": "Project Files",
"path": "/workspace/project"
}
]
}
EOF
# Run with custom configuration
docker run -d -p 3000:3000 \
--name projectduck \
-v $(pwd)/my-projects.json:/app/projects.json \
-v /path/to/your/workspace:/workspace \
kelithius/projectduck:latestCreate a docker-compose.yml file for easier management:
version: "3.8"
services:
projectduck:
image: kelithius/projectduck:latest
container_name: projectduck
restart: unless-stopped
ports:
- "3000:3000"
# Environment variables
environment:
- NODE_ENV=production
- PORT=3000
- HOSTNAME=0.0.0.0
# Volume mounts for custom documents and configuration
volumes:
# Mount your workspace directory containing all projects
- /path/to/your/workspace:/workspace
# Optional: Custom projects.json configuration
# - ./custom-projects.json:/app/projects.json
# Health check
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:3000/health",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Security options
security_opt:
- no-new-privileges:trueThen run:
# Start with docker-compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down# Clone the repository
git clone <repository-url>
cd ProjectDuck
# Build using the build script
cd docker/scripts
./build.sh build
# Or build manually (from project root)
docker build -f docker/Dockerfile -t my-projectduck .
# Run your custom image
docker run -d -p 3000:3000 my-projectduck| Variable | Default | Description |
|---|---|---|
PORT |
3000 |
Port number for the server |
NODE_ENV |
production |
Node.js environment |
HOSTNAME |
0.0.0.0 |
Hostname to bind to |
ENABLE_CLAUDE_CODE |
false |
Enable Claude Code integration features |
CLAUDE_SSE_BUFFER_SIZE_MB |
5 |
SSE stream buffer size in MB |
MAX_FILE_SIZE_MB |
10 |
Maximum file size for content viewing |
| Path | Purpose | Example |
|---|---|---|
/workspace |
Main workspace directory | -v /host/workspace:/workspace |
/app/projects.json |
Project configuration | -v ./my-config.json:/app/projects.json |
The container includes a health check endpoint at /health:
# Check container health
curl http://localhost:3000/health- Connect GitHub repository to Vercel
- Automatically detect Next.js project and deploy
- Configure environment variables as needed
# Configure next.config.ts for static mode
npm run build
npm run exportNote: Static export has limitations with API routes and dynamic features.
For detailed Docker documentation and advanced configurations, see the docker/README.md.
MIT License
- Issues: Submit issue reports on GitHub
- Development Guide: Check the source code and inline documentation
ProjectDuck - Making document browsing elegant and efficient π¦β¨