This project involved building a fully functioning e-commerce application REST API. Users can perform various operations such as registering and logging into an account, browsing products, adding products to cart and viewing/placing orders.
This project is part of Codecademy's Full-Stack Engineer career path.
To run the app locally, run npm install
, then npm run start
in the project directory.
This project requires you have a PostgreSQL database to run locally. Reference the ERD (Entity Relationship Diagram) in the resources
folder to view the structure of the tables. You can use pgAdmin or Postbird to interact with the database manually.
After installation, you will need to add your environment variables in a .env
file. This repo includes an example.env
file that contains all the environment variables for reference. Make sure to replace the example values with those specific to your environment.
To easily populate your database with the requisite tables, npm run create-db
. This will create tables in your database if they do not already exist. The configuration for this script can be found in the setupDatabase.js
file located in the db
folder.
Note Running npm run create-db
will only create the tables and not the database itself. Once you have downloaded the Postgres GUI client of your choice, you will need to manually create a database first before running the npm run create-db
command.
Here is a list of the environment variables and their function:
PGUSER
: User's Postgres usernamePGHOST
: Database hostnamePGPASSWORD
: User's Postgres passwordPGDATABASE
: Name of the databasePGPORT
: Postgres port numberSESSION_SECRET
: Session secretPORT
: Local port number
Swagger documentation available at http://localhost:<your-port>/docs
You can use various HTTP clients such as Postman or Insomnia to make requests to the API endpoints.
Note: Most endpoints are protected and require authentication. In order to properly access these endpoints, you will need to have a session cookie present when making your request. This is accessed by hitting the /auth/login
endpoint first. HTTP clients will automatically store cookies and send them with subsequent requests.
- Register an account
- Browse products
- Add products to cart
- Checkout cart
- View order history
- Node.js (v16.18.0)
- Express (v4.18.2)
- PostgreSQL (v15.2)
- Testing