PageTalk (Backend)

GitHub (MySQL Version)

GitHub (MongoDB Version)

Welcome to the backend of the PageTalk project. PageTalk allows users to upload PDFs and receive summaries, along with query-based responses.

Tech Stack:

Technologies Used:

Tables:

  1. Users
  2. Query
  3. PDF
  4. Admin
  5. Collection
  6. Interaction

Routes:

Try it yourself:

  1. Clone the repository:
    git clone https://github.com/PageTalk/Backend.git
  2. Configure your environment variables as in the .env.example file
  3. Configure the docker-compose file on your end
  4. Open a terminal, CD to this folder, and run
    docker-compose up -d
  5. Start the docker container, then create the tables as mentioned in the database/init.sql file.
  6. Run
    npm start
  7. Your application is now running.

Database Diagram:

Database Diagram

Starting

Start the docker container, then run

docker exec -it pagetalk-mysql-container bash

To start a MySQL server, run

mysql -u root -p

Enter password: 1234

Troubleshooting

In case of SQL Connection error

Run the following command in the MySQL server

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';

Note: Server is running on port 3306 so add the port to the dbconfig while creating a connection.

If connection still fails

If the connection still fails, go into the MySQL Container files, look for etc/my.cnf config file, and set port to 3306.

// my.cnf ---- previous code port=3306 ---- rest of the code

How JWT Works

JWT Working Showcase

How JWT is used

JWT Usage Example

Credits: GeeksForGeeks

How to use JWT

  1. User sends a POST request to the server with username and password
  2. Server checks if the username and password are correct
  3. If correct, the server creates a JWT token and sends it back to the user
  4. User stores the JWT token in the local storage
  5. User sends the JWT token in the header of every request
  6. Server checks if the JWT token is valid
  7. If valid, the server sends the response back to the user