Skip to content

Commit aa17a40

Browse files
committed
feat: enhance product summary with health goals, religious requirements, and improved UI
- Add support for health goals and religious dietary requirements in product analysis - Include detailed nutritional data (calories, carbs, sugars, fats, proteins, fiber, salt) - Integrate allergen tags, product labels, and categories from Open Food Facts API - Improve prompt to conditionally include only user-specified preferences - Modernize UI with card-based design for AI summary and generated images - Add emoji icons and improved typography for better visual hierarchy - Maintain comprehensive translations for all 5 languages (EN, FR, ES, IT, AR)
1 parent abb57ae commit aa17a40

File tree

6 files changed

+171
-94
lines changed

6 files changed

+171
-94
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ The output format is a Markdown file to faciliate the display of the recipe on t
223223

224224
- **Challenge**: Present the application in multiple languages
225225

226-
- **Solution**: The same prompt is utilized, but the LLM is instructed to generate the output in a specific language, catering to the user's language preference (English/French).
226+
- **Solution**: The same prompt is utilized, but the LLM is instructed to generate the output in a specific language, catering to the user's language preference (English, French, Spanish, Italian, Arabic). The UI includes comprehensive translations for all features including allergen warnings, ingredient descriptions, and nutritional information.
227227

228228
**Direct Allergen Detection and Nutritional Analysis**
229229

lambda/barcode_product_summary/index.js

