Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 36 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,95 +66,51 @@ Check our (soon) [Wiki](link-to-wiki) for detailed guides on:
| Obtain crafting table | Collects wood to craft a crafting table and drops it | [Download](https://github.com/SilkePilon/KnowledgeBook/blob/main/flows/crafting_table.json) |
| | | |

## How To Install 📥
## Setup and Running with Docker 🐳

This project uses Docker Compose for a consistent and easy-to-manage development environment.

### Prerequisites

Make sure you have the following installed:

- [Node.js](https://nodejs.org/) 22.0.0 or above
- [npm](https://www.npmjs.com/)

### Installation Steps

1. Clone the repository:
```bash
git clone https://github.com/SilkePilon/KnowledgeBook.git
cd KnowledgeBook
```

2. Install dependencies for all workspaces:
```bash
npm run install:all
```

3. Set up HTTPS for development:
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/) (usually included with Docker Desktop)

### Installation & Running

1. **Clone the repository:**
```bash
git clone https://github.com/SilkePilon/KnowledgeBook.git
cd KnowledgeBook
```

2. **Start the application using Docker Compose:**
```bash
docker-compose up --build
```
This command will:
- Build the Docker images for the frontend and backend services (if they don't exist or if their Dockerfiles have changed).
- Start all services defined in the `docker-compose.yml` file.
- Frontend will be accessible at `http://localhost:3000`.
- Backend will be accessible at `http://localhost:8080`.

To run the application in detached mode (in the background), use:
```bash
docker-compose up --build -d
```

### Stopping the Application

To stop and remove the containers, networks, and volumes created by `docker-compose up`:
```bash
cd backend
npm run setup-https
docker-compose down
```

This will:
- Install dependencies for both frontend and backend
- Generate trusted SSL certificates for local development
- Configure HTTPS for secure communication

> **Note:** When first accessing the backend API in your browser, you may need to accept the self-signed certificate. This is normal for local development and doesn't affect security.

### Running the Application

You can run the frontend and backend separately or together:

#### Run both frontend and backend:
```bash
npm run dev
```

#### Run only the frontend:
```bash
npm run frontend
```

#### Run only the backend:
```bash
npm run backend
```

The frontend will be available at `http://localhost:3000` and the backend at `http://localhost:8080` by default.

### Development

- Frontend code is located in the `frontend/` directory
- Backend code is located in the `backend/` directory
- Each directory has its own `package.json` with specific dependencies and scripts

```bash
curl -sL -o main.zip https://github.com/SilkePilon/KnowledgeBook/archive/refs/heads/main.zip && unzip main.zip && cd KnowledgeBook-main && npm install && npm rebuild && cd .. && rm main.zip && cd KnowledgeBook-main && node main.js
```

## Manual Install

#### 1. Clone the Repository

First, make a local copy of the repository:

```bash
git clone https://github.com/SilkePilon/KnowledgeBook.git
```

Open the cloned repository in your preferred terminal app.

#### 1. Install packages

Assuming you have [Node](https://nodejs.org/en/download/package-manager/current) and [NPM](https://www.npmjs.com/) installed you can run the following commands:

```bash
npm install
npm rebuild
node main.js
```

That's it! You can now open up https://knowledgebook.vercel.app/ and start creating!
- Frontend code is located in the `frontend/` directory.
- Backend code is located in the `backend/` directory.
- Changes to the code in these directories will be reflected live in the running containers due to volume mounts configured in `docker-compose.yml`. You might need to restart services or they might hot-reload depending on their individual configurations.

## Adding Custom Nodes to the Project

Expand Down
23 changes: 23 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use Node.js 22 Alpine as base
FROM node:22-alpine

# Set working directory
WORKDIR /usr/src/app

# Install system dependencies for canvas
RUN apk add --no-cache build-base cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev

# Copy package files
COPY package.json package-lock.json ./

# Install production dependencies
RUN npm install --omit=dev

# Copy application code
COPY . .

# Expose port
EXPOSE 8080

# Default command
CMD ["node", "main.js"]
36 changes: 18 additions & 18 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@
"node": ">=22.0.0"
},
"dependencies": {
"@nxg-org/mineflayer-physics-util": "^1.5.8",
"@nxg-org/mineflayer-physics-util": "^1.8.10",
"@xboxreplay/xboxlive-auth": "^4.1.0",
"axios": "^1.8.4",
"body-parser": "^1.20.2",
"canvas": "^2.11.2",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-rate-limit": "^7.4.0",
"minecraft-data": "^3.66.0",
"mineflayer": "^4.20.1",
"mineflayer-collectblock": "^1.4.1",
"axios": "^1.9.0",
"body-parser": "^2.2.0",
"canvas": "^3.1.0",
"dotenv": "^16.5.0",
"express": "^5.1.0",
"express-rate-limit": "^7.5.0",
"minecraft-data": "^3.89.0",
"mineflayer": "^4.29.0",
"mineflayer-collectblock": "^1.6.0",
"mineflayer-elytrafly": "^1.4.6",
"mineflayer-pathfinder": "^2.4.5",
"mineflayer-tool": "^1.2.0",
"morgan": "^1.10.0",
"node-fetch": "2.7.0",
"openai": "^4.55.3",
"node-fetch": "3.3.2",
"openai": "^4.103.0",
"pem": "^1.14.8",
"prismarine-auth": "^2.7.0",
"prismarine-viewer": "^1.28.0",
"prismarine-viewer": "^1.33.0",
"prompt-sync": "^4.2.0",
"rsa-json": "^0.0.2",
"sharp": "^0.33.4",
"rsa-json": "^0.2.1",
"sharp": "^0.34.2",
"vec3": "^0.1.10",
"ws": "^8.18.0"
"ws": "^8.18.2"
},
"devDependencies": {
"@types/node": "^22.5.4",
"typescript": "^5.6.2"
"@types/node": "^22.15.21",
"typescript": "^5.8.3"
}, "scripts": {
"start": "node main.js",
"dev": "node main.js",
Expand Down
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.8'
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "8080:8080"
volumes:
- ./backend:/usr/src/app
- /usr/src/app/node_modules
command: npm run dev
environment:
- NODE_ENV=development

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ./frontend:/usr/src/app
- /usr/src/app/node_modules
command: npm run dev
environment:
- NODE_ENV=development
- NEXT_PUBLIC_API_URL=http://backend:8080
# If issues arise with HTTPS/TLS, uncomment the line below if needed by the frontend for self-signed certs from backend
# - NODE_TLS_REJECT_UNAUTHORIZED=0
depends_on:
- backend
23 changes: 23 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Stage 1: Build
FROM node:22-alpine AS build

# Set working directory
WORKDIR /usr/src/app

# Copy package files
COPY package.json package-lock.json ./

# Install dependencies
RUN npm install

# Copy application code
COPY . .

# Build the Next.js application
RUN npm run build

# Expose port
EXPOSE 3000

# Default command to start the app
CMD ["npm", "start"]
99 changes: 50 additions & 49 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,61 @@
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.8.0",
"@radix-ui/react-alert-dialog": "^1.1.5",
"@radix-ui/react-checkbox": "^1.1.4",
"@radix-ui/react-collapsible": "^1.1.3",
"@radix-ui/react-dialog": "^1.1.5",
"@radix-ui/react-dropdown-menu": "^2.1.6",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.1.3",
"@radix-ui/react-select": "^2.1.3",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slider": "^1.2.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-toast": "^1.2.1",
"@radix-ui/react-tooltip": "^1.1.2",
"@tanstack/react-table": "^8.20.1",
"@xyflow/react": "^12.0.4",
"axios": "^1.7.3",
"canvas-confetti": "^1.9.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^1.0.0",
"@hookform/resolvers": "^5.0.1",
"@radix-ui/react-alert-dialog": "^1.1.14",
"@radix-ui/react-checkbox": "^1.3.2",
"@radix-ui/react-collapsible": "^1.1.11",
"@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-dropdown-menu": "^2.1.15",
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-popover": "^1.1.14",
"@radix-ui/react-scroll-area": "^1.2.9",
"@radix-ui/react-select": "^2.2.5",
"@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-slider": "^1.3.5",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-switch": "^1.2.5",
"@radix-ui/react-toast": "^1.2.14",
"@radix-ui/react-tooltip": "^1.2.7",
"@tanstack/react-table": "^8.21.3",
"@xyflow/react": "^12.6.4",
"axios": "^1.9.0",
"canvas-confetti": "^1.9.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"cors": "^2.8.5",
"framer-motion": "^11.0.8",
"html-to-image": "^1.11.11",
"input-otp": "^1.1.0",
"ldrs": "^1.0.1",
"lucide-react": "^0.488.0",
"next": "^14.2.6",
"next-themes": "^0.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.0",
"react-icons": "^5.0.1",
"react-markdown": "^9.0.1",
"react-resizable-panels": "^2.0.9",
"react-skinview3d": "^5.0.3",
"react-zoom-pan-pinch": "^3.4.2",
"recharts": "^2.12.1",
"framer-motion": "^12.12.2",
"html-to-image": "^1.11.13",
"input-otp": "^1.4.2",
"ldrs": "^1.1.7",
"lucide-react": "^0.511.0",
"next": "^15.1.8",
"next-themes": "^0.4.6",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-hook-form": "^7.56.4",
"react-icons": "^5.5.0",
"react-markdown": "^10.1.0",
"react-resizable-panels": "^3.0.2",
"react-skinview3d": "^6.0.0",
"react-zoom-pan-pinch": "^3.7.0",
"recharts": "^2.15.3",
"socket.io-client": "^4.8.1",
"vaul": "^1.0.0",
"tailwind-merge": "^3.2.0",
"tailwindcss-animate": "^1.0.7"
"tailwind-merge": "^3.3.0",
"tailwindcss-animate": "^1.0.7",
"vaul": "^1.1.2"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.5",
"@tailwindcss/postcss": "^4.1.7",
"@types/cors": "^2.8.18",
"@types/node": "^22",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.8",
"postcss": "^8",
"tailwindcss": "^3.4.4",
"tailwindcss": "^4.1.7",
"typescript": "^5"
}
}
2 changes: 1 addition & 1 deletion frontend/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
'@tailwindcss/postcss': {},
},
};

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use client";

import * as React from "react";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { type ThemeProviderProps } from "next-themes/dist/types";
import { ThemeProvider as NextThemesProvider, type ThemeProviderProps } from "next-themes";

export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
Expand Down
Loading