Stearnzy / backend

Backend repository for the Vivid application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vivid Project Backend

Contributors Forks Stargazers Issues Build Status

Vivid Backend

This is the backend API service for the Vivid app.

· Report Bug · Request Feature

Table of Contents

About The Project

Please visit the frontend repository of this project and check out the readme there for a more in depth look at this project!

This backend repository was built to provide CRUD endpoints to the front end for users, dreams, and themes. This backend also provides as the middleman between the frontend and the Tone Analyzer Microservice. This repository saves, updates, retrieves and deletes user information, dream logs, and dream themes in the PostgreSQL database. When a user saves a dream journal entry, a request will be issued to the tone analyzer microservice containing a raw text body holding that journal entry. After analysis, the list of tones and their counts are transformed and saved to the database.

To view all the repositories associated with Vivid, please visit Vivid-Project

Built With

Getting Started

To properly use this application you will need to set up and configure three repositories. Follow the Configuration directions in each repository to get Vivd running locally! Alternatively, check out the production application here! Heroku puts some apps to sleep after a while; if loading the home page fails or times out, refreshing the page should be enough to see the app in production.

Prerequisites

These setup instructions are for Mac OS.

Configuration

  • Fork and clone this repo into the directory that will house the Frontend or Microservice repositories.
  • Install the Maven Command Line tool with Homebrew by entering brew install maven
  • Be sure to have PostgreSQL installed on your machine and create a new database titled vivid

Usage

  • Run the server from the command line by entering mvn spring-boot:run. This should seed the Postgres database with prepackaged seed data and allow you to make API calls from a tool such as Postman.

API Endpoints

Authenticate User

Request:

Uri: POST /users/authenticate

{
    "email": "adrew@example.com",
    "password": "password"
}

Response:

{
    "id": 345,
    "name": "Ava Drew",
    "email": "adrew@example.com",
    "token": "a6t9dvJW424Mw3BRHTfE5qiZg67-kXk_"
}
Get user data

Request:

Uri: GET /user

Header: "Authorization": "Bearer <token>"

Response:

{
    "id": 450,
    "name": "Ava Drew",
    "email": "adrew@example.com"
}
Get user dreams

Request:

Uri: GET /dreams

Header: "Authorization": "Bearer <token>"

Response:

[
    {
        "id": 551,
        "date": "02/22/2021",
        "title": "Weird Dream",
        "description": "This was very weird",
        "emotion": "Fun",
        "themes": [],
        "toneAnalysis": {
          "tone_strength": {
                "Tentative": 1
            },
            "unique_tones": "Tentative"
        }
    }
    {
        ...
    }
]
Get user dreams by date range

Request:

Uri: GET /dreams

Header: "Authorization": "Bearer <token>"

Params(required): dateStart, dateEnd

Response:

[
    {
        "id": 3,
        "date": "2021-02-23",
        "title": "Cool Dream",
        "description": "This is a good dream",
        "emotion": "Happy",
        "themes": [],
        "toneAnalysis": {
          "tone_strength": {
                "Tentative": 1
            },
            "unique_tones": "Tentative"
        }
    },
    {
        "id": 4,
        "date": "2021-02-24",
        "title": "Bad Dream",
        "description": "This was scary",
        "emotion": "Bad",
        "themes": [],
        "toneAnalysis": {
          "tone_strength": {
                "Joy": 1
            },
            "unique_tones": "Joy"
        }
    },
    {
        ...
    }
]
Get single user dream

Request:

Uri: GET /dreams/<dreamId>

Header: "Authorization": "Bearer <token>"

Response:

{
    "id": 579,
    "user": {
        "id": 576,
        "name": "Ava Drew",
        "email": "adrew@example.com"
    },
    "date": "02/22/2021",
    "title": "Weird Dream",
    "description": "This was very weird",
    "emotion": "Fun",
    "themes": [],
    "toneAnalysis": {
        "tone_strength": {
            "Tentative": 1
        },
        "unique_tones": "Tentative"
    }
}
Create a user dream

Request:

Uri: POST /dreams

Header: "Authorization": "Bearer <token>"

Raw JSON Body:

{
    "date": "02/25/2021",
    "title": "Train dream",
    "description": "I was on a train",
    "emotion": "Weird"
}

Response:

{
    "id": 146,
    "date": "02/25/2021",
    "title": "Train dream",
    "description": "I was on a train",
    "emotion": "Weird",
    "themes": [],
    "toneAnalysis": {
        "tone_strength": {
            "Tentative": 1
        },
        "unique_tones": "Tentative"
    }
}
Create user

Request:

URI: POST /users

Raw JSON Body:

{
    "name": "Alex",
    "email": "alex@example.com",
    "password": "password123"
}

Response:

{
    "id": 14,
    "name": "Alex",
    "email": "alex@example.com",
    "token": "K157xIzmC9WBc7O4Rd6Ge2PV_jiwyfvN"
}

Testing

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

Amanda Davidson  - LinkedIn - GitHub - Turing Alum Profile

Shawn Truesdale    - LinkedIn - GitHub

Jonathan Wilson     - LinkedIn - GitHub - Turing Alum Profile

Zach Stearns           - LinkedIn - GitHub - Turing Alum Profile

Aidan Murray           - LinkedIn - GitHub

Taylor Phillips           - LinkedIn - GitHub - Turing Alum Profile

Project Link: Vivid

About

Backend repository for the Vivid application.


Languages

Language:Java 100.0%