Implement Docker-based Wiki/Knowledgebase with PostgreSQL FTS and role-based auth #2

Merged
Copilot merged 7 commits from copilot/create-wiki-knowledgebase-program into main 2025-11-04 09:09:30 -06:00
Copilot commented 2025-11-04 08:23:01 -06:00 (Migrated from github.com)

Built a production-ready wiki application with PostgreSQL full-text search, JWT authentication, and modern React UI supporting Markdown/Rich Text dual editing modes.

Backend (Node.js/Express)

  • Authentication: JWT with bcrypt (10 rounds), role-based access (viewer/editor/admin)
  • Search: PostgreSQL full-text search with to_tsvector + ts_rank relevance scoring
  • Security: Rate limiting (100/15min), Helmet headers, parameterized queries
  • Schema: Users, pages with version history (page_revisions), tags with M:N relations

Frontend (React/Vite)

  • Editor: Toggle between Markdown (react-markdown) and Rich Text modes
  • Theme: CSS variables with dark/light mode, persisted in localStorage
  • Layout: Configurable sidebar position (left/right/top), TOC display (flat/grouped A-Z)
  • Pages: Dashboard with stats, search results, page CRUD with route guards

Docker

  • Multi-stage frontend build (Node → Nginx)
  • Nginx reverse proxy: /api/* → backend, /* → static assets
  • Health checks on PostgreSQL before backend startup
  • Volume persistence for database

Security Fixes

  • Updated axios 1.6.2 → 1.12.0 (5 CVEs: DoS, SSRF)
  • Added null checks on page.title and page.content rendering
  • CodeQL scan: 0 vulnerabilities

API Endpoints

POST   /api/auth/register         Create account
POST   /api/auth/login            Authenticate
GET    /api/pages                 List pages
POST   /api/pages                 Create (editor+)
PUT    /api/pages/:slug           Update (editor+)
DELETE /api/pages/:slug           Delete (admin only)
GET    /api/search?q=query        Full-text search

Quick Start

docker compose up -d
# Frontend: http://localhost:3000
# Backend:  http://localhost:3001

First user registers as viewer. Promote to admin via:

docker exec -it noodlenook-db psql -U noodlenook -d noodlenook \
  -c "UPDATE users SET role = 'admin' WHERE username = 'user';"
Original prompt

Create a Wiki / Knowledgebase Program that runs in docker. it should have a database backend to store the information, The ability to switch between Markdown and modern type to write wiki pages, Powerful search functionality, User authentication with roles.

The design should be modern and bright with the option for a dark mode, have a toggle between a top bar, a right side bar, and a left side bar, different options for the Table of Contents, and a Search Bar at the top. The Homepage should be a modern and clean dashboard view with quick links, a login button on the top right, and a title and logo in the top left corner


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Built a production-ready wiki application with PostgreSQL full-text search, JWT authentication, and modern React UI supporting Markdown/Rich Text dual editing modes. ## Backend (Node.js/Express) - **Authentication**: JWT with bcrypt (10 rounds), role-based access (viewer/editor/admin) - **Search**: PostgreSQL full-text search with `to_tsvector` + `ts_rank` relevance scoring - **Security**: Rate limiting (100/15min), Helmet headers, parameterized queries - **Schema**: Users, pages with version history (`page_revisions`), tags with M:N relations ## Frontend (React/Vite) - **Editor**: Toggle between Markdown (react-markdown) and Rich Text modes - **Theme**: CSS variables with dark/light mode, persisted in localStorage - **Layout**: Configurable sidebar position (left/right/top), TOC display (flat/grouped A-Z) - **Pages**: Dashboard with stats, search results, page CRUD with route guards ## Docker - Multi-stage frontend build (Node → Nginx) - Nginx reverse proxy: `/api/*` → backend, `/*` → static assets - Health checks on PostgreSQL before backend startup - Volume persistence for database ## Security Fixes - Updated axios 1.6.2 → 1.12.0 (5 CVEs: DoS, SSRF) - Added null checks on `page.title` and `page.content` rendering - CodeQL scan: 0 vulnerabilities ## API Endpoints ``` POST /api/auth/register Create account POST /api/auth/login Authenticate GET /api/pages List pages POST /api/pages Create (editor+) PUT /api/pages/:slug Update (editor+) DELETE /api/pages/:slug Delete (admin only) GET /api/search?q=query Full-text search ``` ## Quick Start ```bash docker compose up -d # Frontend: http://localhost:3000 # Backend: http://localhost:3001 ``` First user registers as viewer. Promote to admin via: ```sql docker exec -it noodlenook-db psql -U noodlenook -d noodlenook \ -c "UPDATE users SET role = 'admin' WHERE username = 'user';" ``` <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Create a Wiki / Knowledgebase Program that runs in docker. it should have a database backend to store the information, The ability to switch between Markdown and modern type to write wiki pages, Powerful search functionality, User authentication with roles. > > The design should be modern and bright with the option for a dark mode, have a toggle between a top bar, a right side bar, and a left side bar, different options for the Table of Contents, and a Search Bar at the top. The Homepage should be a modern and clean dashboard view with quick links, a login button on the top right, and a title and logo in the top left corner </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
SluberskiHomeLab (Migrated from github.com) approved these changes 2025-11-04 09:09:20 -06:00
Sign in to join this conversation.
No description provided.