To start the backend run (add the --build flag to build images before starting containers (build from scratch)):
docker-compose up
docker-compose up --buildThis will build the GraphDB docker image and the FastAPI docker image.
The GraphDB instance will be available at: localhost:7200
The FastAPI documentation will be exposed at: http://0.0.0.0:9017
Desription of how to start the backend locally outside docker. The backend consists of a GraphDB database and a FastAPI server.
To start GraphDB, run these scripts from the GraphDB folder:
bash graphdb_install.sh
bash graphdb_preload.sh
bash graphdb_start.shTo test your graphbd connection run from your base folder (/sindit):
poetry run python run_test.pyGo to localhost:7200 to configure graphdb
To start the FastAPI server, run:
poetry run python run_sindit.py{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src/sindit",
"env": {
"PYTHONPATH": "${workspaceFolder}/src"
},
"justMyCode": false
}
]
}The API requires a valid authentication token for most endpoints. Follow these steps to authenticate and use the API:
-
Generate a Token:
- Use the
/tokenendpoint to generate an access token. - Example
curlcommand:curl -X POST "http://127.0.0.1:9017/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "username=new_user&password=new_password"
- Replace
new_userandnew_passwordwith the credentials provided below.
- Use the
-
Use the Token:
- Include the token in the
Authorizationheader for all subsequent API calls:curl -X GET "http://127.0.0.1:9017/endpoint" \ -H "Authorization: Bearer your_generated_token_here"
- Include the token in the
-
Access API Documentation:
- The FastAPI documentation is available at:
http://127.0.0.1:9017/docs
- The FastAPI documentation is available at:
To add a new user, update the fake_users_db in authentication_endpoints.py with the following credentials:
fake_users_db = {
"new_user": {
"username": "new_user",
"full_name": "New User",
"email": "[email protected]",
"hashed_password": "$2b$12$eW5j9GdY3.EciS3oKQxJjOyIpoUNiFZxrON4SXt3wVrgSbE1gDMba", # Password: new_password
"disabled": False,
}
}To generate a new hashed password, use the Python snippet in password_hash.py.
Replace "new_password" with your desired password.
