0% found this document useful (0 votes)
16 views5 pages

Crit C Development1740664594

The document outlines the development of the FootStoreInventory system, detailing key components such as inventory management, secure authentication, and transaction processing. It highlights the use of various programming languages and frameworks, including Django for backend development and MySQL for database management, along with techniques for real-time updates and secure password storage. Major functions include inventory management, sales tracking, and returns handling, ensuring efficient operations for the shoe retailer.

Uploaded by

김정준
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

Crit C Development1740664594

The document outlines the development of the FootStoreInventory system, detailing key components such as inventory management, secure authentication, and transaction processing. It highlights the use of various programming languages and frameworks, including Django for backend development and MySQL for database management, along with techniques for real-time updates and secure password storage. Major functions include inventory management, sales tracking, and returns handling, ensuring efficient operations for the shoe retailer.

Uploaded by

김정준
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Criteria C: Development of the Product

Code Snippet 1: Inventory Update Function

python

def update_inventory(shoe_id, quantity):


shoe = Shoe.objects.get(id=shoe_id)
shoe.quantity -= quantity # Decrease stock on sale
shoe.save()

Explanation: This Django view function retrieves the shoe record, updates its

quantity, and saves changes to the database.

Secure Authentication

Code Snippet 2: Password Hashing

python
import bcrypt
hashed_pw = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())

Explanation: Uses bcrypt to hash passwords before storing them in the

database.

SQL Scripts

sql
-- Create 'shoes' table
CREATE TABLE shoes (
shoe_id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
size DECIMAL(4,1) NOT NULL
);
-- Foreign key in 'transactions'
ALTER TABLE transactions ADD FOREIGN KEY (shoe_id) REFERENCES sho
es(shoe_id);

Techniques Used

In the development of the FootStoreInventory system, several key techniques were


employed to ensure functionality, usability, and security. These techniques include
algorithmic thinking, appropriate data structures, the use of software tools, and the
design of the user interface (UI). The major components of the product were
developed using various programming languages, frameworks, and tools:

1. Frontend Development (HTML, CSS, JavaScript):


o HTML and CSS were used to structure and style the user interface,
ensuring it is intuitive and responsive.
o JavaScript was used to enhance the interactivity of the website,
including form validations and real-time updates of inventory details.
2. Backend Development (Django):
o Django, a Python web framework, was chosen to manage the server-
side logic, handling data processing, user authentication, and managing
database queries.
o Django’s ORM (Object-Relational Mapping) allows efficient database
operations without writing raw SQL queries, reducing complexity and
improving code maintainability.
3. Database Management (MySQL):
o MySQL was used as the relational database system to store shoe
inventory, transaction records, and user information. This choice
ensures the system is able to handle a growing dataset while
maintaining integrity through relationships (e.g., between shoes and
transactions).
4. Version Control and Code Repositories (GitHub):
o GitHub was used to store and version control the source code, allowing
for easy collaboration and tracking of changes over time.
5. Security and Authentication:
o Passwords are hashed using a secure method before being stored in the
database. This ensures that sensitive user information is kept safe.
o User roles (admin and staff) are defined in the database to control
access to specific parts of the system, ensuring appropriate permissions
for different users.
6. Payment Integration:
o Payment gateways such as PayPal, Stripe, or Square were integrated to
handle financial transactions securely.
7. User Interface Prototypes:
o Wireframing software was used to create initial prototypes of the user
interface to ensure that the design would be user-friendly and meet the
needs of Jason, the shoe retailer.

Areas of Complexity

Several aspects of the FootStoreInventory system present significant complexity and


innovative solutions. These include:

1. Real-time Inventory Updates:


o When a sale or return is processed, the inventory is updated in real-
time. This prevents errors like over-selling or incorrect stock levels,
which were previously caused by using paper templates.
o The algorithm responsible for updating the inventory is triggered by a
transaction, ensuring accurate stock levels. This feature integrates
directly with the backend and uses MySQL queries to reflect changes
in the database immediately.
2. Secure User Authentication:
o The system employs hashed passwords to secure user login
information. The hash is stored in the database rather than the plaintext
password, ensuring that sensitive data is protected.
o This algorithm uses the Python bcrypt library for hashing passwords,
ensuring that even if the database is compromised, passwords cannot
be easily recovered.
3. Transaction Management:
o The system handles both sales and returns transactions. When a sale
occurs, the inventory is decreased, and when a return is processed, the
stock is updated accordingly. The system maintains an accurate record
of these transactions with timestamps and detailed shoe information.
o The algorithm for processing returns is designed to find the
corresponding sale record and update the stock by adding the return
quantity. If no matching sale record is found, the system generates an
error message, preventing incorrect transactions.
4. Search Algorithm:
o A real-time search algorithm is implemented to allow Jason to quickly
locate shoes by ID or name. This search is optimized to perform
efficiently even as the inventory grows, ensuring quick access to shoe
details and reducing time spent on stock management.
Explanation of Areas of Complexity

1. Real-Time Inventory Update Algorithm:


o This algorithm involves adjusting the inventory based on transaction
events (sales or returns). For a sale, the algorithm decrements the
stock, and for a return, it increments the stock. The algorithm is
implemented in the Django views and uses SQL queries to update the
database. This ensures that inventory levels are always accurate, even
as transactions are processed.
o Code Screenshot:
o def update_inventory(shoe_id, quantity):
o shoe = Shoe.objects.get(id=shoe_id)
o shoe.quantity -= quantity
o shoe.save()

This function checks the shoe's current quantity, updates it based on the
transaction (sale or return), and saves the updated information.

2. Secure Password Storage:


o The logic for secure password hashing uses the bcrypt library. It
ensures that passwords are not stored in plain text and provides an
additional layer of security by making password hashes
computationally expensive to crack.
o Code Screenshot:

import bcrypt
hashed_password = bcrypt.hashpw(user_password.encode('utf-8'), bcrypt.gensalt())

This snippet demonstrates how the password is hashed before storing it in the
database, ensuring that user credentials are safely protected.

3. Transaction Processing (Sales and Returns):


o The processReturn function ensures that returns are handled correctly
by first checking the sale record. If the sale record exists, the stock is
updated, and the return is logged; otherwise, an error message is
returned.
o Code Screenshot:
4. def processReturn(saleID, shoeID, returnQuantity):
5. sale_record = Sale.objects.get(id=saleID)
6. if sale_record:
7. shoe = Shoe.objects.get(id=shoeID)
8. shoe.quantity += returnQuantity
9. shoe.save()
10. return "Return processed successfully"
11. else:
12. return "Sale record not found"

This algorithm ensures that the stock is updated accurately when a return is
processed, preventing errors in inventory records.

Showcase of Major Functions

The major functions of the FootStoreInventory system include:

1. Inventory Management: Allows for adding, editing, and deleting shoe


entries, with real-time updates to stock.
2. Sales Recording: Tracks every sale, updating the inventory automatically.
3. Returns Handling: Ensures accurate stock updates when items are returned.
4. Reporting: Provides sales and inventory reports, helping Jason track best-
selling shoes and manage stock levels more effectively.

Bibliography

1. Django Documentation: https://docs.djangoproject.com/en/stable/


2. MySQL Documentation: https://dev.mysql.com/doc/
3. Bcrypt Python Library: https://pypi.org/project/bcrypt/
4. W3Schools HTML, CSS, and JavaScript Tutorials:
https://www.w3schools.com/

Appendix: Full source code of the system is included, with detailed comments
explaining the functionality of each section of the code.

You might also like