Full Stack Frameworks with Django - Milestone Project: Toys under the Sun
Toys๐ฎ under the Sun๐ is an e-commerce website for users to search, review and purchase toys meant for young kids to teenagers globally. It helps to make the users buying experience easy by letting them read and write reviews of these toys before deciding on the purchase.
The sample user login:
ID: happyuser | Password: Manytoys123 |
---|
The administrator login:
ID: toys | Password: first |
---|
UX
The web application is meant to be easy to manoeuvre for the user or customer to find toys easily, read reviews to determine if it is the right toy for them, add to shopping cart and purchase them. The customer will need to create a user login to either write a review on a toy or make a purchase!
On the other hand, it should also allow the administrator to add, edit and delete toy products from this online catalog.
UI
Colour
The main colours used in the site are blue, white, and yellow.
Font
Cursive fonts that are more playful like Bangers and Caveat to highlight certain key points.
Sans-serif font, Quicksand, which allows easy reading of chunky text.
Wireframe
The wireframe for the home page can be found here. The overall idea is to make the web application user-friendly and intuitive to navigate:
- Navbar on top with all the links related to the products (Toys) and product reviews on the left, and links related to the user and shopping cart on the right.
- The middle section of the site will show the advanced search criteria and/ or to display the search results or entries.
- The footer of the site has links similar to the navbar
User Stories
Users' goals:
- To find out about the latest toys using the search form (able to search by name, age group suitable to play, country of origin and category)
- To read reviews of toys and even write / edit reviews
- To make purchases of toys
Site owners' goals:
- Earn income from the sale of toys (ecommerce)
- Increase brand awareness
- Track customer information โ understand the buyers trends to decide what kind of Toy items to bring in and roll out, and capture more sales
- Authentication and authorisation
- to allow new users to sign up, verify their email address etc.
- to track purchase / order history
- to add/edit/delete product item and information
Features
- Navbar links to all pages on the site โ Toy (Home page), Review and Cart (Shopping cart to lead to checkout)
- Under the Toy / Homepage and after the user searches based on the criteria, upon clicking on the image or name on the card (search display result), it will lead to the individual Toy product page showing its features, price, country of origin, and reviews given by users that have signed up an account.
- Under the Review tab, it shows all the reviews written by user who has signed in. Only the user who has created the review is able to edit and delete it.
- Toy items can be 'purchased' by the user by allowing the user to add, remove items from his shopping cart, view the total amount of the purchase, and proceed to the checkout page to enter his credit card details for successful payment.
- Only the Administrator of the site is able to create, edit and delete Toy details. These features are only seen and made available to the Administrator.
- In the Django Admin panel, the administrator is able to view all the Purchase instances (order history of all the users) to keep track of sales and orders.
- In the Django Admin panel, the administrator has the authority to edit user's details such as password or verify their email addresses.
- In the Django Admin panel, the administrator can also add, edit and delete the Toy and Review.
- Flash messages โ to prompt the user on whether certain actions are successfully or unsuccessfully completed. E.g. edited successfully to Cart or deleted successfully
- Footer consists all the links in navbar for user to quickly navigate around the site.
- Mobile responsive โ when device and screen size changes, the elements in the site change to optimize the user's viewing experience.
Features that can be improved / Future Developments
- Navbar to have a dropdown that leads the user to different Toy categories without needing to use the search form. To make the search form more concise, taking up less space.
- Have a banner carousell right below the navbar to allow users to read what the site is about, the latest trends and ongoing promotions
- At Product Creation and Editing page, to dynamically generate additional input fields and to have HTML tags to style the inputs
- To create a User app with User model โ a personal acccount tab for user to access Purchase/ Order history and to enter Shipping details for ordered items to be shipped to him directly.
- To have superuser account creation by having a Superuser app with Superuser model for some toy retailers to list and manage their items, check sales and order details on the site.
- To have additional pages in the site to describe the T&C of purchases, after sales services and shipment queries etc.
- Advanced form validation can be added to validate the fields in form submission (Add new toy or Edit toy pages)
Currently, only the Administrator is able to view Purchase model and instances of every Purchase (Purchase/Order history) in the admin panel.
- To have a User account page โ to update particulars, account details like password and email address, shipping address, check Purchase / Order history
- Order confirmation - To send out an email with the purchase details and collection/shipping details to the user with every successful payment order automatically
- Successful login user page โ to have a successful login in page and lead user back to User panel (future feature)
Technologies Used
- HTML5
- CSS3
- JavaScript
- JQuery
- Python
- Django 3.1.1
- django-allauth for user authentication
- django-crispy-forms for form styling
- dotenv
- PostgreSQL as the database
- psycopg2
- dj-database-url
- gunicorn 20.0.4
- WhiteNoise
- Stripe
- To handle checkout and payments using credit cards (test)
- Cloudinary
- store images on cloud database
- Bootstrap 4
- The project uses Bootstrap framework for basic, quick, customisable design codes and allows the site to be mobile responsive.
- Bootstrap NavBar code by Codeply
- To centralise logo in the middle of the navbar with links on each side
- Font Awesome v5.0.0
- Github icon from Font Awesome
- Am I Responsive?
- To check the mobile responsiveness of the site
- Word to markdown converter
- To convert word doc into Markdown for use in README.md
- Google Font
- Fonts used
- Favicon
- Favicon creation
- Github and GitPod
- Heroku
Programming Methodologies
- .env file stores environment variables so database credentials are hidden from public view.
Database Design
Testing
Before deployment to Heroku, the manual testing is done using the browser's Inspect tool and 8080 server to preview the site ensures that the site is mobile responsive and all content, such as buttons and links, are linked correctly and displayed on different screen sizes, namely mobile (below 480px), tablet (between 768px to 1024px) and laptop (above 1024px):
- iPad (portrait and landscape mode)
- iPad Pro (portrait and landscape mode)
- Kindle Fire (portrait and landscape mode)
- Galaxy S9/S9+
- iPhone X/XS
- iPhone 6/7/8
- iPhone 5/SE
- Pixel 2
- Moto G4
- Surface Duo
- Galaxy Fold
These steps are repeated in the testing on major web browsers, Chrome and Firefox:
Potential issues or limitations with Product text inputs
For the text inputs such as description of the toy, product features and review writing, the verification or validation of whether the content typed is correct or no typo errors will be on the Administrator.
A few ways to present the text inputs properly and beautifully will be to allow the Administrator to type in HTML tags in the textarea so that the content can be displayed well. A future feature to be added.
Issues with User email verification
User email verification can only be done at the Django Admin panel, manually clicked verified by the Administrator. When the user email link was presented in the Gitpod terminal (local server) and clicked to open, no page was found to verify the email.
Also, when app is deployed to Django, the user signing up for a new account. The site says verification email is sent to the user's email. However, there is no actual email sent despite multiple attempts. In the Django Admin panel under Users, this new user has been registered.
Issues with Product Editing page and Cloudinary image uploader
When the administrator edits a Toy item, the Cloudinary image uploader has some issues, causing the form to need to submit twice before the Toy item is successfully updated. Secondly, in the Update Toy page, it is compulsory for an image to be uploaded before it can be submitted even though the existing image URL is still present.
Secondly, as a future development, when the Toy already has an existing image uploaded, the image URL can be stored separately and input so as not needing a new image to be uploaded again.
To sum up the Testing section, moving forward automated model testing and automated client testing can be carried out to ensure app is working well.
Deployment
Code for the project was committed to GitHub:
Github is used for version controlling and all the commits for this project found at this link:
https://github.com/Minirazs/project4_toys-under-the-sun
The site is automatically updated when new commits are pushed to the master branch from VSC or GitPod using the Source Control: Git panel on the left of the console.
- Once there are any changes made to the files, individual files are staged by clicking on the '+' sign in the Source Control: Git panel
- Enter relevant message to the changes into the bar and press Ctrl Enter to commit to GitHub
OR
- Add individual file to the next commit staging area by typing in the bash terminal:
git add <filename>
- Add changes in the working directory:
git add .
- Write a meaningful message to describe the changes:
git commit -m "<message>"
- Push initial local branch commits to the remote repository master branch:
git push -u origin master
- Push subsequent local branch commits:
git push
Deployment to Heroku via GitPod:
- Log into Heroku by typing into the bash terminal:
heroku login -i
- Create a new heroku app:
heroku create <app-name>
- Check correct remotes added:
git remote -v
- Install gunicorn:
pip3 install gunicorn
- Create a name file named " P rocfile" in the same directory as app.py
- Enter:
web gunicorn <python file name without '.py'>
- Create requirements file:
pip3 freeze --local requirements.txt
- Using bash, commit all new changes to GitHub:
git add .
thengit commit -m "message"
, and then git push to Origingit push
- Push to Heroku:
git push heroku master
On Heroku website:
- Log into Heroku dashboard, go to Settings and Config Vars to set environment variables (same as those named in .env file) under Config variables
SECRET_KEY = "<Your own key>"
CLOUDINARY_CLOUD_NAME = "<Cloudinary account name>"
CLOUDINARY_API_KEY = "<Cloudinary API key>"
CLOUDINARY_API_SECRET = "<Cloudinary secret key>"
STRIPE_PUBLISHABLE_KEY = "<Stripe publishable key>"
STRIPE_SECRET_KEY = "<Stripe secret key>"
ENDPOINT_SECRET = "<Stripe webhook endpoint signing secret>"
DATABASE_URL = "<Heroku PostgreSQL database URL>"
EMAIL_HOST_PASSWORD = "<email host password>"
EMAIL_HOST_USER = "<email address>"
TEST_EMAIL = "0"
- Open App to view the web application!
Clone repository and run the application locally on Windows
- Install the Heroku Command Line Interface (CLI) for Windows installation here: https://devcenter.heroku.com/articles/getting-started-with-python#set-up
- On Windows, start the Command Prompt (cmd.exe) and log into Heroku:
heroku login -i
- Clone repository to have a local version of the code:
git clone https://github.com/Minirazs/project4_toys-under-the-sun.git
- Change directory to local repository:
cd project4_toys-under-the-sun
- Create a new heroku app:
heroku create <APP NAME>
- If the app is already created, add heroku remote:
heroku git:remote -a <APP NAME>
- Deploy to Heroku:
git push heroku main
- Open the app:
heroku open
- Install app dependencies locally:
pip install -r requirements.txt
- In root folder, create a .env file and set the following environment variables:
export SECRET_KEY = "<Your own key>"
export CLOUDINARY_CLOUD_NAME = "<Cloudinary account name>"
export CLOUDINARY_API_KEY = "<Cloudinary API key>"
export CLOUDINARY_API_SECRET = "<Cloudinary secret key>"
export STRIPE_PUBLISHABLE_KEY = "<Stripe publishable key>"
export STRIPE_SECRET_KEY = "<Stripe secret key>"
export ENDPOINT_SECRET = "<Stripe webhook endpoint signing secret>"
export DATABASE_URL = "<Heroku PostgreSQL database URL>"
export EMAIL_HOST_PASSWORD = "<email host password>"
export EMAIL_HOST_USER = "<email address>"
export TEST_EMAIL = "0"
- Run collectstatic:
python manage.py collectstatic
and reply "yes" - Start the app locally using heroku local:
heroku local web -f Procfile.windows
- Open http://localhost:5000 with web browser and the app is running locally!
Credits
Tools & Tech used
Special thanks to the developers and tech creators for sharing freely their code and tools that are used in this site creation. ๐ค๐ They are listed in the Technologies section above.
Certain Django & Heroku Deployment steps
Special thanks and credit to Heroku Dev Center and my Coding Instructor Paul Chor for providing the Django code to some parts of the website (including cart and checkout) and the deployment steps that are shown above.
Images, Content & Logo ๐ท
- All product content including description, images and prices etc. are taken from Toy'r'us.com and copyrights belong to every toy's respective brand
This e-commerce website is created for educational purposes only.