Skip to main content

SINTEF Digital Twin Framework

Project description

SINDIT Logo

Run backend using Docker Compose

To start the backend run (add the --build flag to build images before starting containers (build from scratch)):

docker-compose up
docker-compose up --build

This 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

Run backend locally

Desription of how to start the backend locally outside docker. The backend consists of a GraphDB database and a FastAPI server.

GraphDB

To start GraphDB, run these scripts from the GraphDB folder:

bash graphdb_install.sh
bash graphdb_preload.sh
bash graphdb_start.sh

To test your graphbd connection run from your base folder (/sindit):

poetry run python run_test.py

Go to localhost:7200 to configure graphdb

API uvicorn server

To start the FastAPI server, run:

poetry run python run_sindit.py

Run using vscode launcher

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "/Users/gorans/projects/monorepo/projects/sindit",
            "justMyCode": false,
            "envFile": "/Users/gorans/projects/monorepo/projects/sindit/environment_and_configuration/dev_environment_backend.env",

        }
    ]
}

Using the API

Authentication

The API requires a valid authentication token for most endpoints. Follow these steps to authenticate and use the API:

  1. Generate a Token:

    • Use the /token endpoint to generate an access token.
    • Example curl command:
      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_user and new_password with the credentials provided below.
  2. Use the Token:

    • Include the token in the Authorization header for all subsequent API calls:
      curl -X GET "http://127.0.0.1:9017/endpoint" \
      -H "Authorization: Bearer your_generated_token_here"
      
  3. Access API Documentation:

    • The FastAPI documentation is available at: http://127.0.0.1:9017/docs

Generate New Username and Password

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": "new_user@example.com",
        "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.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sindit-0.0.1.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sindit-0.0.1-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file sindit-0.0.1.tar.gz.

File metadata

  • Download URL: sindit-0.0.1.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for sindit-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5ca2b68fdfbc5769efcd2b6a9483dd717a5f979fb159fedc5b866fd5041a17f4
MD5 fd2b6418d360b74ab9b551f4a93bba2f
BLAKE2b-256 b13cba3b9a72802ff4865b868d9923292c1cd0436d2e382fe3fffaa49fd301e9

See more details on using hashes here.

File details

Details for the file sindit-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: sindit-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for sindit-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42916fdabf238f86804f61a6b05ec579d25a401c3957f2fc64fdf713248d68c1
MD5 3c3f7aaaf2d7d24721512177a6100eba
BLAKE2b-256 2ea6e693b13b5b2c27a289a7cd2ff3c6b44a458c4900aa73f86200955e9aef0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page