Lines changed: 97 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lambda/recipe_step_by_step/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/ui/src/assets/i18n/all.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const customTranslations: Record<string, Record<string, string>> = {
3838
ingredients_desc_additive:
3939
"Click on each additive to view AI-generated detailed descriptions",
4040
ingredients_no_additive: "The product does not have additives",
41+
allergen_warning_title: "Allergen Warning",
42+
allergen_warning_message: "This product contains allergens you're sensitive to:",
4143
summary_title: "Summary of ingredients generated by AI",
4244
summary_benefits_title: "Benefits",
4345
summary_disadvantages_title: "Disadvantages",
@@ -128,6 +130,8 @@ const customTranslations: Record<string, Record<string, string>> = {
128130
ingredients_desc_additive:
129131
"Cliquez sur chaque additif pour voir les descriptions détaillées générées par l'IA",
130132
ingredients_no_additive: "Le produit ne contient pas d'additifs",
133+
allergen_warning_title: "Avertissement Allergène",
134+
allergen_warning_message: "Ce produit contient des allergènes auxquels vous êtes sensible :",
131135
summary_title: "Résumé des ingrédients généré par IA",
132136
summary_benefits_title: "Avantages",
133137
summary_disadvantages_title: "Inconvénients",
@@ -220,6 +224,8 @@ const customTranslations: Record<string, Record<string, string>> = {
220224
ingredients_no_additive: "Il prodotto non contiene additivi",
221225
ingredients_desc_additive:
222226
"Fai clic su ogni additivo per visualizzare le descrizioni dettagliate generate dall’AI",
227+
allergen_warning_title: "Avviso Allergeni",
228+
allergen_warning_message: "Questo prodotto contiene allergeni a cui sei sensibile:",
223229
summary_title: "Riepilogo degli ingredienti generato dall’AI",
224230
summary_benefits_title: "Benefici",
225231
summary_disadvantages_title: "Svantaggi",
@@ -313,6 +319,8 @@ const customTranslations: Record<string, Record<string, string>> = {
313319
ingredients_no_additive: "El producto no contiene aditivos",
314320
ingredients_desc_additive:
315321
"Haz clic en cada aditivo para ver descripciones detalladas generadas por IA",
322+
allergen_warning_title: "Advertencia de Alérgenos",
323+
allergen_warning_message: "Este producto contiene alérgenos a los que eres sensible:",
316324
summary_title: "Resumen de ingredientes generados por IA",
317325
summary_benefits_title: "Beneficios",
318326
summary_disadvantages_title: "Desventajas",
@@ -398,6 +406,8 @@ arabic:{
398406
"ingredients_desc_ingredient": "انقر على كل مكون لعرض الوصف التفصيلي الناتج عن الذكاء الاصطناعي",
399407
"ingredients_desc_additive": "انقر على كل إضافة لعرض الوصف التفصيلي الناتج عن الذكاء الاصطناعي",
400408
"ingredients_no_additive": "المنتج لا يحتوي على إضافات",
409+
"allergen_warning_title": "تحذير من مسببات الحساسية",
410+
"allergen_warning_message": "يحتوي هذا المنتج على مسببات حساسية تؤثر عليك:",
401411
"summary_title": "ملخص المكونات الناتجة عن الذكاء الاصطناعي",
402412
"summary_benefits_title": "الفوائد",
403413
"summary_disadvantages_title": "العيوب",

resources/ui/src/pages/components/barcode_ingredients.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ const BarcodeIngredients: React.FC<BarcodeIngredientsProps> = ({
3939
const [ingredientsError, setIngredientsError] = useState("");
4040

4141
const fetchData = async () => {
42-
console.log(
43-
`call backend with scannedCode: ${productCode} and language: ${language}`
44-
);
42+
4543
setApiResponse(null);
4644
setLoading(true);
4745

@@ -53,13 +51,11 @@ const BarcodeIngredients: React.FC<BarcodeIngredientsProps> = ({
5351
);
5452

5553
if (!response.error) {
56-
console.log("response=" + JSON.stringify(response));
5754
const keyValueArray = Object.entries(response.ingredients_description);
5855
const newIngredients = keyValueArray.map(([key, value]) => ({
5956
label: key,
6057
description: value,
6158
}));
62-
console.log(newIngredients);
6359

6460
setIngredients(newIngredients);
6561

resources/ui/src/pages/components/barcode_product_summary.tsx

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,14 @@ const BarcodeProductSummary: React.FC<BarcodeProductSummaryProps> = ({
142142
return (
143143
<div>
144144
{loadingSummary && (
145-
<div>
145+
<div style={{ padding: "16px" }}>
146146
<Alert>
147-
<strong>Loading Summary of Ingredients...</strong>
147+
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
148+
<strong>{currentTranslations["summary_title"].replace("Summary of ingredients generated by AI", "Loading AI Analysis")}...</strong>
149+
</div>
148150
</Alert>
149151
</div>
150-
)}{" "}
152+
)}
151153
{summaryError ? (
152154
<Alert statusIconAriaLabel="Error" type="error">
153155
<strong>{summaryError}</strong>
@@ -156,42 +158,64 @@ const BarcodeProductSummary: React.FC<BarcodeProductSummaryProps> = ({
156158
<>
157159
{recommendation && (
158160
<div>
159-
<SpaceBetween direction="vertical" size="m">
160-
<ColumnLayout columns={2}>
161-
162-
<Container
163-
header={
164-
<Header variant="h2">
161+
<SpaceBetween direction="vertical" size="l">
162+
{/* AI Summary Card */}
163+
<div style={{
164+
background: "white",
165+
border: "1px solid #e5e7eb",
166+
borderRadius: "8px",
167+
padding: "20px",
168+
boxShadow: "0 1px 3px rgba(0,0,0,0.1)"
169+
}}>
170+
<div style={{ display: "flex", alignItems: "center", gap: "8px", marginBottom: "16px" }}>
171+
<span style={{ fontSize: "24px" }}></span>
172+
<h3 style={{ margin: 0, fontSize: "20px", fontWeight: "600" }}>
165173
{currentTranslations["summary_title"]}
166-
</Header>
167-
}
168-
169-
>
170-
<ReactMarkdown children={recommendation}></ReactMarkdown>
171-
</Container>
172-
<Container
173-
174-
media={{
175-
position: "top",
176-
content: (
177-
<div className={image ? "" : "pulsate"}>
178-
<img
179-
src={
180-
image
181-
? `${hostingDomain}${image}`
182-
: "image-placeholder.png"
183-
}
184-
alt={currentTranslations['image_title']}
185-
/>
174+
</h3>
175+
</div>
176+
<div style={{
177+
fontSize: "15px",
178+
lineHeight: "1.6",
179+
color: "#374151"
180+
}}>
181+
<ReactMarkdown children={recommendation}></ReactMarkdown>
182+
</div>
183+
</div>
184+
185+
{/* AI Generated Image Card */}
186+
{(image || loadingImage) && (
187+
<div style={{
188+
background: "white",
189+
border: "1px solid #e5e7eb",
190+
borderRadius: "8px",
191+
overflow: "hidden",
192+
boxShadow: "0 1px 3px rgba(0,0,0,0.1)"
193+
}}>
194+
<div style={{ padding: "16px", borderBottom: "1px solid #e5e7eb" }}>
195+
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
196+
<span style={{ fontSize: "20px" }}>🎨</span>
197+
<h4 style={{ margin: 0, fontSize: "16px", fontWeight: "600" }}>
198+
{currentTranslations['image_title']}
199+
</h4>
186200
</div>
187-
),
188-
height: "100%",
189-
}}
190-
>
191-
{currentTranslations['image_title']}
192-
</Container>
193-
194-
</ColumnLayout>
201+
</div>
202+
<div style={{ position: "relative", paddingTop: "56.25%" }}>
203+
<img
204+
src={image ? `${hostingDomain}${image}` : "image-placeholder.png"}
205+
alt={currentTranslations['image_title']}
206+
className={image ? "" : "pulsate"}
207+
style={{
208+
position: "absolute",
209+
top: 0,
210+
left: 0,
211+
width: "100%",
212+
height: "100%",
213+
objectFit: "cover"
214+
}}
215+
/>
216+
</div>
217+
</div>
218+
)}
195219
</SpaceBetween>
196220
</div>
197221
)}

0 commit comments

Comments
 (0)