Giter Club home page Giter Club logo

link-api's Introduction

link-api

Overview

This is an API for the Link react app. Most of the calls use SQLAlchemy models and schemas to access a Postgres DB, but the /analyze endpoint uses the LTS Connectivity tool (linked below).

It uses:

Setup/Installation

1. Install dependencies, if not installed. For postgres with extensions, consider using

sudo apt install postgresql-15-pgrouting

which will install PostgreSQL, PostGIS, and PGrouting. If you have postgres already, you need to install the other two individually. Setup any roles you want.

You also need ogr2ogr. For Linux:

  sudo apt-get install gdal-bin

2. Create an empty virtual environment

python -m venv ve

Then activate the environment.

. ve/bin/activate

3. Install the requirements with:

pip install wheel && pip install -r requirements_base.txt

4. Add a .env file

Create a .env file at the root of the project. An example is below, which contains a URI to a database.

DB_URI=postgresql://user:pw@host:port/db

You may also alter the path by including a URL_ROOT variable (that starts with a /). If not included, it will not be used.

DB_URI=postgresql://user:pw@host:port/db
URL_ROOT=/api

5. Add config file for pg-data-etl

You'll need to add a configuration file for pg-data-etl at the root of this project. It must be named 'database_connections.cfg', and should be formatted like this:

[localhost] 
host = host
un = postgres
pw = password
port = port
db_name = db_name

Don't edit the localhost in brackets, as the script searches for it (see analyze endpoint) but change all the other variables.

6. Import database backup

If you're putting this onto a remote server, you need to pipe a copy of the database from a machine that's behind the DVRPC firewall, as all of the data import and setup scripts can only be run behind the firewall, pulling from DVRPC's GIS postgres server. The most recent backup can be found in 'G:\Shared drives\Bike LTS and Connectivity Analysis Webmap\Rethinking Connectivity\DB_Backups'.

Pipe a copy in with:

psql -U your_username -h your_host -p your_port -d target_database < backup.sql  

Usage

Start the development server with

cd app
uvicorn main:app --reload

See what API calls are supported by visiting localhost:8000/docs. (Note that if you set URL_ROOT, this would be different, e.g. a URL_ROOT of /api would result in localhost:8000/api/docs).

License

The project uses the GPL 3.0 license.

link-api's People

Contributors

mmorley0395 avatar kdwarn avatar jstrangfeld avatar dependabot[bot] avatar

Watchers

Christopher Pollard avatar Michael Ruane avatar  avatar  avatar

link-api's Issues

api login

api login will not alert user if credentials are incorrect. however, it still correctly denies access, so this is low-priority, especially since api isn't really intended to be public

rename broken

rename not catching names that are already in db for some reason

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.