- Introduction
- System Requirements
- Configuration
- Installation
- Testing
- Running the Application
- API Endpoints
- Authentication Flow
- Cart Functionality
- Features Implemented
- Project Milestones
Welcome to the user manual for the Demo Store application. This manual provides step-by-step instructions on how to download, install, configure, run, and test the application. The Demo Store application is a minimal full-stack application built with Node.js, Express, Sequelize, React, and Vite.
Before proceeding with the installation, make sure you have the following system requirements:
- Node.js (version 14 or higher)
- npm (version 6 or higher)
- PostgreSQL (version 12 or higher)
- Git
Before running the application, you need to configure the database connection. Follow these steps:
-
Create a
.envfile in the root directory of the project. -
Add the following environment variables to the
.envfile. Check “.env.example” for example and insert your actual credentials.
Follow these steps to install the Demo Store application:
- Clone the repository from GitHub:
git clone https://github.com/antonovmike/demo_store.git
cd demo_store- Install the backend dependencies:
cd server
npm install- Install the frontend dependencies:
cd client
npm install- Initialize the database: Create a new datebase:
sudo -u postgres psql
CREATE DATABASE demo_store;
CREATE DATABASE demo_store_test;cd server
npm run db:migrate
npm run db:seed:allThe command npm run db:seed:all will create in the “Users” table: a user with the username "admin" password "admin" and email "admin@demostore.com"; a user with the username "editor" password "editor" and email "editor@demostore.com".
To run the tests, follow these steps:
- Run server tests then client tests in sequence:
npm test- Run server tests:
npm run test:root- Run the client tests:
npm run test:clientTo run the application, follow these steps:
- Start the backend:
cd server
npm run dev- Open a new terminal window. Start the frontend:
cd client
npm run devThe Demo Store application provides the following API endpoints:
Check the basic server response.
Request:
curl http://127.0.0.1:3000/pingResponse:
"pong"Simple hello endpoint.
Request:
curl http://127.0.0.1:3000/helloResponse:
"Hello"Check server health and uptime.
Request:
curl http://127.0.0.1:3000/statusResponse:
{
"status": "ok",
"uptime": "123.45"
}Follow these steps to perform the authentication flow:
- Register a new user:
- Open the frontend application in your web browser.
- Navigate to the "Register" page.
- Fill in the registration form with your details.
- Click the "Register" button.
- Login to receive a JWT token:
- Navigate to the "Login" page.
- Fill in the login form with your credentials.
- Click the "Login" button.
- Profile page fetches user info from /users/me:
- After successful login, the user is redirected to the profile page.
- The profile page fetches the user's information from the
/users/meendpoint.
- Token is stored in localStorage and sent with each request automatically.
Follow these steps to use the cart functionality:
- Add products to the cart:
- Navigate to the "Products" page.
- Select the products you want to add to the cart.
- Click the "Add to Cart" button.
- Cart data persists via localStorage:
- The cart data is stored in the browser's localStorage, so it will persist even if you refresh the page.
- Edit quantity or remove items:
- Navigate to the "Cart" page.
- Modify the quantity of the items in the cart or remove items as needed.
- The total amount will be dynamically updated.
✅ User registration & login
✅ JWT authentication
✅ Protected /users/me route
✅ Product list with demo items
✅ Add to cart
✅ Cart persistence via localStorage
✅ Cart management (update, remove, clear)