πΊπΈ English |
π§π· PortuguΓͺs |
VideoΒ Β Β |Β Β Β TechnologiesΒ Β Β |Β Β Β StepsΒ Β Β |Β Β Β AboutΒ Β Β |Β Β Β PagesΒ Β Β |Β Β Β ComponentsΒ Β Β |Β Β Β CloningΒ Β Β |Β Β Β Contact
apple-store-video.mp4
If the video has any errors, reload the page!
It cannot be deployed just for copyright reasons.
Below are the 18 technologies used in the development of the project, and their reasons
NextJS |
Typescript |
Redux |
Tailwind |
ReactJS |
Stripe |
NextAuth |
Sanity.io |
HeadlessUI |
React |
React Hot |
Overlayscroll |
Vercel |
React Icons |
Random String |
Javascript |
CSS3 |
HTML5 |
46 of the current 54 steps have already been completed, but new ones could be added!
πΉ | Definition of the base structure and installation of dependencies |
πΉ | Definition of global styles |
πΉ | Search for good showcase photos |
πΉ |
Development of pages/index base
|
πΉ | Database creation and basic configuration with Sanity |
πΉ |
components/Header development
|
πΉ |
Development of components/Button inspired by DevDojo
|
πΉ |
Finalizing the structure and style of pages/index
|
πΉ | Database administration panel configuration |
πΉ | Completion of the database |
πΉ |
Development of pages/api/getCategories and pages/api/getProducts
|
πΉ |
Development of utils/fetchCategories and utils/fetchProducts
|
πΉ |
components/Product development
|
πΉ | Search for products in the database via SSR |
πΉ | Redux implementation |
πΉ | Notifications implementation |
πΉ |
components/Cart development
|
πΉ |
pages/checkout structure and style development
|
πΉ |
components/CheckoutProduct development
|
πΉ |
Grouping of duplicate products in pages/checkout
|
πΉ | Stripe implementation |
πΉ |
utils/get-stripejs and utils/api-helpers development
|
πΉ |
pages/api/checkout_sessions development
|
πΉ |
pages/success structure and style development
|
πΉ |
pages/api/getSession and utils/fetchLineProducts development
|
πΉ |
Finalization of pages/success getting the data via SSR
|
πΉ |
NextAuth implementation and pages/api/auth/[...nextauth] creation
|
πΉ | Google Cloud project creation |
πΉ | Implementation of NextAuth in Sanity |
πΉ | Database deployment |
πΉ | Project images optimization |
πΉ | Moving from Hero Icons to React Icons |
πΉ |
pages/index design and responsiveness improvement
|
πΉ |
pages/checkout responsiveness improvement
|
πΉ | License creation and project README development |
πΉ | Project SEO improvement |
πΉ |
react-currency-formatter removal (bugging)
|
πΉ |
components/Currency development
|
πΉ | Project deployment in Vercel |
πΉ | Division of Production and Development branches |
πΉ | Cross-Browser development |
πΉ | Scroll Styling |
πΉ |
pages/index responsiveness improvement
|
πΉ |
General bug fixesσ Όσ Όσ Όββββββββββββσ ΌπΉ Fixed pages/index Mobile menu with new scrollπΉ Fixed components/Cart position with new scrollπΉ Fixed the Buy button in pages/index with the new scrollπΉ Fixed Head title πΉ pages/success scroll fix πΉ Fixed validateDOMNesting error in pages/success
πΉ SEO fix
|
πΉ | Implementation of Vercel Analytics |
πΉ | Addition of my social networks |
β | Error handling improvement |
β | Customization of Toasts |
β | Project performance optimization |
β |
pages/checkout zip code search development
|
β | Storing cart products in Local Storage |
β | Search system development |
β | Pages for each product development |
β | Addition of new products and categories |
β | Apple page cloning |
β | Creation of partner products page consuming an API |
In summary, the application consists of an Apple E-Commerce, simulating a complete purchase flow, where the user can or cannot authenticate himself through his Google account through NextAuth, add and remove products from his cart with the help of Redux, simulate payment for these products through the Stripe test environment, and at the end you will be redirected to a confirmation and thank you page for the purchase. This purchase flow itself involving the products searched from the Sanity database is the main highlight of the application, but there are other very important points that can be seen in the sections below.Watching the video above and/or accessing the project online will help you understand the explanation!
I also recommend especially checking out the reasons for using NextJS, Typescript, Redux and Tailwind in the Technologies section, as my main objective with this project was to develop my autonomy with such technologies, since I am a React developer and they are a fundamental part of my ecosystem, being the main ones responsible for agility, reliability, performance and professionalism in general during the development of the application, due to its excellent resources.
But this is clear, without taking away the merit of the other technologies used, they all play a specified fundamental role with them, and contribute to the result of the project as a whole, and I will continue to learn and deepen myself a lot in these technologies and in what is necessary during the development of this application to put all my ideas into practice and fulfill all the tasks listed in the Steps section, which is a section that is also worth checking out to get an overview of the project's evolution.
pages/index
: This is the Home of the application, where the user can monitor the LogIn/LogOut, and add products to the cart. Products are searched in the database using the concept of SSR;pages/checkout
: This is the purchase review page, where the user can remove products from the cart and continue with the payment, being redirected to the Stripe test environment - a payment page;pages/success
: After filling in the data and deciding the payment on the Stripe page, the user will be redirected to this page, which is the confirmation and acceptance of the purchase.
pages/api/auth/[...nextauth]
: This is NextAuth's global settings file;pages/api/checkout_sessions
: This route is responsible for transforming the received purchase data into the format that Stripe requires, and creating a Stripe session for the user. Usage example:pages/checkout
;pages/api/getCategories
: This route is responsible for returning the product categories from the database. Usage example:utils/fetchCategories
;pages/api/getProducts
: This route is responsible for returning products from the database. Usage example:utils/fetchProducts
;pages/api/getSession
: This route is responsible for returning a session from the received id. Usage example:utils/fetchLineProducts
.
pages/_app
: This component contains global application settings, such as Redux and NextAuth contexts that involve the entire application, global styles, and toast rendering;pages/_document
: Briefly, this component contains the application's SEO settings.
components/Button
: This component is related to the button reused periodically during the application;components/Cart
: This component is related to the cart icon that appears when there is an item in the cart and the scroll is below 400;components/CheckoutProduct
: This component is related to the products shown inpages/checkout
;components/Currency
: This component is responsible for formatting prices currency;components/Header
: This component is relative to the application header;components/Product
: This component is related to the products shown inpages/index
.
redux/cartSlice
: Using Redux, this component contains the logic used to handle user interaction actions in relation to the shopping system. It exports extremely important functions, such asaddToCart
andremoveFromCart
(which are self-explanatory), and values such asselectCartProducts
(total of products in the cart), and among others, which are used periodically by the project;redux/store
: This is the Redux settings file.
utils/api-helpers
: The idea of this component is to streamline and reuse certain processes performed inpages/api
, componentizing them in this component. For now, it only exportsfetchPostJSON
, responsible for speeding up POST requests;utils/fetchCategories
: This component is responsible for speeding up the search for product categories in the database;utils/fetchProducts
: This component is responsible for speeding up the search for products in the database;utils/fetchLineProducts
: This component, working together withpages/api/getSession
, is responsible for returning products based on the sent id, and together they perform id verification and can return 404 if it is incorrect;utils/get-stripejs
: This component is responsible for initializing Stripe, using the Sigleton Pattern to not initialize it more than once.
sanity
: This is the sanity settings file. It also exportsurlFor
, a function that helps display images of products in the database;apple-store-database
: This is the project database, created using Sanity.
To clone and run this project on your computer you will need Git and Node.js v18.12.1 or higher and previously installed.
After that, in the terminal:
# Clone this repository with:
> git clone https://github.com/Luk4x/apple-store.git
# Enter the repository with:
> cd apple-store
Now being in the root of the project, create the .env.local
file, which should contain the following environment variables:
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_SANITY_DATASET=production
NEXT_PUBLIC_SANITY_PROJECT_ID=
SANITY_API_TOKEN=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=
To configure such variables, you will need to create a project in Sanity, Stripe and Google Cloud, plus you'll need to fill in the database as well.
After that:
# Install dependencies with:
> npm install
> cd apple-store-database
> npm install
# Run the project with:
> npm run dev
> cd ..
> npm run dev
# Once this is done, you will be able to access the project at: http://localhost:3000
Vitrine.Dev πͺ
|
Lucas Maciel |