2.4 KiB
Flask-API managing Users And Events
A RESTful API that manages events, offering users the ability to schedule, retrieve, update, delete, and be reminded of events with additional advanced features.
Flask-API - Interface
-
The User Will be able to retrieve upcomming event/s
- sort by
- popularity
- date
- filter by:
- location
- sort by
-
The User will be abale to create/update a new event
-
The User will be able to login/out
-
The Anonymous User will be able to create a new user
-
Event:
- (Auth Users) An event is an upcomming Party/Concert/Sport event/etc. It is tied to a user that created this event.
-
Authentication:
- The User will be able to login:
- The API will generate a JWT token and set the userId inside the Flask session.
- The API will return the JWT token in the response cookie header.
- The User will be able to login:
Backend-reminder
- The Users will be able to be reminded of upcoming events.
- The backend will Send reminders 30 minutes before the event's scheduled time based on there location and the event location.
Database
- Sqlite(for simplicity use)
Schema
-
User -
- Id (UUID, primary key)
- Name (string, required)
- Email (string, required, unique)
- Password_hash (string, required)
- location (string, required)
-
Event
- Id (int, primary key)
- Title (string, required)
- Description (string, required)
- Location (string, required)
- Deleted (bool, required)
- DueDate (string, required)
- User_id (string, required, foreign key)
-
User Event Association (Many to Many) - this table will hold the notifyed users to the event
- User_id (string, required, foreign key, primary key)
- Event_id (Integer, required, foreign key, primary key)
API EndPoints
-
GET /events (Optional: ?['location' = String, 'sort_by' = Enum('date'/'popularity'/'creation' ) ])
-
GET /events/{id} - returns a single event
-
POST /events - create a new event (Auth)
-
PUT /events/{id} - update an event (Auth + authorized)
-
DELETE /events/{id} - (Soft)delete an event (Auth + authorized)
-
GET /user - returns all users
-
GET /user/{id} - returns a single user
-
POST /user - create a new user (Auth)
-
PUT /user/{id} - update an user (Auth + authorized)
-
DELETE /user/{id} - (Soft)delete an user (Auth + authorized)
Application init flow
- init schaduler
- run the flask app
how to run?
- pip install -r requirements.txt
- flask db upgrade
- flask run