/social-network-api

Social Network backend repository

Primary LanguagePythonMIT LicenseMIT

Social Network Project

This is a mini social media project that I created to learn more about the FastAPI and React frameworks. It is a simple social media site that allows users to create accounts and make posts. It is a work in progress and I plan to add more features in the future.

Technologies

FastAPI PostgreSQL Docker

About

This repo contains the backend code of the project made with FastAPI.
The frontend code can be found here.

Features

  • Create accounts
  • User posts

Getting Started

Prerequisites

  • Docker
  • Docker Compose
  • Python >= 3.10
  • Pipenv
  • Traefik (optional)

Installation

  1. Clone the repo
    git clone https://github.com/fhilipecrash/social-network-api
  2. Run the project
    1. Without Docker python container
      docker-compose up -d pgsql # Run the postgres container
      pipenv shell # Activate the virtual environment
      pipenv install # Install the dependencies
      pipenv run dev # Run the project
    2. With Docker python container
      docker-compose up -d # Run the postgres and python container
    3. With Devcontainer If you have Devcontainer extension just open the project in VSCode and it will automatically create the container for you.

Usage

When you enter the project for the first time you will need to run the migrations to create the database tables.

pipenv run migrate

Checkout the Swagger documentation at http://localhost:8000/docs

You can use traefik to use a basic proxy to the project. If you have trakif binary on your PATH, you can run the following command to start the proxy:

Note: Traefik is started automatically when you run the project with docker-compose.

Note: This command will use your current terminal session to run the proxy and you don't be able to use the terminal while the proxy is running. So open a new terminal session to run the project.

pipenv run proxy # Run the proxy

Now you can access the documentation at http://localhost:9999/api/v1/docs just like any other application route and it is recommended to use the same url and port to test the endpoints.