This is a Flask-based web application for managing users, research papers, and authors. It includes features for user sign-up, sign-in, profile management, adding and listing research papers, and adding new authors.
- Python 3.x
- pip (Python package installer)
- pip install flask-swagger-ui
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
-
On Windows:
venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
-
-
Install the dependencies:
pip install -r requirements.txt
-
Create the database and tables:
python create_db.py
-
Populate the database with sample data:
python populate_db.py
-
Start the Flask app:
python app.py
-
Access the application:
Open your web browser and go to
http://127.0.0.1:5000
.
-
Sign Up:
POST /api/signup
Request Body:
{ "user_email": "string", "user_first_name": "string", "user_last_name": "string", "user_password": "string" }
Expected Response:
{ "message": "User created successfully", "token": "string" }
-
Sign In:
POST /api/signin
Request Body:
{ "user_email": "string", "user_password": "string" }
Expected Response:
{ "message": "Signed in successfully", "token": "string" }
-
Get Profile:
GET /api/profile
Headers:
Authorization: Bearer <token>
Expected Response:
{ "user_id": "integer", "user_email": "string", "user_first_name": "string", "user_last_name": "string", "user_image": "string", "user_registration_time": "string", "user_access": "string", "university": "string", "collections_paper_ids": "string" }
-
Update Profile:
PUT /api/profile
Headers:
Authorization: Bearer <token>
Request Body:
{ "user_first_name": "string", "user_last_name": "string", "user_image": "string" }
Expected Response:
{ "message": "Profile updated successfully" }
-
List Papers:
GET /api/papers
Expected Response:
[ { "paper_id": "integer", "paper_created_by_user_id": "integer", "short_paper_title": "string", "short_description": "string", "preview_image": "string", "authors": [ { "author_id": "integer", "first_name": "string", "last_name": "string", "image": "string", "website": "string" } ], "paper_pdf_link": "string" } ]
-
Get Paper by ID:
GET /api/papers/<int:paper_id>
Expected Response:
{ "paper_id": "integer", "paper_created_by_user_id": "integer", "short_paper_title": "string", "short_description": "string", "preview_image": "string", "authors": [ { "author_id": "integer", "first_name": "string", "last_name": "string", "image": "string", "website": "string" } ], "paper_pdf_link": "string", "paper_description": "string" }
-
Add Paper:
POST /api/papers
Headers:
Authorization: Bearer <token>
Request Body:
{ "short_paper_title": "string", "short_description": "string", "preview_image": "string", "authors_ids": [list of author ids], "paper_pdf_link": "string", "paper_description": "string" }
Expected Response:
{ "message": "Paper added successfully", "paper_id": "integer" }
-
Add Author:
POST /api/authors
Headers:
Authorization: Bearer <token>
Request Body:
{ "author_first_name": "string", "author_last_name": "string", "author_image": "string", "author_website": "string" }
Expected Response:
{ "message": "Author added successfully", "author_id": "integer" }
-
Get User Paper Collections:
GET /api/collections
Headers:
Authorization: Bearer <token>
Expected Response:
{ "collections_paper_ids": [integer] }
-
Get Papers from Collections:
GET /api/collections/papers
Headers:
Authorization: Bearer <token>
Expected Response:
[ { "paper_id": "integer", "paper_created_by_user_id": "integer", "short_paper_title": "string", "short_description": "string", "preview_image": "string", "authors": [ { "author_id": "integer", "first_name": "string", "last_name": "string", "image": "string", "website": "string" } ], "paper_pdf_link": "string" } ]
-
Add Paper to Collections:
POST /api/collections
Headers:
Authorization: Bearer <token>
Request Body:
{ "paper_id": "integer" }
Expected Response:
{ "message": "Paper added to collections successfully" }
-
Remove Paper from Collections:
DELETE /api/collections
Headers:
Authorization: Bearer <token>
Request Body:
{ "paper_id": "integer" }
Expected Response:
{ "message": "Paper removed from collections successfully" }
The database used in this application is bam.db
. It contains the following tables:
- Table Name:
users
- Description: Stores user information.
Column Name | Data Type | Constraints | Description |
---|---|---|---|
user_id |
INTEGER | PRIMARY KEY, AUTOINCREMENT | Unique identifier for each user. |
user_email |
TEXT | NOT NULL, UNIQUE | User's email address. |
user_first_name |
TEXT | NOT NULL | User's first name. |
user_last_name |
TEXT | NOT NULL | User's last name. |
user_password |
TEXT | NOT NULL | User's hashed password. |
user_image |
TEXT | URL or path to user's profile image. | |
user_registration_time |
TIMESTAMP | DEFAULT CURRENT_TIMESTAMP | Timestamp of user registration. |
user_access |
TEXT | CHECK(user_access IN ('user', 'team', 'admin')), NOT NULL | User's access level (user, team, admin). |
university |
TEXT | Name of the university the user is associated with. | |
collections_paper_ids |
TEXT | Comma-separated list of paper IDs in the user's collection. |
- Table Name:
research_papers
- Description: Stores information about research papers.
Column Name | Data Type | Constraints | Description |
---|---|---|---|
paper_id |
INTEGER | PRIMARY KEY, AUTOINCREMENT | Unique identifier for each paper. |
paper_created_by_user_id |
INTEGER | NOT NULL, FOREIGN KEY REFERENCES users(user_id) |
User who created the paper. |
short_paper_title |
TEXT | NOT NULL | Short title of the paper. |
short_description |
TEXT | NOT NULL | Short description of the paper. |
preview_image |
TEXT | URL or path to the paper's preview image. | |
authors_ids |
TEXT | NOT NULL | Comma-separated list of author IDs. |
paper_pdf_link |
TEXT | NOT NULL | URL link to the paper's PDF. |
paper_description |
TEXT | NOT NULL | Full description of the paper. |
- Table Name:
authors
- Description: Stores information about authors.
Column Name | Data Type | Constraints | Description |
---|---|---|---|
author_id |
INTEGER | PRIMARY KEY, AUTOINCREMENT | Unique identifier for each author. |
author_first_name |
TEXT | NOT NULL | Author's first name. |
author_last_name |
TEXT | NOT NULL | Author's last name. |
author_image |
TEXT | URL or path to author's image. | |
author_website |
TEXT | URL to the author's personal website. |
- Vercel URL: https://bam-backend-git-main-params-projects-b290fccc.vercel.app/
- Pythonanywhere URL: https://buildingamind.pythonanywhere.com/
- Ensure that
user_email
is unique in theusers
table. paper_created_by_user_id
inresearch_papers
referencesuser_id
in theusers
table.authors_ids
inresearch_papers
is a comma-separated list ofauthor_id
values from theauthors
table.
- Ensure that you update the
SECRET_KEY
inapp.py
to a secure value. - Replace
<repository-url>
and<repository-directory>
with the actual URL and directory name of your repository.
- Add Publication date to the research papers table
- Add update paper method.
- Write and endpoint to delete an existing user.
- Write test for each endpopint in postman.
- Update the documentation in readme file.