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.
To get the project up and running on your local machine, follow the setup and installation instructions below.
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.
This is the recommended way to run the project, as it sets up both the FastAPI application and the Neo4j database with minimal effort.
-
Clone the repository:
git clone https://github.com/ryofac/rede_social_fast_neo4j.git cd rede_social_fast_neo4j -
Configure environment variables: Copy the
example.envfile to.envin 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.
-
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.
-
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 athttp://localhost:8000/docs. You can access the Neo4j Browser athttp://localhost:7474(useneo4jas username and yourNEO_PASSWORDfrom.env).
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:
-
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
.envfile is correctly configured to point to your Neo4j instance (e.g.,NEO_URL=bolt://localhost:7687). -
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 -
Install Poetry: If you don't have Poetry installed, follow the instructions on their official website: https://python-poetry.org/docs/#installation
-
Install dependencies:
poetry install
-
Activate the virtual environment:
poetry shell
-
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
-
Access the application: The FastAPI application will be available at
http://localhost:8000, and its API documentation athttp://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.