A fullstack social media application built with React, Node.js, and SQLite (PostgreSQL-ready).
- ✅ User registration and authentication (JWT)
- ✅ Shared timeline for all users (sorted by date, newest first)
- ✅ Create, edit, and delete posts
- ✅ Comment on posts (collapsible comment sections)
- ✅ Search posts by text or username
- ✅ Profile management (update display name)
- ✅ Admin role with elevated permissions
- ✅ Avatar initials display
- ✅ Soft delete (admins can see deleted content)
- ✅ Edited indicators (shows "edited" and "edited by admin")
- ✅ Loading states during API calls
- ✅ Delete confirmation dialogs
- ✅ Navbar with user info and navigation
- ✅ Home page for unauthenticated users
- Frontend: React, Tailwind CSS, React Router, Axios
- Backend: Node.js, Express, JWT, bcryptjs
- Database: PostgreSQL (pg)
- Runtime: Bun
- Bun (latest version)
- Navigate to the backend directory:
cd backend- Install dependencies:
bun install- Create a
.envfile in the backend directory with your database credentials:
PORT=3001
JWT_SECRET=your-secret-key-change-in-production
DATABASE_URL=postgresql://postgres:fV0LFPR7mKTroJ9m@db.rxwcfhspknhkiykojsme.supabase.co:5432/postgres- Start the backend server:
bun run start
# or for development with auto-reload:
bun run devThe backend will run on http://localhost:3001
- Navigate to the frontend directory:
cd frontend- Install dependencies:
bun install- Start the development server:
bun run devThe frontend will run on http://localhost:3000
- Start both backend and frontend servers
- Open
http://localhost:3000in your browser - Register a new account (you can choose "user" or "admin" role)
- Start posting and interacting with the timeline!
POST /api/auth/register- Register new userPOST /api/auth/login- LoginGET /api/auth/me- Get current user
GET /api/posts- Get all posts (timeline)GET /api/posts/search?q=query- Search postsPOST /api/posts- Create postPUT /api/posts/:id- Update postDELETE /api/posts/:id- Delete post
GET /api/comments/post/:postId- Get comments for a postPOST /api/comments- Create commentPUT /api/comments/:id- Update commentDELETE /api/comments/:id- Delete comment
PUT /api/users/profile- Update profile
The application uses PostgreSQL with the following tables:
users- User accountsposts- User postscomments- Comments on posts
All tables support soft deletes (deleted flag) and track edit history.
- All API endpoints (except auth) require JWT authentication
- Passwords are hashed using bcrypt
- Permission checks enforced on backend
- Admin-only features protected by middleware
- The database is initialized automatically on first server start
- The application uses PostgreSQL with connection pooling for better performance
- Tables are created automatically if they don't exist
- The code automatically converts MySQL-style queries to PostgreSQL syntax for compatibility