2008-Untangled / Untangled-BE

Backend repository for the Untangled app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Untangled Backend

Contributors Forks Stargazers Issues Build Status

Untangled Backend

This project was made from the idea of helping those with Dementia and Alzheimers recall memories using the memory palace technique. This is the Back End repository for the Untangled application, which works in tandem with the Untangled Frontend Repository. This Back End application returns information to the Front End through API requests.
Explore the docs »

· Report Bug · Request Feature

Table of Contents

  1. About This Project
  2. Virtual Environment setup
  3. Database Setup
  4. Running Locally
  5. Running Tests
  6. Endpoints
  7. Endpoints Table
  8. Database Schema
  9. Roadmap
  10. Contributing
  11. Contact

About This Project

Visit Untangled to view all the repositories associated with this application.

This Backend application stores all the relevant data needed for the Untangled application. It has information for users, rooms, and memories, and allows for updates to users and memories. It responds to the Frontend of the application through API requests and responses. Scroll down to the endpoints section see what is available.

Built With

Virtual Environment setup

# build a virtual environment to install your Python packages
python3 -m venv ./venv

# 'activate' the virtual environment for your project
# do this every time you start a new terminal and enter your project folder
source venv/bin/activate

# install your Python packages
pip3 install -r requirements.txt

To shut off your virtual environment, run deactivate at a terminal where you have an active virtual environment.

Database Setup

createdb untangled_dev
createdb untangled_test

export DATABASE_URL=postgresql://localhost:5432/untangled_dev

# examine any database models you have set up
python3 manage.py db migrate

# "upgrade" your database schema to use the changes you've made in your models
python3 manage.py db upgrade

# then apply the same for your test database:
export DATABASE_URL=postgresql://localhost:5432/untangled_test
python3 manage.py db upgrade

# you can seed your database with:
python3 manage.py db_seed

Running Locally

To run the application in your local dev environment run:

python3 run.py

You may now access API endpoints locally at:

http://localhost:5000/api/v1/

Running Tests

If you just want to run your tests, pytest by itself will do the job.

In order to return a test coverage report run:

# remove any previous test caching, previous coverage reports, and a database
# of coverage data from the last time you ran this
rm -rf .pytest_cache/ coverage_html_report/ .coverage

# set your database url for your test database and use 'coverage' to launch
# pytest
DATABASE_URL=postgresql://localhost/untangled_test coverage run -m pytest

# generate the HTML reports
coverage html

# open the coverage report in your browser
open coverage_html_report/index.html

# count how many 'assert' calls you make in your tests
# my last project using this structure had 76 tests and 296 assertions that
# made sure every little thing got tested
grep -R assert tests | grep '.py:' | wc -l

Endpoints

All endpoints can be reached at:

https://untangled-be.herokuapp.com/api/v1/
  • GET and PATCH endpoints will return a 200 status code on success
  • POST endpoints will return a 201 status code on success
  • DELETE endpoints will return a 204 status code on success

Failure conditions will return an appropriate 400-series or 500-series error and a JSON payload indicating helpful errors in a format such as:

{
  "error": 404,
  "message": "Resource not found"
}

GET request: Require no headers or body.

PATCH request: Require a body with the new information as a JSON payload. For example, the body for a user patch request:

{
  "name": "ian",
  "email": "ian.douglas@iandouglas.com"
}

Endpoints Table

https://untangled-be.herokuapp.com/api/v1

Description URL Verb Request Body Sample Success Response
Get All Users /users GET
{
"success": true,
"results": [
{
"id": <int>,
"name": "<string>"
"email": "<string>"
}
]
}
Get A User By Id /users/:id GET
{
"id": <int>,
"name": "<string>",
"email": "<string>"
"success": ture
}
Get All Rooms /users/:id/rooms GET
{
"success": true,
"data": [
{
"id": <int>,
"name": "<string>",
"image": "<string>",
"user_id": <int>
},
{...}
]
}
Get A Room By Id /rooms/:id GET
{
"success": true,
"data": {
"id": <int>
"name": "<string>"
"image": "<string>",
"user_id": <int>
}
}
Get All Memories For A Room /rooms/:id/memories GET
 {
"success": true,
"data": [
{
"id": <int>,
"description": "<string>",
"image": "<string>",
"song": "<string>",
"aromas": "<string>",
"x": <int>,
"y": <int>,
"room_id": <int>
},
{
"id": <int>,
"description": "<string>",
"image": "<string>",
"song": "<string>",
"aromas": "<string>",
"x": <int>,
"y": <int>,
"room_id": <int>
}
]
}
Create a Memory /rooms/:id/memories POST
{
"description": "<string>",
"image": "<string>",
"song": "<string>",
"aromas": "<string>",
"x": <int>,
"y": <int>
}
 {
"id": <int>,
"description": "<string>",
"image": "<string>",
"song": "<string>",
"aromas": "<string>",
"x": <int>,
"y": <int>,
"room_id": <int>,
"success": true
}
Update a Memory By Id /memories/:id PATCH
{
"description": "<string>",
"image": "<string>",
"song": "<string>",
"aromas": "<string>",
"x": <int>,
"y": <int>
}
 {
"success": true,
"data": {
"id": <int>,
"description": "<string>",
"image": "<string>",
"song": "<string>",
"aromas": "<string>",
"x": <int>,
"y": <int>,
"room_id": <int>
}
}
Delete a Memory /memories/:id DELETE
 Returns 204 No Content 

Database Schema

Database Schema

Roadmap

See Open Issues or visit our Project Board for a list of proposed features, known issues, and project extensions.

Contributing

Contributions are what make this community such an amazing and fun place to learn, grow, and create! Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch git checkout -b feature/NewGreatFeature
  3. Commit your Changes git commit -m 'Add some NewGreatFeature'
  4. Push to the Branch git push origin feature/NewGreatFeature
  5. Open a new Pull Request!

Contact

Bryce Jarrett      - LinkedIn - GitHub

Cameron Romo   - LinkedIn - GitHub

Joe Lopez           - LinkedIn - GitHub

Estelle Staffieri   - LinkedIn - GitHub

Grant Dempsey  - LinkedIn - GitHub

Eduardo Parra     - LinkedIn - GitHub

Jesse Mellinger   - LinkedIn - GitHub

Sean Steel           - LinkedIn - GitHub

Project Link: Untangled

About

Backend repository for the Untangled app


Languages

Language:Python 98.3%Language:Mako 0.7%Language:HTML 0.4%Language:Dockerfile 0.4%Language:Shell 0.3%