Giter Site home page Giter Site logo

jeffreyq / ucla-cs-130 Goto Github PK

View Code? Open in Web Editor NEW
1.0 5.0 3.0 4.17 MB

This is the central hub to our CS 130 Project: Polly

Python 29.08% Mako 0.27% Shell 0.16% JavaScript 64.14% Java 1.46% Ruby 1.55% Objective-C 2.54% Makefile 0.51% Dockerfile 0.29%

ucla-cs-130's Introduction

Polly

Setup instructions

Our Flask backend and postgres database are containerized using Docker.

To begin, make sure you have Docker Desktop installed.

Once you have Docker running, use the following commands from the backend project directory to setup and run the application:

  • make build
    • Builds both docker images
  • make run
    • Runs the Flask and postgres containers
  • make upgrade
    • Runs the alembic db upgrade command. Run this whenever you generate a migration

To stop the docker-compose process, press Ctrl-C

Live-reloading of the flask code is enabled, meaning you will be able to edit Python source code and see changes take effect immediately.

Postgres data is persisted to a volume on disk. This means that if you stop the docker-compose process, any data written to the postgres instance will be saved and available the next time you run make run. If you want to delete the volume completely, run make clean

Development

We are following the outline specified in this article to organize our Flask app.

Generating a migration

If you make any update to the models (any of the classes in app/main/models/*), you must generate a migration.

You can do so by running make migrate message="<your message>"

Testing

Tests are written in the app/test/ folder. Test modules should be named in the form test_<file>.py for example app/test/models/test_user.py.

To run the test suite, run make test. This runs a test postgres instance, creating and destroying the db instance on every run.

Our test suite coverage can be seen here. (This may be out of date)

Documentation Generation

Online Documentation

Our backend API documentation is generated automatically using flask_restplus, a library extension of Swagger.

While the Python server is running, visit http://localhost:5000/ in a browser to check out nice looking interactive API documentation, and also try out the endpoints with test requests.

Offline Documentation

To generate an offline documentation for the API, simply call make doc inside the backend directory while the Docker server instance is running.

This requires the installation of open source software called swagger2markup to generate AsciiDocs from the swagger OpenAPI JSON files, which you can install here.

Otherwise, the command will throw an error, but will at least generate a new polly_api.json file that describes the new interfaces.

The generated AsciiDoc should be located at backend/polly_api_documentation.adoc here

React-Native Setup

To run the react-native mobile app we are following the instructions here.

Be sure to follow the React-Native CLI Quickstart flow of the guide.

You will need Watchman, Node, and XCode installed.

brew install node
brew install watchman

XCode is most easily installed through the Mac App Store.

The iOS Package Manager CocoaPods is also necessary.

sudo gem install cocoapods

Assuming that you have the iOS simulator installed, all it takes to run Polly is

cd Polly
react-native run-ios

ucla-cs-130's People

Contributors

ramsgoli avatar jeffreyq avatar lawrencechen98 avatar jcaip avatar stephyip1998 avatar nityanbhorde avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

Forkers

xxd4rkc0d3rxx

ucla-cs-130's Issues

Show All of my Polls on the Profile Page

On the Profile Screen, we should render cards for all my of My polls

  • create a action to fetch all of my polls in from the backend and store them in the redux store
  • pass these polls to the Profile screen to render. Make them clickable

/users : see who is related to you and who you are related to

  • endpoint: GET /users/me/pollees

returns all users subscribed to you. Select all from users, and then join on user-user relationship data and then filter

  • endpoint: GET /users/me/pollers

returns all users you are subscribed to. Same as above, but using the other user_id.

Create a common Poll Detail Header component

Screen Shot 2019-12-01 at 2 45 46 PM

This component is used in all Poll Details ^ Create this as a standalone component which can be imported and used in all Poll Detail screens. The `close now` button should send a PATCH to /poll so we can close the poll

Build out /users endpoint

this should let us get all the details for a singular user and create a user

  • endpoint: GET /me

return my user detail for the db. Should just be a query + filter on users table

  • endpoint: POST /users

create a new user, generate a JWT and add to users table.

Add a Search Page to the front-end

Functionality:

  • See all users in the db
  • Press the "Invite" button to send that user an invite request
  • See the status of your relationship with every person

Update DB schema

We need the following two tables:

  • Friends (user-user relationship) table:

two user_ids, and a relationship state (either PENDING or FRIENDS)

  • Follows (user-poll relationship) table:

a user_id and a poll_id, represents that a user is following a poll

/polls poll specific endpoints

This should let us manipulate a single poll.

  • endpoint: GET /polls/

get poll details + responses
query poll table for poll, then join on responses table to provide poll + all responses

  • endpoint: PATCH /polls/

lets you close a poll by changing the is_closed field. Should be similar to below

  • endpoint: POST /polls

add a new poll to the db - take in passed in poll details and add to polls table.

/users friend list functionality

This should let us see our friends and also add friends

  • endpoint: GET /users

returns all of the users in the db as well as the current user relationship to them (blank, pending approval, friends), Will need to join on user-user relationship table

  • endpoint: POST /users/follow

requests a follow, creates a follow request in db (new entry in user-user relationship table)

  • endpoint: POST /users/confirm

confirms request if present, updated db. Finds entry with state PENDING in user-user relationship table, and then updates it to FRIENDS.

Build out /polls endpoint

This should let us get all the polls that a user is associated with (either created or subscribed to)

  • endpoint: GET /polls

get all polls that you're subscribed to.
Query poll-user relationship table for all relationships where user_id = and then join on polls table

  • endpoint: GET /polls/me

get all the polls that you've created.
query polls table with a filter where creator_id =

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.