Code Monkey home page Code Monkey logo

user-event-tracker's Introduction

User Event Tracker

This user event tracker is a simple Flask REST API that uses Flask-SQLAlchemy and psycopg2-binary to connect to a PostgreSQL database. Both the application and the database are running in Docker containers.

This app does not include a login system; one is mocked by manually setting a valid USER_EID value in app/config.py. It also uses Flask's builtin server, rather than one suitable for a production deployment.

Each event and user have an external id (eid). This eid is a UUID generated on save.

The search endpoint makes the assumption that if both title and description search values are provided, both should match, and that if neither are provided, the request is bad.

There is a deactivation endpoint and a deletion endpoint. Events that are not marked active do not show up in search results and are not returned by a direct request; to an end user, they would be functionally deleted. The deletion endpoint truly deletes an event from the database.

Installation instructions

Ensure Docker Desktop is running locally.

Clone this repository, and from its root directory run make run.

If you see User Event Tracker when you visit localhost, everything is running as expected.

Sample requests

Postman collection

You can find a Postman collection here.

cURLs

curl --location 'http://localhost/event' \
--header 'Content-Type: application/json' \
--data '{
    "title": "A deactivated event",
    "description": "Not active."
} '
  • Search title
curl --location 'http://localhost/events' \
--header 'Content-Type: application/json' \
--data '{
    "title": "time"
} '
  • Search description
curl --location 'http://localhost/events' \
--header 'Content-Type: application/json' \
--data '{
    "description": "it'\''s"
} '
  • Search title AND description
curl --location 'http://localhost/events' \
--header 'Content-Type: application/json' \
--data '{
    "title": "refreshing",
    "description": "something"
} '
  • Deactivate event

You might prefer to create a separate event to test this one. Just swap out the eid!

curl --location --request PUT 'http://localhost/event/92be70d5-8811-4520-b7c5-7f3025e7159e'
  • Delete event

You might prefer to create a separate event to test this one. Just swap out the eid!

curl --location --request DELETE 'http://localhost/event/92be70d5-8811-4520-b7c5-7f3025e7159e'
  • For further testing: create a different user

    • Visit Create a user
    • Copy the eid returned.
    • Replace the existing value for USER_EID in app/config.py with the newly-created user eid.
    • Try some requests. See how they've changed.

user-event-tracker's People

Contributors

slyeargin avatar

Watchers

 avatar

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.