The Social Media Backend Clone is a backend application developed using FastAPI that emulates a social media platform's core functionalities. This project provides a robust backend solution featuring user authentication, CRUD operations for posts, a vote/like system, and integrates with a PostgreSQL database using SQLAlchemy. It is designed to handle user interactions securely and efficiently, serving as a solid foundation for a social media application.
- CRUD Operations: Create, Read, Update, and Delete posts.
- User Authentication: Secure user registration, login, and JWT-based authentication.
- Vote/Like System: Users can vote or like posts.
- Database Integration: PostgreSQL for data storage with SQLAlchemy ORM.
- API Documentation: Automatically generated documentation with FastAPI.
- Environment Configuration: Environment variables for secure management.
- Python 3.8 or higher
- PostgreSQL
- Virtual environment (optional but recommended)
-
Clone the Repository:
git clone https://github.com/yourusername/social-media-backend-clone.git cd social-media-backend-clone
-
Create a Virtual Environment:
python -m venv venv
For Windows:
venv\Scripts\activate
For MacOS/Linux:
source venv/bin/activate
Install Dependencies:
pip install -r requirements.txt
Configure Environment Variables:
DATABASE_URL=postgresql://username:password@localhost/dbname SECRET_KEY=your_secret_key
Run Database Migrations:
alembic upgrade head
Start the Application:
uvicorn app.main:app --reload
POST /users/register
: Register a new user.POST /users/login
: Login and receive a JWT token.GET /users/{user_id}
: Retrieve user details.
POST /posts
: Create a new post.GET /posts
: Retrieve all posts.GET /posts/{post_id}
: Retrieve a specific post.PUT /posts/{post_id}
: Update a specific post.DELETE /posts/{post_id}
: Delete a specific post.
POST /posts/{post_id}/vote
: Vote on a post.GET /posts/{post_id}/votes
: Retrieve votes for a specific post.
Contributions are welcome! Please follow these steps to contribute:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature
-
Commit your changes:
git commit -am 'Add new feature'
-
Push to the branch:
git push origin feature/your-feature
-
Create a new Pull Request