https://github.com/glory42/twitter_like_api
📱 Social Media API A Twitter-like backend using Express.js & PostgreSQL. Features tweet posting, hashtags, follow/unfollow, and personalized feeds. Optimized SQL queries for performance. ⚡
https://github.com/glory42/twitter_like_api
expressjs jwt postgresql websockets
Last synced: 3 months ago
JSON representation
📱 Social Media API A Twitter-like backend using Express.js & PostgreSQL. Features tweet posting, hashtags, follow/unfollow, and personalized feeds. Optimized SQL queries for performance. ⚡
- Host: GitHub
- URL: https://github.com/glory42/twitter_like_api
- Owner: Glory42
- License: mit
- Created: 2025-03-10T20:12:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-15T15:28:48.000Z (over 1 year ago)
- Last Synced: 2025-03-15T16:28:31.825Z (over 1 year ago)
- Topics: expressjs, jwt, postgresql, websockets
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 📱 Social Media API
## 📌 Description
🚀 *Social Media API* is a backend system for a simplified Twitter-like platform. It allows users to 📝 post tweets with hashtags, 🔄 follow/unfollow users, and 📜 view a personalized feed. Built with **Express.js** and **PostgreSQL**, it utilizes **advanced SQL queries** for hashtag detection and feed generation.
## 🎯 Objective
Build a scalable and efficient backend for a social media platform with essential features like user interactions, feeds, and hashtags.
## 🚀 Key Features
- 📝 **Post tweets** with hashtags.
- 🔄 **Follow/unfollow** users.
- 📜 **Feed** showing tweets from followed users.
- 🔍 **Hashtag detection** using LIKE queries.
- 🗄 **Optimized SQL queries** for better performance.
## 🏗 Steps to Build
1️⃣ **Database Setup**: Create tables for `users`, `tweets`, `hashtags`, and `follows`.
2️⃣ **Followers System**: Add a `followers` join table (`follower_id`, `followed_id`).
3️⃣ **Hashtag Detection**: Implement `LIKE` queries to detect hashtags (e.g., `#express`).
4️⃣ **Feed Generation**: Use complex SQL queries to fetch tweets from followed users.
5️⃣ **Real-Time Updates** (Optional): Implement WebSockets for live tweet updates.
## 🛠 Technologies Used
- **Backend Framework**: Express.js
- **Database**: PostgreSQL
- **Authentication**: JWT
- **WebSockets** (Optional for real-time updates)
## 📂 Project Structure
```sh
social-media-api/
├── config/
│ └── db.js # PostgreSQL connection
├── routes/
│ ├── auth.js # User registration/login
│ ├── tweets.js # Tweet CRUD, hashtag extraction
│ ├── users.js # Follow/unfollow, profile
│ └── feed.js # User feed logic
├── controllers/
│ ├── authController.js
│ ├── tweetController.js
│ ├── userController.js
│ └── feedController.js
├── models/
│ ├── User.js # User schema/queries
│ ├── Tweet.js # Tweet schema/queries
│ ├── Hashtag.js # Hashtag schema/queries
│ └── Follow.js # Follow schema/queries
├── middleware/
│ ├── auth.js # Authentication
│ └── errorHandler.js # Global error handling
└── app.js
```
## 📌 API Endpoints
| ⚡ Method | 🔗 Endpoint | 📝 Description |
|--------|--------------|-------------|
| POST | /auth/register | 🆕 User registration |
| POST | /auth/login | 🔑 User login |
| POST | /tweets | 📝 Create a tweet |
| GET | /tweets/:id | 🔍 View a tweet |
| GET | /feed | 📜 Get user feed |
| POST | /users/:id/follow | 🔄 Follow a user |
| POST | /users/:id/unfollow | ❌ Unfollow a user |
## 📚 Concepts Learned
- 📊 **Advanced SQL queries** for efficient data retrieval.
- 📜 **Feed algorithms** to generate personalized timelines.
- 🔄 **Real-time updates** (with WebSockets, optional).
## 🤝 Contributing
Contributions are welcome! Open an issue or submit a pull request.
## 📜 License
This project is licensed under the MIT **[License](LICENSE)**.