A project developed for the course Databases 2 at University of Salerno.
UniConnect is a comprehensive application for connecting university students. This guide provides detailed steps to set up and run the application, generate mock data, and import it into a Neo4j database.
- Docker
- Python
- Java JDK 17
- Flutter SDK
- Maven
- Android Studio Community (for front-end)
- IntelliJ IDEA Community (for back-end)
- Install and Run Neo4j Docker Container
- Generate Mock Data
- Copy CSV File to Docker Container
- Import Data into Neo4j
- Set Up the Application
- Run the Application
- Systems
First, install and run the Neo4j Docker container with the following command:
docker run --name UniConnect-Db-App --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/uniconnect' neo4j:5
--name UniConnect-Db-App
: Names the Docker container "UniConnect-Db-App".--publish=7474:7474
: Maps port 7474 on your local machine to port 7474 on the Docker container for the Neo4j browser interface.--publish=7687:7687
: Maps port 7687 on your local machine to port 7687 on the Docker container for the Bolt protocol.-e 'NEO4J_AUTH=neo4j/uniconnect'
: Sets the Neo4j authentication with the usernameneo4j
and the passworduniconnect
.neo4j:5
: Specifies the version of the Neo4j Docker image to use.
Create a Python script to generate mock student data and save it to a CSV file.
Python Script to Generate Mock Data (generate_mock_data.py
):
import bcrypt
import pandas as pd
from faker import Faker
import uuid
# Configure the salt for bcrypt
salt = b"$2a$10$Gs.PmaGJQtm0ThQF3VkX2u"
def hash_password(password):
hashed_password = bcrypt.hashpw(password.encode('utf-8'), salt)
return hashed_password.decode('utf-8')
# Create an instance of Faker
fake = Faker()
# Number of students to generate
num_students = 600
# Enums for the department
departments = [
"AGRICOLA", "ARCHITETTURA", "BIOMEDICHE", "FORMAZIONE_BENICULTURALI",
"CHIMICHE", "ECONOMICHE_STATISTICHE", "GIURIDICHE", "INGEGNERIA_ELETTRICA",
"INGEGNERIA_EDILE", "INGEGNERIA_INDUSTRIALE", "INFORMATICA", "MATEMATICA_FISICA",
"MEDICINA_CHIRURGIA_ODONTOIATRIA", "FARMACIA", "MOTORIE_UMANE_SOCIALI",
"POLITICHE_SOCIALI", "LINGUAGGIO_BENICULTURALI", "FISICA", "SCUOLA_MEDICINA"
]
# Mock data
data = []
for _ in range(num_students):
student_id = str(uuid.uuid4())
full_name = fake.name()
name_parts = full_name.split()
first_name = name_parts[0].lower()
last_name = name_parts[-1].lower()
email = f"{first_name}.{last_name}@gmail.com"
password_hash = hash_password("Ciao1002!")
biography = " "
departement_unisa = fake.random_element(departments)
data.append([student_id, full_name, email, password_hash, departement_unisa,biography])
# Create a DataFrame and save to a CSV
df = pd.DataFrame(data, columns=["ID", "fullName", "email", "passwordHash", "departementUnisa"."biography"])
df.to_csv("mock_students.csv", index=False)
Run the Python script to generate the mock_students.csv
file.
python generate_mock_data.py
Copy the mock_students.csv
file into the /var/lib/neo4j/import
folder of the Docker container.
docker cp mock_students.csv UniConnect-Db-App:/var/lib/neo4j/import/
Access the Cypher Shell of the Neo4j Docker container.
docker exec -it UniConnect-Db-App bin/cypher-shell -u neo4j -p uniconnect
Run the following command in the Cypher Shell to import the data from the CSV file into the Neo4j database.
LOAD CSV WITH HEADERS FROM 'file:///mock_students.csv' AS row
CREATE (:Student {ID: row.ID, fullName: row.fullName, email: row.email, passwordHash: row.passwordHash, departementUnisa: row.departementUnisa, row.biography});
Ensure you have Java JDK 17 installed. You can download it from the official website.
Follow the instructions on the official Flutter website to install the Flutter SDK.
Download and install Android Studio Community from the official website. This IDE is required for running and developing the Flutter front-end.
Download and install IntelliJ IDEA Community from the official website. This IDE is required for running and developing the Spring Boot back-end.
Ensure you have Maven installed. Navigate to your backend project directory and run the following command to install dependencies and build the project.
mvn clean install
If you have any necessity to add dependencies to your pom.xml
file, below there is an example of use it:
<dependencies>
<!-- Example dependencies -->
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.4.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
<!-- Add other necessary dependencies -->
</dependencies>
There are all dependencies in the Spring module, so you can download by Intellij setting or with the command of mvn
Ensure you have Flutter installed. Navigate to your Flutter project directory and run the following command to get the dependencies.
flutter pub get
This command is important if there are any dependencies older than your version of sdk
flutter pub outdated
The same for Flutter dependencies, if you have any necessity to add any dependencies to your pubspec.yaml
file: there is an example of use it
dependencies:
flutter:
sdk: flutter
http: ^0.13.3
bcrypt: ^3.0.0
provider: ^5.0.0
# Add other necessary dependencies
Open the backend project in IntelliJ IDEA Community and run the application using Maven.
mvn spring-boot:run
Alternatively, you can run the backend directly from IntelliJ IDEA:
- Open the project in IntelliJ IDEA Community.
- Navigate to the
src/main/java
directory. - Locate the
UniConnectApplication.java
file. - Right-click on the file and select
Run 'UniConnectApplication'
orDebug 'UniConnectApplication'
.
Open the front-end project in Android Studio Community and run the Flutter application.
flutter run
Alternatively, you can run the front-end directly from Android Studio:
- Open the project in Android Studio Community.
- Navigate to the
lib
directory. - Locate the
main.dart
file. - Ensure that a device is selected for deployment (either a physical device or an emulator).
- Click the
Run
orDebug
button at the top of the interface.
Note: If you encounter issues with device selection or running the application, refer to the official Flutter guide for setting up devices in Android Studio.
Students | Follows-Relationship | Created-by-Relationship |
---|---|---|
UniConnect offers the following primary features:
Absolutely! Let's include multiple images for each feature in the table:
Feature | Description | Images |
---|---|---|
Login | Login enables registered students to securely access their accounts by providing their credentials, such as username/email and password. |
This project is licensed under the MIT License - see the LICENSE file for details.
By following these steps, you will be able to set up and run the UniConnect application
Generate mock data, copy it into the Neo4j Docker container, and import it into the database using Cypher Shell. This README.md
file contains all the necessary instructions to mock student data, copy it into the Neo4j Docker container, and import it into the database. Be sure to adjust any paths or specific details to fit your development environment.
This README.md
now includes detailed instructions for running the application directly from the main entry points in Android Studio and IntelliJ IDEA, ensuring users can set up and execute the project efficiently.