This project is a REST API designed to handle task management within an organization. It provides endpoints for user registration, authentication (login/logout), and various operations related to task management.
Key Features:
- User management: Registration, login, logout, retrieval (all and single), updating, and deletion.
- Task management: Creation, retrieval, update, and deletion.
- Assignment management: Assigning and unassigning users to tasks.
- Admin privileges: Listing all users' data.
Technologies Used:
- Flask
- Flask-Smorest
- Flask-JWT-Extended
- Flask-SQLAlchemy
- PostgreSQL
- Marshmallow
Make sure you have the following software installed on your machine:
- Python (version 3.10.12)
- pip
- Clone the repository to your local machine:
git clone https://github.com/Moaaz-Mahmoud/Project-Management-API- Navigate to the project directory:
cd Project-Management-API- Install the required Python dependencies using pip:
pip install -r requirements.txt-
Ensure you have a PostgreSQL database server running. You can install PostgreSQL from here if you haven't already.
-
Create a new PostgreSQL database and keep the database URL.
-
To set up your environment variables, create a .env file in the project directory based on the .env.example file included in the repository.
DATABASE_URL=<your_database_url>
JWT_SECRET_KEY=<your_jwt_secret_key>
Create and seed the database:
flask db_create
flask db_seedOnce the database is set up and initialized, you can start the Flask application:
flask runThe application should now be running locally at http://127.0.0.1:5000/.
You can access the Swagger UI documentation for the API at http://127.0.0.1:5000/swagger-ui/. This documentation provides information about the available endpoints and how to interact with them.
To run the automated tests for the application, use the following command:
python3 -m unittest discover # Linuxpython -m unittest discover # WindowsA few requests to experiment with the API. Watch out for the placeholders!
- Register a User:
curl -X POST http://localhost:5000/register -H "Content-Type: application/json" -d '{
"name": "Meowing Cat",
"username": "meowing_cat",
"email": "cat@meows.com",
"password": "123",
"status": "ACTIVE"
}'- Log In to Obtain Access Token:
curl -X POST http://localhost:5000/login -H "Content-Type: application/json" -d '{
"username_or_email": "meowing_cat",
"password": "123"
}'- Create a Task:
curl -X POST http://localhost:5000/users/<user_id>/tasks -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{
"name": "Destroy the earphones",
"description": "Destroy the earphones for no reason.",
"due_date": "2024-01-31 07:00:00",
"status": "active"
}'- Assign the Task to the New User:
curl -X POST "http://localhost:5000/assign?user_id=<user_id>&task_id=<task_id>" -H "Authorization: Bearer <access_token>"- Retrieve a List of Your Tasks:
curl -X GET http://localhost:5000/users/<user_id>/tasks -H "Authorization: Bearer <access_token>"- Unassign the Task:
curl -X DELETE "http://localhost:5000/assign?user_id=<user_id>&task_id=<task_id>" -H "Authorization: Bearer <access_token>"- Retrieve a List of Your Tasks Again:
curl -X GET http://localhost:5000/users/<user_id>/tasks -H "Authorization: Bearer <access_token>"- Delete the Task:
curl -X DELETE http://localhost:5000/tasks/<task_id> -H "Authorization: Bearer <access_token>"- Log Out:
curl -X POST http://localhost:5000/logout -H "Authorization: Bearer <access_token>"- Attempt to Retrieve a List of Your Tasks Again:
curl -X GET http://localhost:5000/users/<user_id>/tasks -H "Authorization: Bearer <access_token>"