A backend REST API for a social media application built using Node.js, Express, Sequelize, and MySQL.
This API handles user authentication, posts, likes, comments, notifications, and other core social features.
β
User registration and login (with JWT)
β
Create, read, update, delete (CRUD) posts
β
Like and comment on posts
β
Follow and unfollow users
β
Notification system for likes, comments, follows
β
Sequelize ORM with MySQL database
β
Clean modular structure with separate models, controllers, routes
- Node.js
- Express.js
- Sequelize ORM
- MySQL
- JWT (JSON Web Tokens)
- bcrypt (for password hashing)
/src
βββ config/ # Database configuration
βββ controllers/ # Request handlers
βββ middleware/ # Auth, validation middleware
βββ models/ # Sequelize models
βββ routes/ # API route definitions
βββ app.js # Main app entry point
1οΈβ£ Clone the repository
git clone https://github.com/koredeowoblow/social-api.git
cd social-api
2οΈβ£ Install dependencies
npm install
3οΈβ£ Set up your .env
file
Create a .env
file in the root:
PORT=5000
DB_HOST=localhost
DB_USER=your_mysql_user
DB_PASS=your_mysql_password
DB_NAME=social_media
JWT_SECRET=your_jwt_secret
4οΈβ£ Set up the database
- Ensure your MySQL server is running.
- Run Sequelize sync or migrations:
5οΈβ£ Start the server
npm run dev
Visit: http://localhost:5000
## π API Endpoints (Core)
| Method | Endpoint | Description |
| ------ | ------------------------ | ---------------------- |
| POST | /api/auth/register | Register new user |
| POST | /api/auth/login | Login user |
| GET | /api/posts | Get all posts |
| POST | /api/posts | Create a new post |
| POST | /api/posts/\:id/like | Like a post |
| POST | /api/posts/\:id/comment | Comment on a post |
| GET | /api/users/\:id/follow | Follow a user |
| GET | /api/users/\:id/unfollow | Unfollow a user |
| GET | /api/notifications | Get user notifications |
Detailed API docs (with request/response samples) coming soon!
Want to improve this project?
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -m 'Add feature'
) - Push to the branch (
git push origin feature/your-feature
) - Open a pull request
We welcome all contributions!
This project is licensed under the MIT License.
Made with β€οΈ by Shinaayomi Owolabi (koredeowoblow) LinkedIn | GitHub