A comprehensive inventory management system supporting dark/light modes and English/Chinese locales. Built with Vite and Vue3 on the frontend using Ant Design and Tabulator-table, and Python Django REST framework with MySQL and Django ORM on the backend. Ensures database transactions adhere to ACID properties.
class LocaleRegion(models.Model):
name = models.CharField(max_length=255)
# HK,ZH,EN
code = models.CharField(max_length=255)
value = models.IntegerField()
class Meta:
db_table = "system_locale_region"
class LocaleData(models.Model):
key_word = models.CharField(max_length=254, unique=True)
value1 = models.CharField(max_length=255)
value2 = models.CharField(max_length=255)
class Meta:
db_table = "system_locale_data"
# /api/v1/locales/?lang=en
class LocalesProcessor(generics.GenericAPIView):
def get(self, request):
getLanguageCode = request.GET.get("lang", None)
locales = {}
languageModel = LocaleRegion.objects.get(code="en-US")
# Check if request language code exist in Locales
if LocaleRegion.objects.filter(code=getLanguageCode).exists():
# Get the language code
languageModel = LocaleRegion.objects.get(code=getLanguageCode)
# Get all the LocalesWords
for o in LocaleData.objects.all():
# Get the language code
keyName = "value" + str(languageModel.value)
locales[o.key_word] = getattr(o, keyName)
return Response(data={"details": locales})
Excel Import Optimization: Initially used pandas to loop through Excel data, which was slow due to serializer validations. Optimized by using Django ORM's bulk upload, processing all Excel data in one loop, extracting features into a set, updating them first, and matching by ID back to main data, significantly improving data processing speed.
Stock Out Page Performance: Using Ant Design forms caused high RAM usage on low-spec mobile scanners, leading to page freezes. Learned that looped components should use simple elements instead of heavy UI framework components to reduce overhead. Implemented a TypeScript check to render simple HTML elements on mobile screens and Ant Design rich pages on larger screens. This experience led to exploring lighter UI frameworks like TailwindCSS.