better README.md

This commit is contained in:
Kfir Dayan 2024-01-09 11:27:53 +02:00
parent 0c7f0f4ca4
commit 2a092e1eb2

104
README.md
View file

@ -1,43 +1,45 @@
### Flask-API managing Users And Events # Flask-API for Managing Users and Events
A RESTful API that manages events, offering users the ability to schedule, retrieve, This Flask-based RESTful API provides functionality for managing and interacting with events. It offers users the capability to schedule, retrieve, update, and delete events. Additionally, it features user authentication and event reminders.
update, delete, and be reminded of events with additional advanced features.
# Flask-API - Interface ## Flask-API - Interface
- The User Will be able to retrieve upcomming event/s The API allows interaction through the following features:
- sort by
- popularity
- date
- filter by:
- location
- 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: - **Retrieval of Upcoming Events:**
- (Auth Users) An event is an upcomming Party/Concert/Sport event/etc. It is tied to a user that created this event. - Sort by:
- Popularity
- Date
- Filter by:
- Location
- Authentication: - **Event Management:**
- The User will be able to login: - Users can create and update events.
- 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.
# Backend-reminder - **User Authentication:**
- The Users will be able to be reminded of upcoming events. - Users can log in and out.
- The backend will Send reminders 30 minutes before the event's scheduled time based on there location and the event location. - Anonymous users can register.
- **Event Details:**
- Events include parties, concerts, sports events, etc., and are linked to the user who created them.
- **Authentication Mechanism:**
- Logging in generates a JWT token stored in the Flask session.
- The JWT token is returned in the response cookie header.
# Database ## Backend Reminder System
- Sqlite(for simplicity use) - Users receive reminders for upcoming events.
# Schema - The backend sends reminders 30 minutes prior to the event, considering user and event locations.
- User -
## Database Configuration
- **Database Used:** SQLite (for simplicity)
- **Schema:**
- `User`:
- Id (UUID, primary key) - Id (UUID, primary key)
- Name (string, required) - Name (string, required)
- Email (string, required, unique) - Email (string, required, unique)
- Password_hash (string, required) - Password_hash (string, required)
- location (string, required) - Location (string, required)
- Event - `Event`:
- Id (int, primary key) - Id (int, primary key)
- Title (string, required) - Title (string, required)
- Description (string, required) - Description (string, required)
@ -45,35 +47,23 @@ update, delete, and be reminded of events with additional advanced features.
- Deleted (bool, required) - Deleted (bool, required)
- DueDate (string, required) - DueDate (string, required)
- User_id (string, required, foreign key) - User_id (string, required, foreign key)
- `User Event Association` (Many-to-Many):
- User Event Association (Many to Many) - this table will hold the notifyed users to the event - User_id (string, foreign key, primary key)
- User_id (string, required, foreign key, primary key) - Event_id (int, foreign key, primary key)
- Event_id (Integer, required, foreign key, primary key)
## API Endpoints
- `GET /events` (Optional: `location`, `sort_by` (date/popularity/creation))
- `GET /events/{id}` - Retrieve a single event
- `POST /events` - Create a new event (Auth required)
- `PUT /events/{id}` - Update an event (Auth + authorization required)
- `DELETE /events/{id}` - Soft delete an event (Auth + authorization required)
- User management endpoints (`/user`), including creation, retrieval, update, and deletion (with appropriate authentication and authorization).
# API EndPoints ## Application Initialization Flow
- GET /events (Optional: ?['location' = String, 'sort_by' = Enum('date'/'popularity'/'creation' ) ]) - Initialize scheduler.
- GET /events/{id} - returns a single event - Run the Flask application.
- 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
- 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
## How to Run?
1. Install dependencies: `pip install -r requirements.txt`
2. Upgrade the database: `flask db upgrade`
3. Start the Flask application: `flask run`