diff --git a/.gitignore b/.gitignore index 4570efd97..ea32d551a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules +node_modules/ /.pnp .pnp.* .yarn/* @@ -37,7 +37,7 @@ wheels/ /coverage # next.js -/.next/ +.next/ /out/ # production diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ab818ef54..000000000 --- a/Dockerfile +++ /dev/null @@ -1,107 +0,0 @@ -# syntax=docker/dockerfile:1-labs - -# Build argument for custom certificates directory -ARG CUSTOM_CERT_DIR="certs" - -FROM node:20-alpine3.22 AS node_base - -FROM node_base AS node_deps -WORKDIR /app -COPY package.json package-lock.json ./ -RUN npm ci --legacy-peer-deps - -FROM node_base AS node_builder -WORKDIR /app -COPY --from=node_deps /app/node_modules ./node_modules -# Copy only necessary files for Next.js build -COPY package.json package-lock.json next.config.ts tsconfig.json tailwind.config.js postcss.config.mjs ./ -COPY src/ ./src/ -COPY public/ ./public/ -# Increase Node.js memory limit for build and disable telemetry -ENV NODE_OPTIONS="--max-old-space-size=4096" -ENV NEXT_TELEMETRY_DISABLED=1 -RUN NODE_ENV=production npm run build - -FROM python:3.11-slim AS py_deps -WORKDIR /app -RUN python -m venv /opt/venv -ENV PATH="/opt/venv/bin:$PATH" -COPY api/requirements.txt ./api/ -RUN pip install --no-cache -r api/requirements.txt - -# Use Python 3.11 as final image -FROM python:3.11-slim - -# Set working directory -WORKDIR /app - -# Install Node.js and npm -RUN apt-get update && apt-get install -y \ - curl \ - gnupg \ - git \ - ca-certificates \ - && mkdir -p /etc/apt/keyrings \ - && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ - && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ - && apt-get update \ - && apt-get install -y nodejs \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Update certificates if custom ones were provided and copied successfully -RUN if [ -n "${CUSTOM_CERT_DIR}" ]; then \ - mkdir -p /usr/local/share/ca-certificates && \ - if [ -d "${CUSTOM_CERT_DIR}" ]; then \ - cp -r ${CUSTOM_CERT_DIR}/* /usr/local/share/ca-certificates/ 2>/dev/null || true; \ - update-ca-certificates; \ - echo "Custom certificates installed successfully."; \ - else \ - echo "Warning: ${CUSTOM_CERT_DIR} not found. Skipping certificate installation."; \ - fi \ - fi - -ENV PATH="/opt/venv/bin:$PATH" - -# Copy Python dependencies -COPY --from=py_deps /opt/venv /opt/venv -COPY api/ ./api/ - -# Copy Node app -COPY --from=node_builder /app/public ./public -COPY --from=node_builder /app/.next/standalone ./ -COPY --from=node_builder /app/.next/static ./.next/static - -# Expose the port the app runs on -EXPOSE ${PORT:-8001} 3000 - -# Create a script to run both backend and frontend -RUN echo '#!/bin/bash\n\ -# Load environment variables from .env file if it exists\n\ -if [ -f .env ]; then\n\ - export $(grep -v "^#" .env | xargs -r)\n\ -fi\n\ -\n\ -# Check for required environment variables\n\ -if [ -z "$OPENAI_API_KEY" ] || [ -z "$GOOGLE_API_KEY" ]; then\n\ - echo "Warning: OPENAI_API_KEY and/or GOOGLE_API_KEY environment variables are not set."\n\ - echo "These are required for DeepWiki to function properly."\n\ - echo "You can provide them via a mounted .env file or as environment variables when running the container."\n\ -fi\n\ -\n\ -# Start the API server in the background with the configured port\n\ -python -m api.main --port ${PORT:-8001} &\n\ -PORT=3000 HOSTNAME=0.0.0.0 node server.js &\n\ -wait -n\n\ -exit $?' > /app/start.sh && chmod +x /app/start.sh - -# Set environment variables -ENV PORT=8001 -ENV NODE_ENV=production -ENV SERVER_BASE_URL=http://localhost:${PORT:-8001} - -# Create empty .env file (will be overridden if one exists at runtime) -RUN touch .env - -# Command to run the application -CMD ["/app/start.sh"] diff --git a/Ollama-instruction.md b/Ollama-instruction.md index f6e47e3de..5615f9819 100644 --- a/Ollama-instruction.md +++ b/Ollama-instruction.md @@ -59,12 +59,13 @@ cp api/config/embedder.ollama.json.bak api/config/embedder.json Start the backend: ```bash -pip install -r api/requirements.txt -python -m api.main +pip install -r backend/api/requirements.txt +cd backend && python -m api.main ``` Start the frontend: ```bash +cd frontend npm install npm run dev ``` diff --git a/README.md b/README.md index f32767de6..f705a4048 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](./docs/README.md) | [简体中文](./docs/README.zh.md) | [繁體中文](./docs/README.zh-tw.md) | [日本語](./docs/README.ja.md) | [Español](./docs/README.es.md) | [한국어](./docs/README.kr.md) | [Tiếng Việt](./docs/README.vi.md) | [Português Brasileiro](./docs/README.pt-br.md) | [Français](./docs/README.fr.md) | [Русский](./docs/README.ru.md) ## ✨ Features @@ -81,16 +81,17 @@ OLLAMA_HOST=your_ollama_host ```bash # Install Python dependencies -pip install -r api/requirements.txt +pip install -r backend/api/requirements.txt # Start the API server -python -m api.main +cd backend && python -m api.main ``` #### Step 3: Start the Frontend ```bash # Install JavaScript dependencies +cd frontend npm install # or yarn install @@ -162,21 +163,25 @@ graph TD ``` deepwiki/ -├── api/ # Backend API server -│ ├── main.py # API entry point -│ ├── api.py # FastAPI implementation -│ ├── rag.py # Retrieval Augmented Generation -│ ├── data_pipeline.py # Data processing utilities -│ └── requirements.txt # Python dependencies +├── backend/ # Backend API server +│ ├── api/ # API source code +│ │ ├── main.py # API entry point +│ │ ├── api.py # FastAPI implementation +│ │ ├── rag.py # Retrieval Augmented Generation +│ │ ├── data_pipeline.py # Data processing utilities +│ │ └── requirements.txt # Python dependencies +│ └── Dockerfile # Backend Docker configuration │ -├── src/ # Frontend Next.js app +├── frontend/ # Frontend Next.js app │ ├── app/ # Next.js app directory -│ │ └── page.tsx # Main application page -│ └── components/ # React components -│ └── Mermaid.tsx # Mermaid diagram renderer +│ ├── components/ # React components +│ ├── lib/ # Utility libraries +│ ├── public/ # Static assets +│ ├── package.json # JavaScript dependencies +│ └── Dockerfile # Frontend Docker configuration │ -├── public/ # Static assets -├── package.json # JavaScript dependencies +├── docs/ # Documentation +├── docker-compose.yml # Docker Compose configuration └── .env # Environment variables (create this) ``` @@ -452,7 +457,7 @@ The API server provides: - RAG (Retrieval Augmented Generation) - Streaming chat completions -For more details, see the [API README](./api/README.md). +For more details, see the [API README](./backend/api/README.md). ## 🔌 OpenRouter Integration diff --git a/.python-version b/backend/.python-version similarity index 100% rename from .python-version rename to backend/.python-version diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 000000000..07947ffba --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,21 @@ +# backend/Dockerfile +FROM python:3.11-slim +WORKDIR /app + +# Install curl for health checks +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies +COPY backend/api/requirements.txt ./api/ +RUN python -m venv /opt/venv && \ + /opt/venv/bin/pip install --no-cache -r api/requirements.txt + +# Copy source +COPY backend/api/ ./api/ + +ENV PATH="/opt/venv/bin:$PATH" +ENV PORT=8001 + +# Health check endpoint is implemented at /health +EXPOSE 8001 +CMD ["python", "-m", "api.main"] \ No newline at end of file diff --git a/api/README.md b/backend/api/README.md similarity index 100% rename from api/README.md rename to backend/api/README.md diff --git a/api/__init__.py b/backend/api/__init__.py similarity index 100% rename from api/__init__.py rename to backend/api/__init__.py diff --git a/api/api.py b/backend/api/api.py similarity index 100% rename from api/api.py rename to backend/api/api.py diff --git a/api/azureai_client.py b/backend/api/azureai_client.py similarity index 100% rename from api/azureai_client.py rename to backend/api/azureai_client.py diff --git a/api/bedrock_client.py b/backend/api/bedrock_client.py similarity index 100% rename from api/bedrock_client.py rename to backend/api/bedrock_client.py diff --git a/api/config.py b/backend/api/config.py similarity index 100% rename from api/config.py rename to backend/api/config.py diff --git a/api/config/embedder.json b/backend/api/config/embedder.json similarity index 100% rename from api/config/embedder.json rename to backend/api/config/embedder.json diff --git a/api/config/embedder.json.bak b/backend/api/config/embedder.json.bak similarity index 100% rename from api/config/embedder.json.bak rename to backend/api/config/embedder.json.bak diff --git a/api/config/embedder.ollama.json.bak b/backend/api/config/embedder.ollama.json.bak similarity index 100% rename from api/config/embedder.ollama.json.bak rename to backend/api/config/embedder.ollama.json.bak diff --git a/api/config/embedder.openai_compatible.json.bak b/backend/api/config/embedder.openai_compatible.json.bak similarity index 100% rename from api/config/embedder.openai_compatible.json.bak rename to backend/api/config/embedder.openai_compatible.json.bak diff --git a/api/config/generator.json b/backend/api/config/generator.json similarity index 100% rename from api/config/generator.json rename to backend/api/config/generator.json diff --git a/api/config/lang.json b/backend/api/config/lang.json similarity index 100% rename from api/config/lang.json rename to backend/api/config/lang.json diff --git a/api/config/repo.json b/backend/api/config/repo.json similarity index 100% rename from api/config/repo.json rename to backend/api/config/repo.json diff --git a/api/dashscope_client.py b/backend/api/dashscope_client.py similarity index 100% rename from api/dashscope_client.py rename to backend/api/dashscope_client.py diff --git a/api/data_pipeline.py b/backend/api/data_pipeline.py similarity index 100% rename from api/data_pipeline.py rename to backend/api/data_pipeline.py diff --git a/api/logging_config.py b/backend/api/logging_config.py similarity index 100% rename from api/logging_config.py rename to backend/api/logging_config.py diff --git a/api/main.py b/backend/api/main.py similarity index 100% rename from api/main.py rename to backend/api/main.py diff --git a/api/ollama_patch.py b/backend/api/ollama_patch.py similarity index 100% rename from api/ollama_patch.py rename to backend/api/ollama_patch.py diff --git a/api/openai_client.py b/backend/api/openai_client.py similarity index 100% rename from api/openai_client.py rename to backend/api/openai_client.py diff --git a/api/openrouter_client.py b/backend/api/openrouter_client.py similarity index 100% rename from api/openrouter_client.py rename to backend/api/openrouter_client.py diff --git a/api/prompts.py b/backend/api/prompts.py similarity index 100% rename from api/prompts.py rename to backend/api/prompts.py diff --git a/api/rag.py b/backend/api/rag.py similarity index 100% rename from api/rag.py rename to backend/api/rag.py diff --git a/api/requirements.txt b/backend/api/requirements.txt similarity index 100% rename from api/requirements.txt rename to backend/api/requirements.txt diff --git a/api/simple_chat.py b/backend/api/simple_chat.py similarity index 100% rename from api/simple_chat.py rename to backend/api/simple_chat.py diff --git a/api/test_api.py b/backend/api/test_api.py similarity index 100% rename from api/test_api.py rename to backend/api/test_api.py diff --git a/api/tools/embedder.py b/backend/api/tools/embedder.py similarity index 100% rename from api/tools/embedder.py rename to backend/api/tools/embedder.py diff --git a/api/websocket_wiki.py b/backend/api/websocket_wiki.py similarity index 100% rename from api/websocket_wiki.py rename to backend/api/websocket_wiki.py diff --git a/pyproject.toml b/backend/pyproject.toml similarity index 100% rename from pyproject.toml rename to backend/pyproject.toml diff --git a/pytest.ini b/backend/pytest.ini similarity index 100% rename from pytest.ini rename to backend/pytest.ini diff --git a/run.sh b/backend/run.sh similarity index 100% rename from run.sh rename to backend/run.sh diff --git a/test/__init__.py b/backend/test/__init__.py similarity index 100% rename from test/__init__.py rename to backend/test/__init__.py diff --git a/test/test_extract_repo_name.py b/backend/test/test_extract_repo_name.py similarity index 100% rename from test/test_extract_repo_name.py rename to backend/test/test_extract_repo_name.py diff --git a/uv.lock b/backend/uv.lock similarity index 100% rename from uv.lock rename to backend/uv.lock diff --git a/docker-compose.yml b/docker-compose.yml index 089538084..f024775ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,31 +1,38 @@ -version: '3.8' - services: - deepwiki: + backend: build: context: . - dockerfile: Dockerfile + dockerfile: backend/Dockerfile + container_name: deepwiki-backend ports: - - "${PORT:-8001}:${PORT:-8001}" # API port - - "3000:3000" # Next.js port + - "8001:8001" env_file: - .env - environment: - - PORT=${PORT:-8001} - - NODE_ENV=production - - SERVER_BASE_URL=http://localhost:${PORT:-8001} - - LOG_LEVEL=${LOG_LEVEL:-INFO} - - LOG_FILE_PATH=${LOG_FILE_PATH:-api/logs/application.log} volumes: - ~/.adalflow:/root/.adalflow # Persist repository and embedding data - - ./api/logs:/app/api/logs # Persist log files across container restarts - # Resource limits for docker-compose up (not Swarm mode) - mem_limit: 6g - mem_reservation: 2g - # Health check configuration + - ./backend/api/logs:/app/api/logs # Persist log files across container restarts healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:${PORT:-8001}/health"] - interval: 60s - timeout: 10s + test: ["CMD-SHELL", "curl -f http://localhost:8001/health || exit 1"] + interval: 30s + timeout: 5s retries: 3 - start_period: 30s + + frontend: + build: + context: . + dockerfile: frontend/Dockerfile + args: + - SERVER_BASE_URL=http://backend:8001 + container_name: deepwiki-frontend + ports: + - "3000:3000" + environment: + - NODE_ENV=production + - SERVER_BASE_URL=http://backend:8001 + depends_on: + backend: + condition: service_healthy + +networks: + default: + driver: bridge diff --git a/README.es.md b/docs/README.es.md similarity index 97% rename from README.es.md rename to docs/README.es.md index 8dde37490..99461fb43 100644 --- a/README.es.md +++ b/docs/README.es.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ Características diff --git a/README.fr.md b/docs/README.fr.md similarity index 98% rename from README.fr.md rename to docs/README.fr.md index f75bd862e..347a40566 100644 --- a/README.fr.md +++ b/docs/README.fr.md @@ -15,7 +15,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ Fonctionnalités diff --git a/README.ja.md b/docs/README.ja.md similarity index 98% rename from README.ja.md rename to docs/README.ja.md index 1819c0f60..f9e4892cb 100644 --- a/README.ja.md +++ b/docs/README.ja.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ 特徴 diff --git a/README.kr.md b/docs/README.kr.md similarity index 98% rename from README.kr.md rename to docs/README.kr.md index d22edef7c..49f7b0899 100644 --- a/README.kr.md +++ b/docs/README.kr.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ 주요 기능 diff --git a/README.pt-br.md b/docs/README.pt-br.md similarity index 98% rename from README.pt-br.md rename to docs/README.pt-br.md index f2f13b58b..ee2113e18 100644 --- a/README.pt-br.md +++ b/docs/README.pt-br.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ Recursos diff --git a/README.ru.md b/docs/README.ru.md similarity index 98% rename from README.ru.md rename to docs/README.ru.md index f74a9d0a0..f7b1dc1d2 100644 --- a/README.ru.md +++ b/docs/README.ru.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ Возможности diff --git a/README.vi.md b/docs/README.vi.md similarity index 97% rename from README.vi.md rename to docs/README.vi.md index f5262135b..7a9ad744f 100644 --- a/README.vi.md +++ b/docs/README.vi.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ Tính năng @@ -243,7 +243,7 @@ API server cung cấp: - RAG (Retrieval Augmented Generation) - Trò chuyện liên tục -Biết thêm chi tiết truy cập [ API README](./api/README.md). +Biết thêm chi tiết truy cập [ API README](../api/README.md). ## 🤖 Hệ thống lựa chọn mô hình dựa trên nhà cung cấp diff --git a/README.zh-tw.md b/docs/README.zh-tw.md similarity index 98% rename from README.zh-tw.md rename to docs/README.zh-tw.md index 08e415087..db8404f96 100644 --- a/README.zh-tw.md +++ b/docs/README.zh-tw.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ 特點 diff --git a/README.zh.md b/docs/README.zh.md similarity index 97% rename from README.zh.md rename to docs/README.zh.md index e05ce05cf..ac977898f 100644 --- a/README.zh.md +++ b/docs/README.zh.md @@ -14,7 +14,7 @@ [![Twitter/X](https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white)](https://x.com/sashimikun_void) [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.com/invite/VQMBGR8u5v) -[English](./README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) +[English](../README.md) | [简体中文](./README.zh.md) | [繁體中文](./README.zh-tw.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [한국어](./README.kr.md) | [Tiếng Việt](./README.vi.md) | [Português Brasileiro](./README.pt-br.md) | [Français](./README.fr.md) | [Русский](./README.ru.md) ## ✨ 特点 diff --git a/screenshots/DeepResearch.png b/docs/screenshots/DeepResearch.png similarity index 100% rename from screenshots/DeepResearch.png rename to docs/screenshots/DeepResearch.png diff --git a/screenshots/Deepwiki.png b/docs/screenshots/Deepwiki.png similarity index 100% rename from screenshots/Deepwiki.png rename to docs/screenshots/Deepwiki.png diff --git a/screenshots/Interface.png b/docs/screenshots/Interface.png similarity index 100% rename from screenshots/Interface.png rename to docs/screenshots/Interface.png diff --git a/screenshots/Ollama.png b/docs/screenshots/Ollama.png similarity index 100% rename from screenshots/Ollama.png rename to docs/screenshots/Ollama.png diff --git a/screenshots/privaterepo.png b/docs/screenshots/privaterepo.png similarity index 100% rename from screenshots/privaterepo.png rename to docs/screenshots/privaterepo.png diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..09580ca5c --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,25 @@ +# frontend/Dockerfile +# Build stage +FROM node:20-alpine3.22 AS builder +WORKDIR /app + +# Accept build argument +ARG SERVER_BASE_URL=http://backend:8001 +ENV SERVER_BASE_URL=${SERVER_BASE_URL} + +COPY frontend/package.json frontend/package-lock.json ./ +RUN npm ci --legacy-peer-deps +COPY frontend/ ./ +RUN npm run build + +# Runtime stage +FROM node:20-alpine3.22 +WORKDIR /app +ENV NODE_ENV=production + +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/eslint.config.mjs b/frontend/eslint.config.mjs similarity index 100% rename from eslint.config.mjs rename to frontend/eslint.config.mjs diff --git a/next.config.ts b/frontend/next.config.ts similarity index 94% rename from next.config.ts rename to frontend/next.config.ts index 539857b6a..eba862630 100644 --- a/next.config.ts +++ b/frontend/next.config.ts @@ -63,6 +63,10 @@ const nextConfig: NextConfig = { source: '/api/lang/config', destination: `${TARGET_SERVER_BASE_URL}/lang/config`, }, + { + source: '/ws/chat', + destination: `${TARGET_SERVER_BASE_URL}/ws/chat`, + }, ]; }, }; diff --git a/package-lock.json b/frontend/package-lock.json similarity index 100% rename from package-lock.json rename to frontend/package-lock.json diff --git a/package.json b/frontend/package.json similarity index 100% rename from package.json rename to frontend/package.json diff --git a/postcss.config.mjs b/frontend/postcss.config.mjs similarity index 100% rename from postcss.config.mjs rename to frontend/postcss.config.mjs diff --git a/public/file.svg b/frontend/public/file.svg similarity index 100% rename from public/file.svg rename to frontend/public/file.svg diff --git a/public/globe.svg b/frontend/public/globe.svg similarity index 100% rename from public/globe.svg rename to frontend/public/globe.svg diff --git a/public/next.svg b/frontend/public/next.svg similarity index 100% rename from public/next.svg rename to frontend/public/next.svg diff --git a/public/vercel.svg b/frontend/public/vercel.svg similarity index 100% rename from public/vercel.svg rename to frontend/public/vercel.svg diff --git a/public/window.svg b/frontend/public/window.svg similarity index 100% rename from public/window.svg rename to frontend/public/window.svg diff --git a/src/app/[owner]/[repo]/page.tsx b/frontend/src/app/[owner]/[repo]/page.tsx similarity index 100% rename from src/app/[owner]/[repo]/page.tsx rename to frontend/src/app/[owner]/[repo]/page.tsx diff --git a/src/app/[owner]/[repo]/slides/page.tsx b/frontend/src/app/[owner]/[repo]/slides/page.tsx similarity index 100% rename from src/app/[owner]/[repo]/slides/page.tsx rename to frontend/src/app/[owner]/[repo]/slides/page.tsx diff --git a/src/app/[owner]/[repo]/workshop/page.tsx b/frontend/src/app/[owner]/[repo]/workshop/page.tsx similarity index 100% rename from src/app/[owner]/[repo]/workshop/page.tsx rename to frontend/src/app/[owner]/[repo]/workshop/page.tsx diff --git a/src/app/api/auth/status/route.ts b/frontend/src/app/api/auth/status/route.ts similarity index 100% rename from src/app/api/auth/status/route.ts rename to frontend/src/app/api/auth/status/route.ts diff --git a/src/app/api/auth/validate/route.ts b/frontend/src/app/api/auth/validate/route.ts similarity index 100% rename from src/app/api/auth/validate/route.ts rename to frontend/src/app/api/auth/validate/route.ts diff --git a/src/app/api/chat/stream/route.ts b/frontend/src/app/api/chat/stream/route.ts similarity index 100% rename from src/app/api/chat/stream/route.ts rename to frontend/src/app/api/chat/stream/route.ts diff --git a/src/app/api/models/config/route.ts b/frontend/src/app/api/models/config/route.ts similarity index 100% rename from src/app/api/models/config/route.ts rename to frontend/src/app/api/models/config/route.ts diff --git a/src/app/api/wiki/projects/route.ts b/frontend/src/app/api/wiki/projects/route.ts similarity index 98% rename from src/app/api/wiki/projects/route.ts rename to frontend/src/app/api/wiki/projects/route.ts index f87ed35d9..0a697124f 100644 --- a/src/app/api/wiki/projects/route.ts +++ b/frontend/src/app/api/wiki/projects/route.ts @@ -31,7 +31,7 @@ function isDeleteProjectCachePayload(obj: unknown): obj is DeleteProjectCachePay } // Ensure this matches your Python backend configuration -const PYTHON_BACKEND_URL = process.env.PYTHON_BACKEND_HOST || 'http://localhost:8001'; +const PYTHON_BACKEND_URL = process.env.SERVER_BASE_URL || 'http://localhost:8001'; const PROJECTS_API_ENDPOINT = `${PYTHON_BACKEND_URL}/api/processed_projects`; const CACHE_API_ENDPOINT = `${PYTHON_BACKEND_URL}/api/wiki_cache`; diff --git a/src/app/favicon.ico b/frontend/src/app/favicon.ico similarity index 100% rename from src/app/favicon.ico rename to frontend/src/app/favicon.ico diff --git a/src/app/globals.css b/frontend/src/app/globals.css similarity index 100% rename from src/app/globals.css rename to frontend/src/app/globals.css diff --git a/src/app/layout.tsx b/frontend/src/app/layout.tsx similarity index 100% rename from src/app/layout.tsx rename to frontend/src/app/layout.tsx diff --git a/src/app/page.tsx b/frontend/src/app/page.tsx similarity index 100% rename from src/app/page.tsx rename to frontend/src/app/page.tsx diff --git a/src/app/wiki/projects/page.tsx b/frontend/src/app/wiki/projects/page.tsx similarity index 100% rename from src/app/wiki/projects/page.tsx rename to frontend/src/app/wiki/projects/page.tsx diff --git a/src/components/Ask.tsx b/frontend/src/components/Ask.tsx similarity index 100% rename from src/components/Ask.tsx rename to frontend/src/components/Ask.tsx diff --git a/src/components/ConfigurationModal.tsx b/frontend/src/components/ConfigurationModal.tsx similarity index 100% rename from src/components/ConfigurationModal.tsx rename to frontend/src/components/ConfigurationModal.tsx diff --git a/src/components/Markdown.tsx b/frontend/src/components/Markdown.tsx similarity index 100% rename from src/components/Markdown.tsx rename to frontend/src/components/Markdown.tsx diff --git a/src/components/Mermaid.tsx b/frontend/src/components/Mermaid.tsx similarity index 100% rename from src/components/Mermaid.tsx rename to frontend/src/components/Mermaid.tsx diff --git a/src/components/ModelSelectionModal.tsx b/frontend/src/components/ModelSelectionModal.tsx similarity index 100% rename from src/components/ModelSelectionModal.tsx rename to frontend/src/components/ModelSelectionModal.tsx diff --git a/src/components/ProcessedProjects.tsx b/frontend/src/components/ProcessedProjects.tsx similarity index 100% rename from src/components/ProcessedProjects.tsx rename to frontend/src/components/ProcessedProjects.tsx diff --git a/src/components/TokenInput.tsx b/frontend/src/components/TokenInput.tsx similarity index 100% rename from src/components/TokenInput.tsx rename to frontend/src/components/TokenInput.tsx diff --git a/src/components/UserSelector.tsx b/frontend/src/components/UserSelector.tsx similarity index 100% rename from src/components/UserSelector.tsx rename to frontend/src/components/UserSelector.tsx diff --git a/src/components/WikiTreeView.tsx b/frontend/src/components/WikiTreeView.tsx similarity index 100% rename from src/components/WikiTreeView.tsx rename to frontend/src/components/WikiTreeView.tsx diff --git a/src/components/WikiTypeSelector.tsx b/frontend/src/components/WikiTypeSelector.tsx similarity index 100% rename from src/components/WikiTypeSelector.tsx rename to frontend/src/components/WikiTypeSelector.tsx diff --git a/src/components/theme-toggle.tsx b/frontend/src/components/theme-toggle.tsx similarity index 100% rename from src/components/theme-toggle.tsx rename to frontend/src/components/theme-toggle.tsx diff --git a/src/contexts/LanguageContext.tsx b/frontend/src/contexts/LanguageContext.tsx similarity index 100% rename from src/contexts/LanguageContext.tsx rename to frontend/src/contexts/LanguageContext.tsx diff --git a/src/hooks/useProcessedProjects.ts b/frontend/src/hooks/useProcessedProjects.ts similarity index 100% rename from src/hooks/useProcessedProjects.ts rename to frontend/src/hooks/useProcessedProjects.ts diff --git a/src/i18n.ts b/frontend/src/i18n.ts similarity index 100% rename from src/i18n.ts rename to frontend/src/i18n.ts diff --git a/src/messages/en.json b/frontend/src/messages/en.json similarity index 100% rename from src/messages/en.json rename to frontend/src/messages/en.json diff --git a/src/messages/es.json b/frontend/src/messages/es.json similarity index 100% rename from src/messages/es.json rename to frontend/src/messages/es.json diff --git a/src/messages/fr.json b/frontend/src/messages/fr.json similarity index 100% rename from src/messages/fr.json rename to frontend/src/messages/fr.json diff --git a/src/messages/ja.json b/frontend/src/messages/ja.json similarity index 100% rename from src/messages/ja.json rename to frontend/src/messages/ja.json diff --git a/src/messages/kr.json b/frontend/src/messages/kr.json similarity index 100% rename from src/messages/kr.json rename to frontend/src/messages/kr.json diff --git a/src/messages/pt-br.json b/frontend/src/messages/pt-br.json similarity index 100% rename from src/messages/pt-br.json rename to frontend/src/messages/pt-br.json diff --git a/src/messages/ru.json b/frontend/src/messages/ru.json similarity index 100% rename from src/messages/ru.json rename to frontend/src/messages/ru.json diff --git a/src/messages/vi.json b/frontend/src/messages/vi.json similarity index 100% rename from src/messages/vi.json rename to frontend/src/messages/vi.json diff --git a/src/messages/zh-tw.json b/frontend/src/messages/zh-tw.json similarity index 100% rename from src/messages/zh-tw.json rename to frontend/src/messages/zh-tw.json diff --git a/src/messages/zh.json b/frontend/src/messages/zh.json similarity index 100% rename from src/messages/zh.json rename to frontend/src/messages/zh.json diff --git a/src/types/repoinfo.tsx b/frontend/src/types/repoinfo.tsx similarity index 100% rename from src/types/repoinfo.tsx rename to frontend/src/types/repoinfo.tsx diff --git a/src/types/wiki/wikipage.tsx b/frontend/src/types/wiki/wikipage.tsx similarity index 100% rename from src/types/wiki/wikipage.tsx rename to frontend/src/types/wiki/wikipage.tsx diff --git a/src/types/wiki/wikistructure.tsx b/frontend/src/types/wiki/wikistructure.tsx similarity index 100% rename from src/types/wiki/wikistructure.tsx rename to frontend/src/types/wiki/wikistructure.tsx diff --git a/src/utils/getRepoUrl.tsx b/frontend/src/utils/getRepoUrl.tsx similarity index 100% rename from src/utils/getRepoUrl.tsx rename to frontend/src/utils/getRepoUrl.tsx diff --git a/src/utils/urlDecoder.tsx b/frontend/src/utils/urlDecoder.tsx similarity index 100% rename from src/utils/urlDecoder.tsx rename to frontend/src/utils/urlDecoder.tsx diff --git a/src/utils/websocketClient.ts b/frontend/src/utils/websocketClient.ts similarity index 83% rename from src/utils/websocketClient.ts rename to frontend/src/utils/websocketClient.ts index b29c1b104..11832649f 100644 --- a/src/utils/websocketClient.ts +++ b/frontend/src/utils/websocketClient.ts @@ -3,15 +3,11 @@ * This replaces the HTTP streaming endpoint with a WebSocket connection */ -// Get the server base URL from environment or use default -const SERVER_BASE_URL = process.env.SERVER_BASE_URL || 'http://localhost:8001'; - -// Convert HTTP URL to WebSocket URL +// Use relative path for WebSocket connection to avoid CORS issues const getWebSocketUrl = () => { - const baseUrl = SERVER_BASE_URL; - // Replace http:// with ws:// or https:// with wss:// - const wsBaseUrl = baseUrl.replace(/^http/, 'ws'); - return `${wsBaseUrl}/ws/chat`; + // Use relative path that will be handled by Next.js rewrite rules + const wsUrl = '/ws/chat'; + return wsUrl; }; export interface ChatMessage { diff --git a/tailwind.config.js b/frontend/tailwind.config.js similarity index 100% rename from tailwind.config.js rename to frontend/tailwind.config.js diff --git a/tsconfig.json b/frontend/tsconfig.json similarity index 100% rename from tsconfig.json rename to frontend/tsconfig.json diff --git a/yarn.lock b/frontend/yarn.lock similarity index 100% rename from yarn.lock rename to frontend/yarn.lock