Event-CRUD-Flask-python3-API/README.md
2024-01-09 11:27:53 +02:00

2.4 KiB

Flask-API for Managing Users and Events

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.

Flask-API - Interface

The API allows interaction through the following features:

  • Retrieval of Upcoming Events:

    • Sort by:
      • Popularity
      • Date
    • Filter by:
      • Location
  • Event Management:

    • Users can create and update events.
  • User Authentication:

    • Users can log in and out.
    • 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.

Backend Reminder System

  • Users receive reminders for upcoming events.
  • The backend sends reminders 30 minutes prior to the event, considering user and event locations.

Database Configuration

  • Database Used: SQLite (for simplicity)
  • 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):
      • User_id (string, foreign key, primary key)
      • Event_id (int, 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).

Application Initialization Flow

  • Initialize scheduler.
  • Run the Flask application.

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