This is a backend application for a Twitter-like platform, built using Flask and SQLAlchemy. The backend provides essential functionalities such as user registration, tweet creation, user profiles, and moderation actions.
-
User Registration: Allows users to register with unique usernames, bio, and passwords.
-
User Login: Allows users to login.
-
User Authentication: Secures endpoints with JWT-based authentication, ensuring user data remains private.
-
Tweet Creation: Enables users to create tweets with a character limit of 150.
-
User Profiles: Provides user profiles displaying basic information, following status, and their tweets.
-
Follow System: Allows users to follow and unfollow each other.
-
Moderation Actions: Moderators can suspend users, flag tweets as spam, and perform other administrative actions.
-
Clone the repository:
git clone https://github.com/RevoU-FSSE-2/Assignment-RPrasetyoB.git
-
Install dependencies:
pip install pipenv
pipenv shell
pipenv install
-
Run the application:
flask run
https://documenter.getpostman.com/view/29092304/2s9YeD7sxj
week21.postman_collection.json - Google Drive
Methods | Endpoint | Requirement & Authorization | Body | |
---|---|---|---|---|
Register | POST | /auth/registration | - | username, bio, password |
Login | POST | /auth/login | user is_suspended? | username, password |
Create Tweet | POST | /tweet | bearer_token, user is_suspended? | tweet |
User Profile | GET | /user-profile | bearer_token | - |
Follow | POST | /following/:target_user.id | bearer_token | - |
Flag spam | POST | /moderation/tweet | bearer_token, moderator role | tweet.id, is_spam |
Suspend user | POST | /moderation/user | bearer_token, moderator role | user.id, is_suspended |
- Suspended user in database:
- Suspended user cannot login:
- If suspended user have last login token and still not expired, user still cannot create tweet:
- Flag Spam tweets in database:
- Moderator
{
"username":"rpb",
"password":"rpb123"
}
- User
{
"username":"rpb2",
"password":"rpb123"
}
{
"username":"rpb3",
"password":"rpb123"
}