Skip to content

forartsake/webtronics

Repository files navigation

Social Networking Application RESTful API

This is a simple RESTful API for a social networking application built within FastAPI. It allows users to authenticate, register, create, edit, delete, and view posts, as well as like or dislike other users' posts.

Getting Started

To get started with the API, follow these instructions.

Prerequisites

Make sure you have the following software installed on your machine:

  • preferable OS - Linux
  • Docker
  • Docker Compose

Installation

  1. Clone the repository:
git clone {<url>}
  1. Create an .env file based on your environment and set the required environment variables.

  2. Build and run the Docker containers

docker-compose build --no-cache
docker-compose up

These commands will build the FastAPI application container, PostgreSQL database container, and Redis cache container.

  1. Wait for the containers to start up. You can check the logs to monitor the progress:
docker-compose logs -f
  1. Once the containers are up and running, you can access the API documentation by visiting http://<host>:<port>/docs in your web browser.

  2. To run unit tests, use the following command:

python -m pytest -s -rP

Usage

Authentication and Registration

To authenticate or register a user, you can use the following endpoints:

  • POST /register - Register a new user
  • POST /login - Authenticate and retrieve a JWT token

Posts

To manage posts, you can use the following endpoints:

  • GET /posts/{post_id} - Get a specific post by ID
  • POST /posts - Create a new post
  • PUT /posts/{post_id} - Update a post
  • DELETE /posts/{post_id} - Delete a post

Likes and Dislikes

To like or dislike a post, you can use the following endpoints:

  • POST /posts/{post_id}/like - Like a post
  • POST /posts/{post_id}/dislike - Dislike a post

Please note that you cannot like or dislike your own posts.

Technologies Used

  • FastAPI - Web framework for building the API
  • PostgreSQL - Relational database for storing user and post data
  • Redis - In-memory data store for caching
  • Docker - Containerization platform for easy deployment
  • Docker-Compose - Tool for defining and running multi-container Docker applications

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published