This project consists of a backend and frontend that allow users to log in, view Pokémon, and add them to a list of favorite Pokémon.
- Navigate to the backend directory.
- Install the required dependencies by running
npm install
. - Make sure the
.env
file is present in the backend directory and contains the correct MongoDB connection string. - Build the project by running
npm run build
. - Start the web server by running
npm run start
. - The backend server should now be running. You can verify it by accessing
http://localhost:3000
.
For more detailed instructions, refer to the backend README.md.
- Navigate to the frontend directory.
- Install the required dependencies by running
npm install
. - Make sure the
.env
file is present in the frontend directory and contains the correct backend URL (e.g.,VITE_REACT_APP_API_URL=http://localhost:3000/
). - Build the project by running
npm run build
. - Preview the build by running
npm run preview
. - Your default web browser should open, and the application will be accessible at the URL provided by Vite (e.g.,
http://127.0.0.1:5173/
).
For more detailed instructions, refer to the frontend README.md.
Once both the backend and frontend are running, you can use the application by following these steps:
- Open the application in your browser at
http://localhost:3000
. - Enter your username and password in the login form.
- Click the "Sign In" button.
- After logging in, you will see a list of your favorite Pokémon.
- You can browse through the list to see the Pokémon you have added as favorites.
- Use the search input at the bottom of the favorite Pokémon list to search for Pokémon by name.
- As you type, a list of matching Pokémon will appear in an autocomplete dropdown.
- Click on a Pokémon in the dropdown to add it to your list of favorite Pokémon.
- The selected Pokémon will appear in your favorite Pokémon list.
- Click the "Logout" button located in the profile section.
- You will be logged out and redirected to the login screen.
You can create a new user by making a POST request to the /register
endpoint. Below are the instructions for both Postman and cURL.
- Open Postman.
- Set the request method to POST.
- Enter the URL for the register endpoint (e.g.,
http://localhost:3000/register
). - In the "Body" tab, select "raw" and "JSON" from the dropdown.
- Enter the user details in JSON format, for example:
{ "username": "newuser", "email": "newuser@example.com", "password": "password123" }
- Click "Send" to create the user.
You can also create a user using the cURL command in the terminal. Here's an example:
curl -X POST -H "Content-Type: application/json" -d '{"username": "newuser", "email": "newuser@example.com", "password": "password123"}' http://localhost:3000/register
After creating a user, a verification link will be sent to the provided email address. The user can be verified by clicking on the link or by manually making a GET request to the /verify
endpoint with the token. Below are the instructions for both manual methods.
- Open the email containing the verification link.
- Click on the link to verify the user.
- The user is now verified and can log in.
- Open Postman.
- Set the request method to GET.
- Enter the URL for the verify endpoint along with the token (e.g.,
http://localhost:3000/verify?token=YOUR_TOKEN_HERE
). - Click "Send" to verify the user.
You can also verify a user using the cURL command in the terminal. Here's an example:
curl -X GET http://localhost:3000/verify?token=YOUR_TOKEN_HERE
To enable email sending for user verification, you need to configure the following environment variables in the .env
file. These variables are used to connect to the SMTP server and define the application URL.
- MAIL_USERID: The user ID for the SMTP server.
- MAIL_PASS: The password for the SMTP server.
- MAIL_PORT: The port number used by the SMTP server.
- MAIL_SMTP: The SMTP server address.
- APP_URL: The URL of the application.
Here's an example of how to set these variables in the .env
file:
MAIL_USERID="de7428378e182e"
MAIL_PASS="b38d22432ec6fc"
MAIL_PORT=2525
MAIL_SMTP="sandbox.smtp.mailtrap.io"
APP_URL="localhost:3000"
Make sure to replace the values with your actual SMTP server credentials and application URL.
Once these variables are set, the application will be allowed to send a verification email to the user's email address when they register. The email will contain a link to verify the user's account.
Currently, email testing is being done using https://mailtrap.io/, a service that allows you to test email notifications without sending them to real users. This helps in avoiding spam and ensures that the email functionality is working correctly.