Skip to content

About

Twitter-like social media where users can share code snippets.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Kode

A minimalist social feed for educational code snippets — follow developers, like, repost, and comment. image

Stack

  • Frontend: React + Vite + TypeScript (SPA, not Next.js)
  • Backend: Express + TypeScript
  • Database: PostgreSQL + Prisma
  • Auth: Google OAuth
  • Deploy: Nixpacks (Dokploy, Hostinger VPS)

Features

  • Scrollable home feed with language filters
  • Personalized "For You" ranking (follows, likes, recency, engagement)
  • Trending feed
  • User profiles, follow/unfollow
  • Post code with title, description, language, difficulty
  • Like, repost, nested comments/replies
  • Working search (users + posts)
  • Rate limiting: 7 posts / 50 comments per 10 minutes
  • Pre-seeded educational posts (12 posts from 5 seed authors)

Quick Start (Development)

Prerequisites

  • Node.js 20+
  • PostgreSQL

Setup

# Clone and install
npm install

# Configure environment
cp .env.example .env
# Edit .env with your DATABASE_URL, JWT_SECRET, Google OAuth credentials

# Database setup
npm run db:setup

# Run dev (API on :3000, Vite on :5173)
npm run dev

Open http://localhost:5173

Google OAuth

  1. Create OAuth credentials in Google Cloud Console
  2. Authorized JavaScript origins: http://localhost:5173, http://localhost:3000
  3. Authorized redirect URI: http://localhost:3000/api/auth/google/callback
  4. Copy .env.example to .env and set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET

Production (VPS / Dokploy)

In Dokploy → your app → Environment, paste (replace placeholders with your real values):

NODE_ENV=production
PORT=3000
DATABASE_URL=postgresql://postgres:YOUR_DB_PASSWORD@kode-database-k2rqtj:5432/postgres
JWT_SECRET=your-long-random-jwt-secret
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your-client-secret
GOOGLE_CALLBACK_URL=https://kode.pm/api/auth/google/callback
CLIENT_URL=https://kode.pm

In Google Cloud Console for production, add:

  • Origins: https://kode.pm
  • Redirect URI: https://kode.pm/api/auth/google/callback

After deploy, check logs for Google OAuth configured. If you see Google OAuth not configured, one or both Google env vars are missing or empty.

Variable Description
---------- -------------
DATABASE_URL PostgreSQL connection string
JWT_SECRET Long random string
GOOGLE_CLIENT_ID Google OAuth client ID
GOOGLE_CLIENT_SECRET Google OAuth secret
GOOGLE_CALLBACK_URL https://yourdomain.com/api/auth/google/callback
CLIENT_URL https://yourdomain.com
PORT 3000 (or your platform default)
NODE_ENV production

Nixpacks will build the client, compile the server, run migrations, seed data, and start the app on a single port. The Express server serves the built React SPA and API.

npm run build
npm run db:migrate -w server
npm run db:seed -w server
npm start

Project Structure

codescroll/
├── client/          # React SPA (Vite)
├── server/          # Express API
│   ├── prisma/      # Schema, migrations, seed
│   └── src/
│       ├── routes/  # Auth, posts, users, social, comments
│       ├── services/# Feed ranking algorithm
│       └── lib/     # Auth, rate limits, Prisma
├── nixpacks.toml    # VPS deployment config
└── package.json     # npm workspaces root

Seed Data

The seed script creates 5 educational authors and 12 code posts covering React, Python, TypeScript, Go, and Rust. Re-running seed is idempotent for posts (skips if seed posts exist).

API Overview

Method Path Description
POST /api/auth/signup Register
POST /api/auth/login Login
GET /api/auth/google Google OAuth
GET /api/posts/feed Home feed (?language=, ?sort=forYou)
GET /api/posts/trending Trending posts
POST /api/posts Create post
POST /api/social/:id/like Toggle like
POST /api/social/:id/repost Toggle repost
GET /api/posts/:id/comments Comment tree
POST /api/posts/:id/comments Add comment/reply
GET /api/users/search?q= Search
POST /api/users/:username/follow Toggle follow

License

MIT

About

Twitter-like social media where users can share code snippets.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages