Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Vibe coded, mostly made to test features

btholt/simple-wiki

Repository files navigation

Wiki Application

A simple multi-user wiki application built with Next.js, BetterAuth, Drizzle ORM, and Neon Postgres.

Features

  • Multi-user support: Users can sign up and sign in with email/password
  • Article management: Create, edit, and view articles with markdown support
  • Access control: Users can only edit their own articles
  • Public viewing: Anyone can browse and read articles without logging in

Tech Stack

  • Next.js 15 - React framework with App Router
  • BetterAuth - Authentication library
  • Drizzle ORM - TypeScript ORM for database
  • Neon Postgres - Serverless Postgres database
  • shadcn/ui - UI component library
  • Tailwind CSS - Styling
  • React Markdown - Markdown rendering
  • Playwright - E2E testing

Setup

Prerequisites

  • Node.js 20 or higher
  • A Neon Postgres database account

Installation

  1. Clone or navigate to the project directory:
cd wiki
  1. Install dependencies:
npm install
  1. Set up environment variables:

Create a .env.local file in the root directory with the following:

DATABASE_URL=your-neon-connection-string-here
BETTER_AUTH_SECRET=your-secret-here
BETTER_AUTH_URL=http://localhost:3000

You can generate a secret with:

openssl rand -base64 32
  1. Run database migrations:
npm run db:generate
npm run db:migrate

Or push the schema directly (for development):

npm run db:push

Running the Application

Start the development server:

npm run dev

Open http://localhost:3000 in your browser.

Testing

Run Playwright tests:

npm test

Run tests in UI mode:

npm run test:ui

Project Structure

wiki/
├── app/
│   ├── actions/          # Server actions
│   ├── api/auth/         # Auth API routes
│   ├── article/          # Article pages
│   ├── login/            # Login page
│   ├── signup/           # Signup page
│   ├── page.tsx          # Home page
│   ├── layout.tsx        # Root layout
│   └── globals.css       # Global styles
├── components/
│   ├── ui/               # shadcn UI components
│   ├── article-form.tsx  # Article form component
│   ├── article-list.tsx  # Article list component
│   ├── auth-button.tsx   # Auth button component
│   └── markdown-renderer.tsx
├── db/
│   ├── schema.ts         # Database schema
│   └── index.ts          # Database client
├── lib/
│   ├── auth.ts           # Auth server config
│   ├── auth-client.ts    # Auth client
│   └── utils.ts          # Utility functions
├── tests/
│   └── wiki.spec.ts      # E2E tests
├── drizzle/
│   └── migrations/       # Database migrations
└── package.json

API Endpoints

The application provides REST API endpoints that are consumed by our mobile app and other clients:

Articles

  • GET /api/articles/with-authors - Get all articles with author information and statistics
  • GET /api/articles/latest?limit=10 - Get the latest articles (default: 10)
  • GET /api/articles/[id] - Get a specific article by ID
  • GET /api/articles/search?q=query - Search articles by title or content

Users

  • GET /api/users/[id]/articles - Get all articles by a specific user

Statistics

  • GET /api/stats - Get overall platform statistics (total articles, users, etc.)

Note: These endpoints are used by our iOS and Android mobile applications to provide a native experience for wiki readers and contributors.

Usage

As a Visitor

  • Browse all articles on the home page
  • Click on article titles to read the full content
  • View markdown-formatted articles

As a User

  1. Sign Up: Click "Sign Up" and create an account
  2. Sign In: Use your email and password to sign in
  3. Create Article: Click "Create Article" on the home page
  4. Edit Article: Click "Edit" on articles you've created
  5. Sign Out: Click "Sign Out" to end your session

Code Quality

The project uses:

  • Prettier - Code formatting with minimal configuration
  • Biome - Linting for correctness (not style)

License

MIT

About

Vibe coded, mostly made to test features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published