Skincare-Filter-Web-Application

ARCHITECTURE.md — Skincare-Filter-Web-Application

Important Version Note: This project uses Django 6.0 and Python 3.13. All code, syntax, and conventions should follow the latest standards for these versions. (For example: use path() for URL routing, async views, and new ORM features; avoid legacy patterns from Django 4.x or earlier.)

Product Vision & Purpose

The Skincare Allergy Filter empowers users to make safer skincare choices by checking product ingredient lists against a personal allergen profile. Phase 1 delivers fast, normalized exact matching. Phase 2 — the strategic focus — replaces naive string comparison with an alias-aware Synonym Mapper so that ‘Vitamin C’, ‘L-Ascorbic Acid’, and ‘Ascorbate’ all resolve to the same allergen record regardless of how a brand labels it. Disclaimer: This tool is not a substitute for professional medical advice.

Project Summary

High-Level Architecture Overview

Main Components & Responsibilities

Core Logic: Text-to-Database Flow

Input Strategy:

Processing Pipeline:

  1. Sanitization: Clean input text (remove special characters, formatting, and whitespace).
  2. Tokenization: Split text into individual ingredient strings using comma delimiters.
  3. Normalization: Convert all tokens to lowercase and strip whitespace to ensure consistent matching (e.g., “Almond Oil” matches “almond oil”).
  4. Matching: Cross-reference normalized tokens against the UserAllergen database to determine if any allergens are present.
    • Note on Future Normalization: Plan for a “Synonym Mapper” (e.g., Vitamin C → Ascorbic Acid). The system should eventually support many-to-one aliases for ingredients.
  5. Alias Resolution (Planned — Synonym Mapper): Before matching, resolve each normalized token against a many-to-one alias table. All known surface forms of a compound (INCI name, common name, abbreviation) map to a single canonical allergen_key. This stage is deliberately separated from normalization so it can be developed, tested, and toggled independently.

Verdict:

Interface: View-to-Template Context Variables

Template Path Context Variable Type Description / Example Value
allergies/allergies_list.html user_allergies List[Allergen] Allergens associated with the current user
allergies/allergies_list.html ingredient_list List[str] Ingredients entered for the product
allergies/allergies_list.html is_safe bool True if product is safe for user, else False
users/user_list.html users List[User] List of all users (admin view)
users/user.html user User The user being viewed or edited
home.html form Form Allergy or ingredient input form
product.html product_ingredients List[str] Ingredients for the product being checked
product.html allergy_result str “Safe” or “Unsafe” result string

Notes:

Data Flow & API Contract

Third-Party Integrations

Key Design Decisions & ADRs

Scalability & Future-Proofing

Current State:

Performance Target:

Optimization Strategies:

Decision Trigger — The “Celery” Threshold:

Future-Proofing:


Future Considerations:


References to Other Documentation


Note: This document is intended for use as custom instructions to ground AI agents in the project’s vision, architecture, and conventions. Update as the project evolves.