Skip to content

kelithius/projectduck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

37 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ProjectDuck

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.

✨ Key Features

  • 🎯 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

πŸš€ Tech Stack

Core Framework

  • 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

UI & Styling

  • 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

Content Rendering

  • 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

Internationalization & Tools

  • 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

🎯 Supported File Formats

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

πŸ—οΈ Project Structure

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

πŸš€ Quick Start

Prerequisites

  • Node.js 18.0 or higher
  • npm, yarn, pnpm, or bun

Installation & Setup

  1. Install Dependencies
npm install
# or
yarn install
# or
pnpm install
  1. Start Development Server
npm run dev
# or
yarn dev
# or
pnpm dev
  1. Open Browser Navigate to http://localhost:3000 to view the application

Available Commands

# Development mode (with Turbopack support)
npm run dev

# Production build
npm run build

# Start production server
npm start

# Linting
npm run lint

βš™οΈ Configuration

Environment Variables

Copy .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=1000

See .env.example for all available configuration options.

Internationalization Settings

Configure languages in next-i18next.config.js:

module.exports = {
  i18n: {
    defaultLocale: "zh_tw", // Default Traditional Chinese
    locales: ["en", "zh_tw"], // Supported languages
  },
};

Browse Directory

By default, browses files in the /example directory. Can be modified via the BASE_PATH environment variable.

🎨 Feature Highlights

Dual-Panel Design

  • 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

Enhanced Markdown Features

  • βœ… 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)

Performance & Experience

  • 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

πŸ”§ Development Guide

Development Tool Configuration

  • TypeScript: Strict mode, path alias @/*
  • ESLint: Next.js + TypeScript rule set
  • Tailwind CSS: Coexisting configuration with Ant Design

Adding Support for New File Types

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
};

API Routes Development

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 });
}

🚒 Deployment

Docker Deployment (Recommended)

ProjectDuck is containerized and available as kelithius/projectduck Docker image.

Quick Start

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 configurations

Custom Document Directories

Mount 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:latest

Custom Project Configuration

Create 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:latest

Docker Compose

Create 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:true

Then run:

# Start with docker-compose
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

Build Your Own Image

# 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

Environment Variables

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

Volume Mounts

Path Purpose Example
/workspace Main workspace directory -v /host/workspace:/workspace
/app/projects.json Project configuration -v ./my-config.json:/app/projects.json

Health Check

The container includes a health check endpoint at /health:

# Check container health
curl http://localhost:3000/health

Vercel Deployment

  1. Connect GitHub repository to Vercel
  2. Automatically detect Next.js project and deploy
  3. Configure environment variables as needed

Static Export (Limited Features)

# Configure next.config.ts for static mode
npm run build
npm run export

Note: Static export has limitations with API routes and dynamic features.

For detailed Docker documentation and advanced configurations, see the docker/README.md.

πŸ“„ License

MIT License

πŸ“ž Support

  • Issues: Submit issue reports on GitHub
  • Development Guide: Check the source code and inline documentation

ProjectDuck - Making document browsing elegant and efficient πŸ¦†βœ¨

About

File browser and document viewer built with Next.js - elegant dual-panel interface for browsing and viewing documents with enhanced Markdown support

Resources

Contributing

Stars

Watchers

Forks

Contributors