The goal of this full stack project is to design and implement a fully functional online e-commerce website connected to payment API Stripe, cloud storage database Cloudinary and provide a seamless user experience.
-
Hosted at https://knigi-bg.onrender.com/
https://www.youtube.com/watch?v=0UT5XTyFcRU
- ๐ฌ Technologies used
- ๐ฌ Features
- ๐ง Installation
- ๐ซ UX UI
- ๐ Project content
- ๐ Folder Structure
- ๐จ Design and Architecture
- ๐ FUTURE Development:
- ๐Fixes and updates:
| Category | Technologies |
|---|---|
| Frontend | React, TypeScript |
| Server | Node, Express, Cors, Cookie-parser, Multer,Express-Mongoose-RA-JSON-Server |
| UI | Material UI, SASS, Slick-Carousel, React-Slick, |
| Forms | React Hook Form |
| State management | Zustand |
| Admin panel manager | React Admin |
| Database | MongoDB, Mongoose |
| Encryption | bcryptjs |
| Authentication | JsonWebToken |
| API Request | Axios |
| Tools | Git, Vite, ESLint, Prettier, Yarn, Nodemon,disable-react-devtools,hookform devtools |
Here are some examples of how to use this project:
- Register and login as a user
- Browse products in the catalog page
- Filter and sort the products (not fully implemented)
- Add and manage items to the cart
- Add and manage items to the wishlist
- Check each product details in the Details Page, where only authenticated users can comment, add products to cart or wishlist.
- Manage application data from the admin panel only for admins
- Checkout your cart and pay
- Preview order
- Manage profile settings
- Check order history and details
Follow the instructions below:
-
Clone the repository
git clone https://github.com/batanoffs/e-books.git
-
Navigate to the project directory:
cd your-project-directory -
Install dependencies for the server and the client:
./cd client && yarn install./cd server && yarn install -
The application should start automatically because of the
vscode configfile. -
If it does not, you can manually run the development server and the client cd to the main directory and:
./cd server && yarn run start-server./cd client && yarn run dev -
Open your browser and go to http://localhost:5173/ to view the app.
-
Register a new account and login
-
Logo creation and design are loosely done with www.excalidraw.com.
- Home page
- Login Register
- Catalog
- Product details
- Cart details
- Wishlist
- Checkout
- Stipe payment page
- Order preview
- Profile menu
- Orders history
- Admin panel
Server built on express and mongodb with mongoose. Client built with vite, react, typescript and sass.
-
-
Alert Store - a helper store that provides state if the alert is open or not and what is the alert message.
-
Cart Store - stores and provides data for the cart of the authenticated user.
-
Categories Store - stores and provides data for categories in the catalog.
-
Filter Store - provides and stores data for the filter section in the catalog page (not yet implemented)
-
Modal Store - a helper store that provides state if the modal is open or not
-
Location Store - a helper store that provides state for
window.location.pathnameused for better UX and site navigation -
User Data Store - holds information about the currently authenticated user. It provides getters and setters for the user's data, including the user's username, whether the user is logged in, and whether the user is an admin.
-
Wishlist Store - stores and provides data for the wishlist of the authenticated user.
-
-
- useConfirm() - is a hook that opens modal to ask the user for confirmation of his action.
-
- Main Router is located in
Appcomponent
- Main Router is located in
-
-
Constants
- api.ts - stores base URL and endpoints to be used in all services
- location.ts - stores array of regions and countries to be used in the location dropdown
-
Helpers
- getToken() - gets user token
- getUserRole() - gets user role
- getUserId() - gets user id
- checkIfUserIsAdmin() - checks if user is admin
- isAuth() - checks if user is authenticated
- isGuest() - checks if user is not authenticated
- themeOptions -* provides theme options for the MUI* theme
- formatDate(date) - formats the date
- currencyFormatterToBGN(value) - formats the value to BGN currency
-
-
- authService for Authentication
- cartService for handling cart data
- productService for handling products data (todo)
-
- express.ts - contains express middleware
- database.ts - contains mongoose middleware
- routes.ts - contains express routes
-
Model Fields Book, Textbook id,title,author,price,description,picture,coverPageType,stock,categories,publisher,language,publishDate,pageCount,translator,dimensions,createdAt,BookCategories id,nameCart id,products,modifiedAt,activeFeatured productId,productType,featuredAtOrder id,userId,products[{productId, productType, quantity}],total,orderStatus,shippingStatusStationery id,title,price,description,picture,categories,stock,createdAtStationeryCategories id,nameTextbookCategories id,nameUser id,email,password,register_date,roleWishlist id,user,productRefs -
Name Route url Description Main /api/**Main router that combines all routes under /apiAdmin /api/admin/**Admin router combining all routes for management of products, categories, users, orders, featured etc. /users|/categories/books|/categories/textbooks|/categories/stationery|/stationery|/books|/textbooks|/featured|/ordersAuth /api/Authentication for register|login|logoutBook /api/books/**Available routes to get all /, get by id/:idand/uploada product image to Cloudinary/uploadCart /api/cart/**Available routes for POST, GET and DELETE - /to add or remove product from cart,/:userIdto get cart by userId,/:productIdto remove product from cartCategories /api/categories/**Available routes /to get all categories for each type. And for each type/books/,/textbooks/and/stationery/to get all or post a new one.Order /api/orders/**Available routes /to get all,/:idto get/update one by id or delete routesStationery /api/stationery/**Available routes to get all /, get by id/:idand/uploada product image to Cloudinary/uploadCheckout /api/checkout/**For the checkout and payment I use Stripe to create a new session /create-checkout-sessionand retrieve it/session-statusTextbook /api/textbooksAvailable routes to get all /, get by id/:idand/uploada product image to Cloudinary/uploadUser /api/userAvailable routes /verify-userto get user by token,/:idto get, update or delete a user by idWishlist /api/wishlistGET, POST, DELETE a list of products from wishlist. Available routes /to get all or create and update one,/:productIdto delete one by id -
- auth - authenticating the users. Contains logic for
login,registerandlogout - book - handling products of type books. Contains logic for delete, update, create, get all or get one book
- cart - handling cart data. Contains logic for
addToCart,getCart,removeProductFromCart,clearCart - categories - handling categories data, contains logic for
addCategoryandgetAllcategories of every type. - featured - handling featured data, contains logic
getFeaturedProducts,markAsFeatured,removeFromFeatured - images - handling image uploads to Cloudinary. Contains logic
uploadCoverImage - order - handling order data, contains logic
createOrder,getOrderById,getOrders,updateOrderStatus,deleteOrder - stationery - handling stationery data, contains logic
createStationery,getStationeries,updateStationery,deleteStationery - textbook - handling textbook data, contains logic
createTextbook,getTextbooks,updateTextbook,deleteTextbook - stripe - handling payment data, contains logic
checkoutSession - user - handling user data, contains logic
getUsers,getUserByIdFromToken,getUserById,updateUser,deleteUser - wishlist(todo) - handling wishlist data, contains logic
createWishlist,getWishlist,updateWishlist,deleteWishlist
- auth - authenticating the users. Contains logic for
-
- user - Authentication (register, login, logout)
- jwt - creating and verifying tokens
- image - uploading image to
Cloudinary
-
- cors - cors setup for the express server
- filters - to be updated (todo), contains logic for catalog filters and sorting
- guards - isUser, isAdmin, isGuest - checks if user is authenticated and roles
- multer - for file upload
- session - validates the session. If token is present, sets the user in the request object
- validateRequest - validates the requests
-
- getCategoryModel(categoryType) - returns the category model based on the category type.
- cloudinaryConfig() - returns the configuration for
Cloudinary. - errorHandler(error, res) - handles errors in the server.
- parseError(error) - takes in an
errorobject and returns a new error object with a consistent structure. It is designed to handle different types of errors that can occur in an application.
- Update the featured logic based on model and integrate it with admin panel
- Research and integrate
SpeedyandEcontAPIs for delivery - Research and integrate location API of some sort for smooth user experience
- Create pages mentioned in the footer common questions about etc
- Maybe add blog articles functionality
- Implement vouchers and promotions discounts etc.
- Implement testing unit with
ViTest,Playwright. Discuss coverage - Create search logic
- Research and implement forgotten password logic
- Decide on how much material ui components will be used (performance issues)
- Redesign/discuss business logic for buy now button and authentication
- fix issues with session expire and users
- fix issues with cookies token for admins validation
- fix server duplicate code - replace with already created utils
- fix css warnings (low priority)
- fix issues with catalog items hover buttons
- fix issues with Menu component from Material UI for anchorEl property
- update cart logic and think about state management issues for items and quantity
- update carousels functionality buttons etc
- update theme and reuseable code for scss and maybe react
- implement filters for Catalog Page
- update logic for checkout page
- add property
productTypeto each type of products
