{"id":27350627,"url":"https://github.com/robgc/sento-api","last_synced_at":"2025-04-12T19:58:26.050Z","repository":{"id":52706258,"uuid":"164287204","full_name":"robgc/sento-api","owner":"robgc","description":"Async API for exposing results of Sento's analytics","archived":false,"fork":false,"pushed_at":"2022-09-16T18:05:40.000Z","size":128,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-12T19:58:22.303Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robgc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-06T07:59:28.000Z","updated_at":"2019-06-23T23:15:28.000Z","dependencies_parsed_at":"2023-01-18T10:32:58.349Z","dependency_job_id":null,"html_url":"https://github.com/robgc/sento-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robgc%2Fsento-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robgc%2Fsento-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robgc%2Fsento-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robgc%2Fsento-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robgc","download_url":"https://codeload.github.com/robgc/sento-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625506,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-12T19:58:25.474Z","updated_at":"2025-04-12T19:58:26.040Z","avatar_url":"https://github.com/robgc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sento-api\n\n_This project is part of Sento's backend_.\n\nAsync API for exposing results of Sento's analytics\n\n# Table of contents\n\n- [Prerequisites](#prerequisites)\n  - [Using Docker and Docker Compose](#using-docker-and-docker-compose)\n  - [Running locally](#running-locally)\n- [Setting up the database](#setting-up-the-database)\n- [Setting up the API](#setting-up-the-api)\n- [License](#license)\n\n# Prerequisites\n\n## Using Docker and Docker Compose\n\nFor this type of installation you will need:\n\n- Docker Engine 17.12.0 or higher.\n- Docker Compose 1.18.0 or higher.\n\n## Running locally\n\nThese are the software requirements of each component if you want to run it\nlocally:\n\n- Database\n  - PostgreSQL 9.6 or higher (older versions have not been tested).\n  - PostGIS 2.3.0 or higher.\n  - `pg_trgm` extension activated.\n\n- API\n  - Python 3.7 or higher.\n  - Pipenv (package manager).\n\nIn order to set up an instance you need a PostgreSQL database initialised\nusing the instructions available [here](#setting-up-the-database).\n\n# Setting up the database\n\nThe best way to set up the database is with Docker container provided\nin this repository, but you can also use an existing DBMS.\nYou need to do the following:\n\n- **Configure variables for the database**:\n  - **Using the Docker Container**:\n    1. Create a `db.env` file from a copy of `db.example.env`.\n    2. Configure the different values in `db.env` according to your needs.\n      Keep in mind that most of those values will be needed by other Sento's components\n      in order to connect to the database.\n  - **Using an existing PostgreSQL instance**: If you have an existing PostgreSQL database\n    that matches the requirements, you can create a database for sento using the SQL script\n    located at `sento_api/database/init.sql`. Substitute the different variables at the start\n    of that script with the values that best suit you.\n\n- **Configure Sento API database connection**:\n  1. Create a `config.ini` file from a copy of `config.example.ini`\n  2. Adjust the configuration in `config.ini` according to your needs. Keep track of the variables\n    set in your `db.env` file or in your customized `init.sql` script. You should leave the default\n    value of `sento-db` in the `host` key inside the `[postgres]` section if you plan to use\n    the PostgreSQL container, this is a name that can be used by the container\n    to reach to the database in the container network.\n\n- **Create a database and a user for Sento**:\n  - **With the Docker Container**:\n    1. Run `docker volume create sento-data`, this will create a Docker volume where all database\n      data will be stored, useful for making backups and avoiding data loss caused by\n      the removal of the database container.\n    2. Run `docker-compose up -d sento-db`, this will create a PostgreSQL + PostGIS container\n      without any kind of structure.\n    3. Run `docker-compose exec sento-db psql -U postgres -f /src/init.sql`, this will\n      create a user and a database for Sento, this step uses the configuration values\n      written in `db.env` file.\n  - **Using an available instance**: run your customized `init.sql` script\n    with a tool like `psql` or `pgAdmin`.\n\n- **Create the tables from the models**:\n  - **With Docker**:\n    1. Build the API container's image with `docker-compose build`.\n    2. Run\n      `docker-compose run --rm --use-aliases sento-api pipenv run alembic upgrade head`.\n      This will create the necessary tables in the database using Alembic.\n  - **Locally using pipenv**:\n    1. Create a Python virtual environment with the necessary dependencies with `pipenv sync`.\n    2. Run `pipenv run alembic upgrade head`.\n\nAfter that you will be all set!\n\n# Setting up the API\n\nCheck the values set in your `config.ini` file (made from a copy of\n`config.example.ini`), specifically the values set in the `[api]` section.\n\n- **With Docker**:\n  1. Remember that the values set in the `config.ini` file are relative to the container.\n    Normally you will not need to change the listening IP and port present\n    in the `config.example.ini`, but, if you make any changes you will need to keep them\n    in mind for the next step.\n  2. Create a `docker-compose.override.yml` file from `docker-compose.override.exammple.yml` file,\n    then you can configure the IP and port mapping between your host and the container.\n    You can also override other container configurations if you need.\n  3. If you built the image for the API container previously, you can run\n    `docker-compose up -d sento-api`.\n- **Running locally**:\n  1. Create a Python virtual environment with the necessary dependencies with `pipenv sync`,\n    if you have not created it previously.\n  2. Run the following command `pipenv run sento_api/main.py`.\n\nIf you have followed the previous steps you should have an\ninstance of the API waiting for requests.\n\n# License\n\nThe source code of this project is licensed under the GNU Affero General\nPublic License v3.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobgc%2Fsento-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobgc%2Fsento-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobgc%2Fsento-api/lists"}