Skip to content

πŸ“± 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. ⚑

License

Notifications You must be signed in to change notification settings

Glory42/Twitter_like_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± 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

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.

About

πŸ“± 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. ⚑

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published