Skip to content

narinsak-u/mypost-but-github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

271 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

mypost-but-github

mypost-but-github

A mini social webboard inspired by GitHub + Pantip. Share ideas, ask questions, and engage with the community through posts, comments, and real-time messaging.

Live demo: https://mypost-but-github.vercel.app

Features

Posts & Content

  • Rich text editor powered by BlockNote for creating formatted posts
  • Optional tags to categorize content
  • Feed tabs β€” "For You" (all posts) and "Following" (posts from followed users)
  • Like & Star posts to bookmark and show appreciation
  • Comments on posts with inline reply support
  • Full post view at /post/[postId]

Social

  • Follow / unfollow users to curate your feed
  • User profiles with overview and starred posts tabs
  • Who to Follow suggestions on the home page
  • Real-time direct messaging with conversation list and message threads

Search

  • Search users and posts with debounced real-time results
  • MongoDB Atlas Search for autocomplete with highlighted matches (falls back to Prisma contains query when Atlas is not available)

Authentication & UX

  • Email/password + OAuth (Google, GitHub) via Better Auth
  • Dark theme optimized for readability
  • Responsive design β€” works on mobile and desktop
  • Keyboard navigation and accessible UI components

Tech Stack

Category Technologies
Framework Next.js 16 (App Router), React 19
Styling Tailwind CSS 4, shadcn/ui, Radix UI
Auth Better Auth
Database MongoDB + Prisma 6
State TanStack Query (server), Zustand (client)
Forms React Hook Form + Zod
Editor BlockNote
Testing Vitest + React Testing Library

Getting Started

1. Install dependencies

npm install

2. Set up environment variables

Copy .env.example to .env and fill in your values:

DATABASE_URL="mongodb+srv://..."
BETTER_AUTH_SECRET="..."
BETTER_AUTH_URL="http://localhost:3000"
GOOGLE_CLIENT_ID="..."
GOOGLE_CLIENT_SECRET="..."
GITHUB_CLIENT_ID="..."
GITHUB_CLIENT_SECRET="..."

3. Sync database

npx prisma db push

4. Run locally

npm run dev

Open http://localhost:3000

Available Scripts

Command Description
npm run dev Start dev server
npm run build Production build
npm run start Start production server
npm run lint Run Next.js ESLint
npm run test Run Vitest tests
npx prisma studio Open database GUI

Project Structure

β”œβ”€β”€ actions/           # Server Actions
β”œβ”€β”€ app/               # Next.js App Router pages
β”‚   β”œβ”€β”€ (home)/        # Home feed
β”‚   β”œβ”€β”€ (userProfile)/ # User profiles
β”‚   β”œβ”€β”€ post/          # Individual post view
β”‚   └── api/           # API routes (posts, auth, user)
β”œβ”€β”€ components/        # React components
β”‚   β”œβ”€β”€ ui/            # shadcn/ui primitives
β”‚   β”œβ”€β”€ posts/         # Post rendering
β”‚   β”œβ”€β”€ comments/      # Comment system
β”‚   β”œβ”€β”€ chat/          # Direct messaging
β”‚   └── nav/           # Navigation & search
β”œβ”€β”€ hooks/             # Custom React hooks
β”œβ”€β”€ lib/               # Utilities (Prisma, auth, utils)
β”œβ”€β”€ providers/         # React context providers
β”œβ”€β”€ store/             # Zustand stores
β”œβ”€β”€ types/             # TypeScript types + Zod validators
└── prisma/            # Database schema

MongoDB Atlas Search (Optional)

Post search uses MongoDB Atlas $search autocomplete when available (index name: default on the Post collection). If not configured, the app falls back to Prisma contains search.

Create Search Index

  1. Go to MongoDB Atlas β†’ your cluster β†’ Search
  2. Click Create Search Index
  3. Select database and collection (Post)
  4. Use JSON editor:
{
  "mappings": {
    "dynamic": false,
    "fields": {
      "title": { "type": "autocomplete" },
      "body": { "type": "string" }
    }
  }
}

Highlight Search Results

$search: {
  text: {
    query: "next",
    path: ["title", "body"]
  },
  highlight: {
    path: ["title", "body"]
  }
}

Note: Prisma doesn't natively support $search, but you can run raw MongoDB commands via prisma.$runCommandRaw(). See Atlas Search docs for more.

Screenshots

Home

About

πŸ‘» A mini webboard inspired by GitHub + Pantip.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors