SocialPulse is a robust social media backend built with FastAPI, utilizing Docker and PostgreSQL for seamless deployment and database management. It provides essential features for user authentication, JWT-based security, and efficient post management. The project also includes automated testing with pytest, ensuring code reliability and quality. SocialPulse is a solid foundation for building social media applications, with easy setup and comprehensive features.
- User Authentication: Secure user login with password hashing.
- JWT Authentication: Provides JWT token generation with expiration for secure API access.
- Post Management: Create, fetch single posts, update posts, delete posts, like posts, and fetch all posts.
- Docker Support: Easily set up and run the project using Docker Compose.
- Environment Configuration: Example environment files (
.env.example
and.env.postgres.example
) to help you get started quickly.
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/resist15/SocialPulse.git cd SocialPulse
-
Copy the example environment variable files and configure them as needed:
cp .env.example .env cp .env.postgres.example .env.postgres
-
Build and run the containers using Docker Compose:
docker-compose up --build
This will start the FastAPI application along with any required services like the database.
-
The application will be running at
http://127.0.0.1:8000
.
-
Interactive API Documentation:
- Open your browser and navigate to
http://127.0.0.1:8000/docs
for the Swagger UI. - Or go to
http://127.0.0.1:8000/redoc
for ReDoc.
- Open your browser and navigate to
-
Test the API Endpoints:
You can use the interactive documentation to test the endpoints directly from your browser.
- Authentication:
POST /auth/
: Authenticate a user and receive a JWT token.
- User Management:
POST /users/
: Create a new user.GET /users/{id}/
: Fetch the current user's details.
- Post Management:
POST /posts/
: Create a new post.GET /posts/{id}
: Fetch a single post by ID.GET /posts/
: Fetch all posts.PUT /posts/{id}
: Update post.DEL /posts/{id}
: Delete post.POST /like/
: Like a post.
curl -X 'POST' \
'http://127.0.0.1:8000/auth/' \
-H 'Content-Type: application/json' \
-d '{
"username": "user1",
"password": "password123"
}'
{
"access_token": "your.jwt.token",
"token_type": "bearer"
}
The application uses environment variables for configuration. Example environment variable files have been provided:
.env.example
: General environment variables for the application..env.postgres.example
: Environment variables specific to PostgreSQL configuration.
To use them:
- Copy the example files to
.env
and.env.postgres
. - Edit the files to include your specific configuration details, such as database credentials, JWT secret keys, etc.
Docker Compose will automatically load these environment variables.
Contributions are welcome! Please read the CONTRIBUTING.md for guidelines on how to contribute to this project.
This project is licensed under the MIT License - see the LICENSE file for details.