A mini social media app built for CodeAlpha's Full Stack Development Internship — Task 2.
Features:
- User registration & login (JWT auth, hashed passwords), with an editable bio
- Post short text updates (500 char limit)
- Like / unlike posts
- Comment threads on posts
- Follow / unfollow other users
- Feed with "Everyone" and "Following" tabs
- Profile pages showing bio, follower/following counts, and that user's posts
- People directory to search for and follow other users
| Layer | Technology |
|---|---|
| Frontend | HTML, CSS, vanilla JavaScript |
| Backend | Node.js, Express.js |
| Auth | JWT (jsonwebtoken) + bcryptjs password hashing |
| Database | JSON file store (backend/data/db.json) |
Same lightweight, zero-external-services approach as the other CodeAlpha tasks in this series — no MongoDB/Postgres to install.
CodeAlpha_SocialMediaPlatform/
├── backend/
│ ├── data/db.json
│ ├── middleware/auth.js
│ ├── routes/
│ │ ├── auth.js # register, login, bio update
│ │ ├── users.js # profiles, search, follow/unfollow
│ │ ├── posts.js # feed, create/delete, like/unlike
│ │ └── comments.js # post comment threads
│ ├── db.js
│ ├── seed.js
│ ├── server.js
│ └── package.json
└── frontend/
├── index.html # feed + compose
├── profile.html # user profile + posts
├── people.html # search & follow users
├── login.html / register.html
├── css/styles.css
└── js/ # api.js, auth.js, feed.js, profile.js, people.js
cd backend
npm install
cp .env.example .env # then edit JWT_SECRET to any long random string
npm startAPI runs at http://localhost:5002. Health check: GET /api/health.
Static, no build step:
cd frontend
npx serve .Visit the printed local URL. The frontend calls the API at
http://localhost:5002/api (set in frontend/js/api.js — update API_BASE
if you deploy the backend elsewhere).
Register two or more accounts, follow each other from the People page, post something, and switch to the Following tab on the feed to see posts filtered to just the people you follow. Try liking a post and leaving a comment too.
| Method | Route | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register |
— | Create an account |
| POST | /api/auth/login |
— | Log in, returns a JWT |
| PATCH | /api/auth/profile |
✅ | Update your bio |
| GET | /api/users?search= |
✅ | Search/list users |
| GET | /api/users/:id |
✅ | View a profile (with follower counts) |
| POST | /api/users/:id/follow |
✅ | Follow a user |
| DELETE | /api/users/:id/follow |
✅ | Unfollow a user |
| GET | /api/posts?filter=following |
✅ | Feed (all posts, or just those you follow) |
| GET | /api/posts/user/:userId |
✅ | A specific user's posts |
| POST | /api/posts |
✅ | Create a post { content } |
| DELETE | /api/posts/:id |
✅ | Delete your own post |
| POST | /api/posts/:id/like |
✅ | Like a post |
| DELETE | /api/posts/:id/like |
✅ | Unlike a post |
| GET | /api/comments?postId= |
✅ | List comments on a post |
| POST | /api/comments |
✅ | Add a comment { postId, text } |
Authenticated routes expect Authorization: Bearer <token>.
cd backend
npm run seed- Push this folder to a GitHub repo named
CodeAlpha_SocialMediaPlatform. .envis gitignored — don't commit real secrets.