Skip to content

Repository files navigation

Rubyan Project: Social Network with Neo4j and FastAPI

This project demonstrates the functional dynamics of a graph-oriented database, Neo4j, within the context of a social network application. It highlights the importance and benefits of using Neo4j for managing highly interconnected data, which is characteristic of social media platforms.

Getting Started

To get the project up and running on your local machine, follow the setup and installation instructions below.

Prerequisites

Before you begin, ensure you have the following installed:

  • Git: For cloning the repository.
  • Docker Desktop (or Docker Engine and Docker Compose): For running the application and Neo4j in containers.
  • Python 3.9+ (if running locally without Docker).
  • Poetry (if running locally without Docker): For dependency management.

Using Docker Compose (Recommended)

This is the recommended way to run the project, as it sets up both the FastAPI application and the Neo4j database with minimal effort.

  1. Clone the repository:

    git clone https://github.com/ryofac/rede_social_fast_neo4j.git
    cd rede_social_fast_neo4j
  2. Configure environment variables: Copy the example.env file to .env in the project root and fill in the necessary details, especially for the Neo4j connection.

    cp example.env .env
    # Open .env and adjust NEO_PASSWORD and other settings if needed.
    # By default, NEO_URL points to the Neo4j service within Docker Compose.
  3. Start the services: Run the following command in the project root directory:

    docker-compose -f local.yml up --build

    This command will:

    • Build the Docker images for the FastAPI application and Neo4j (if not already built).
    • Start the Neo4j database container.
    • Start the FastAPI application container, which will connect to the Neo4j container.
  4. Access the application: Once the containers are running, the FastAPI application will be accessible at http://localhost:8000. The API documentation (Swagger UI) will be available at http://localhost:8000/docs. You can access the Neo4j Browser at http://localhost:7474 (use neo4j as username and your NEO_PASSWORD from .env).

Running Locally (Development)

If you prefer to run the FastAPI application directly on your machine (assuming Neo4j is running separately, for example, via Docker Compose or a standalone Neo4j instance), follow these steps:

  1. Start Neo4j (if not already running): You can use the Docker Compose setup to run Neo4j only:

    docker-compose -f local.yml up -d neo4j

    Ensure your .env file is correctly configured to point to your Neo4j instance (e.g., NEO_URL=bolt://localhost:7687).

  2. Clone the repository and navigate to the project directory:

    git clone https://github.com/ryofac/rede_social_fast_neo4j.git
    cd rede_social_fast_neo4j
  3. Install Poetry: If you don't have Poetry installed, follow the instructions on their official website: https://python-poetry.org/docs/#installation

  4. Install dependencies:

    poetry install
  5. Activate the virtual environment:

    poetry shell
  6. Run the FastAPI application:

    ./run.sh

    Alternatively, you can run it directly with FastAPI's dev server:

    fastapi dev social_network/main.py --port 8000 --host 0.0.0.0
  7. Access the application: The FastAPI application will be available at http://localhost:8000, and its API documentation at http://localhost:8000/docs.


For more detailed information about the project's architecture, Neo4j integration, and the benefits of using graph databases for social networks, please refer to the full documentation.

About

Uma rede social feita com base no banco de dados orientado a grafos neo4j

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages