Compare commits

...

1 Commits

Author SHA1 Message Date
Flatlogic Bot
587ca82ae6 T0 2026-02-12 13:11:59 +00:00
12 changed files with 327 additions and 168 deletions

View File

@ -1,3 +1,8 @@
from django.contrib import admin
from .models import InventoryItem
# Register your models here.
@admin.register(InventoryItem)
class InventoryItemAdmin(admin.ModelAdmin):
list_display = ('name', 'store_name', 'cost', 'store_location', 'lead_time')
search_fields = ('name', 'store_name', 'features', 'description')
list_filter = ('store_name', 'store_location')

View File

@ -0,0 +1,31 @@
# Generated by Django 5.2.7 on 2026-02-12 13:02
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='InventoryItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('description', models.TextField(blank=True)),
('cost', models.DecimalField(decimal_places=2, max_digits=10)),
('installments_options', models.CharField(help_text='e.g., 12 months interest free', max_length=255)),
('features', models.TextField(help_text='Comma separated features')),
('store_location', models.CharField(max_length=255)),
('store_name', models.CharField(max_length=255)),
('lead_time', models.CharField(help_text='e.g., 3-5 days', max_length=100)),
('image_url', models.URLField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
]

View File

@ -1,3 +1,18 @@
from django.db import models
# Create your models here.
class InventoryItem(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
cost = models.DecimalField(max_digits=10, decimal_places=2)
installments_options = models.CharField(max_length=255, help_text="e.g., 12 months interest free")
features = models.TextField(help_text="Comma separated features")
store_location = models.CharField(max_length=255)
store_name = models.CharField(max_length=255)
lead_time = models.CharField(max_length=100, help_text="e.g., 3-5 days")
image_url = models.URLField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return f"{self.name} - {self.store_name}"

View File

@ -1,25 +1,92 @@
<!DOCTYPE html>
<html lang="en">
{% load static %}
<head>
<meta charset="UTF-8">
<title>{% block title %}Knowledge Base{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}AI Inventory Assistant{% endblock %}</title>
{% if project_description %}
<meta name="description" content="{{ project_description }}">
<meta property="og:description" content="{{ project_description }}">
<meta property="twitter:description" content="{{ project_description }}">
{% endif %}
{% if project_image_url %}
<meta property="og:image" content="{{ project_image_url }}">
<meta property="twitter:image" content="{{ project_image_url }}">
{% endif %}
{% load static %}
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@700;800&display=swap" rel="stylesheet">
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
<style>
:root {
--primary: #6366f1;
--primary-dark: #4f46e5;
--secondary: #64748b;
--accent: #10b981;
--background: #f8fafc;
--glass: rgba(255, 255, 255, 0.7);
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--background);
color: #1e293b;
}
h1, h2, h3, .brand {
font-family: 'Plus Jakarta Sans', sans-serif;
}
.glass-card {
background: var(--glass);
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 1.5rem;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}
.btn-primary {
background-color: var(--primary);
border-color: var(--primary);
padding: 0.75rem 1.5rem;
border-radius: 0.75rem;
font-weight: 600;
transition: all 0.2s ease;
}
.btn-primary:hover {
background-color: var(--primary-dark);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
</style>
{% block head %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
<nav class="navbar navbar-expand-lg navbar-light py-4">
<div class="container">
<a class="navbar-brand brand fw-bold fs-4 text-primary" href="/">InventoryAI</a>
<div class="ms-auto">
<a href="/admin/" class="btn btn-outline-secondary btn-sm px-3 rounded-pill">Admin Portal</a>
</div>
</div>
</nav>
<main>
{% block content %}{% endblock %}
</main>
<footer class="py-5 mt-5">
<div class="container text-center text-muted">
<p>&copy; 2026 InventoryAI Assistant. All rights reserved.</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
{% block scripts %}{% endblock %}
</body>
</html>
</html>

View File

@ -1,145 +1,152 @@
{% extends "base.html" %}
{% load static %}
{% block title %}{{ project_name }}{% endblock %}
{% block content %}
<div class="container mt-4">
<div class="row align-items-center mb-5 pb-5">
<div class="col-lg-6">
<h1 class="display-3 fw-extrabold mb-4 lh-sm">Find your perfect <span class="text-primary">Inventory</span> match.</h1>
<p class="lead text-secondary mb-5 fs-4">Ask our AI assistant about costs, installment plans, features, and locations to find exactly what you need in seconds.</p>
<div class="d-flex gap-3">
<a href="#chat-section" class="btn btn-primary btn-lg px-5">Start Chatting</a>
<a href="/admin/" class="btn btn-link text-decoration-none text-dark fw-bold px-0">Manage Inventory &rarr;</a>
</div>
</div>
<div class="col-lg-5 offset-lg-1 d-none d-lg-block">
<div class="glass-card p-5 text-center">
<div class="py-5">
<div class="display-1 text-primary mb-3">📦</div>
<h3 class="fw-bold">Smart Filtering</h3>
<p class="text-muted">No more endless scrolling. Just talk to the agent.</p>
</div>
</div>
</div>
</div>
<div id="chat-section" class="row justify-content-center pt-5">
<div class="col-lg-8">
<div class="glass-card shadow-lg p-0 overflow-hidden" style="height: 600px; display: flex; flex-direction: column;">
<div class="bg-primary text-white p-4">
<div class="d-flex align-items-center">
<div class="bg-white rounded-circle p-2 me-3" style="width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;">
🤖
</div>
<div>
<h5 class="mb-0 fw-bold">Inventory Concierge</h5>
<small class="opacity-75">AI Assistant • Online</small>
</div>
</div>
</div>
<div id="chat-messages" class="p-4 flex-grow-1 overflow-auto bg-white bg-opacity-50">
<div class="chat-bubble bot mb-4">
<div class="bg-white p-3 rounded-4 shadow-sm d-inline-block" style="max-width: 80%;">
Hello! I can help you find items from our inventory. What are you looking for today?
<br><small class="text-muted mt-2 d-block">Try: "Show me items under $500 with installment options"</small>
</div>
</div>
</div>
<div class="p-4 bg-white border-top">
<form id="chat-form" class="d-flex gap-2">
{% csrf_token %}
<input type="text" id="chat-input" class="form-control form-control-lg rounded-pill border-light-subtle bg-light" placeholder="Type your request here..." autocomplete="off">
<button type="submit" class="btn btn-primary rounded-circle p-0" style="width: 54px; height: 54px;">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-send-fill" viewBox="0 0 16 16">
<path d="M15.964.686a.5.5 0 0 0-.65-.65L.767 5.855H.766l-.452.18a.5.5 0 0 0-.082.887l.41.26.001.002 4.995 3.178 3.178 4.995.002.001.26.41a.5.5 0 0 0 .886-.083l6-15Zm-1.833 1.89L6.637 10.07l-.215-.338a.5.5 0 0 0-.154-.154l-.338-.215 7.494-7.494 1.178-.471-.47 1.178Z"/>
</svg>
</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% block head %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
inset: 0;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% {
background-position: 0% 0%;
.chat-bubble.user {
text-align: right;
}
100% {
background-position: 100% 100%;
.chat-bubble.user > div {
background-color: var(--primary) !important;
color: white;
}
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2.5rem 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}
h1 {
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
font-weight: 700;
margin: 0 0 1.2rem;
letter-spacing: -0.02em;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
opacity: 0.92;
}
.loader {
margin: 1.5rem auto;
width: 56px;
height: 56px;
border: 4px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
.item-card {
border-radius: 1rem;
transition: all 0.2s;
}
.item-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important;
}
}
.runtime code {
background: rgba(0, 0, 0, 0.25);
padding: 0.15rem 0.45rem;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
footer {
position: absolute;
bottom: 1rem;
width: 100%;
text-align: center;
font-size: 0.85rem;
opacity: 0.75;
}
</style>
{% endblock %}
{% block content %}
<main>
<div class="card">
<h1>Analyzing your requirements and generating your app…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
</div>
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
<p class="runtime">
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
</p>
</div>
</main>
<footer>
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
</footer>
{% endblock %}
{% block scripts %}
<script>
const chatForm = document.getElementById('chat-form');
const chatInput = document.getElementById('chat-input');
const chatMessages = document.getElementById('chat-messages');
function addMessage(text, type = 'bot', items = []) {
const div = document.createElement('div');
div.className = `chat-bubble ${type} mb-4 animate__animated animate__fadeInUp`;
let html = `
<div class="${type === 'user' ? 'bg-primary text-white' : 'bg-white'} p-3 rounded-4 shadow-sm d-inline-block" style="max-width: 85%;">
${text}
</div>
`;
if (items.length > 0) {
html += `<div class="row g-3 mt-2">`;
items.forEach(item => {
html += `
<div class="col-sm-6">
<div class="card item-card border-0 shadow-sm h-100 p-3 bg-white">
<h6 class="fw-bold mb-1">${item.name}</h6>
<div class="text-primary fw-bold mb-2">$${item.cost}</div>
<small class="text-muted d-block mb-1">📍 ${item.store} (${item.location})</small>
<small class="text-muted d-block mb-1">💳 ${item.installments}</small>
<small class="text-muted d-block">🚚 Lead time: ${item.lead_time}</small>
</div>
</div>
`;
});
html += `</div>`;
}
div.innerHTML = html;
chatMessages.appendChild(div);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
chatForm.addEventListener('submit', async (e) => {
e.preventDefault();
const message = chatInput.value.trim();
if (!message) return;
addMessage(message, 'user');
chatInput.value = '';
try {
const response = await fetch('/api/chat/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
},
body: json.stringify({ message })
});
const data = await response.json();
if (data.reply) {
addMessage(data.reply, 'bot', data.items || []);
}
} catch (error) {
console.error('Error:', error);
addMessage('Sorry, I encountered an error. Please try again later.', 'bot');
}
});
</script>
{% endblock %}

View File

@ -1,7 +1,7 @@
from django.urls import path
from .views import home
from . import views
urlpatterns = [
path("", home, name="home"),
]
path('', views.home, name='index'),
path('api/chat/', views.chat_api, name='chat_api'),
]

View File

@ -1,25 +1,59 @@
import os
import platform
from django import get_version as django_version
import json
from django.http import JsonResponse
from django.shortcuts import render
from django.utils import timezone
from django.db.models import Q
from .models import InventoryItem
def home(request):
"""Render the landing screen with loader and environment details."""
host_name = request.get_host().lower()
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
"""Render the landing screen with the conversational AI shell."""
featured_items = InventoryItem.objects.all()[:3]
context = {
"project_name": "New Style",
"agent_brand": agent_brand,
"django_version": django_version(),
"python_version": platform.python_version(),
"current_time": now,
"host_name": host_name,
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
"project_name": "AI Inventory Assistant",
"featured_items": featured_items,
}
return render(request, "core/index.html", context)
def chat_api(request):
"""Simple keyword-based search to simulate AI conversational agent."""
if request.method == "POST":
try:
data = json.loads(request.body)
query = data.get("message", "").lower()
if not query:
return JsonResponse({"reply": "I'm listening! What are you looking for?"})
# Simulate "AI" logic by filtering models
# In a real scenario, this would call an LLM with the context of the inventory
results = InventoryItem.objects.filter(
Q(name__icontains=query) |
Q(description__icontains=query) |
Q(features__icontains=query) |
Q(store_name__icontains=query) |
Q(store_location__icontains=query)
).distinct()
if results.exists():
count = results.count()
reply = f"I found {count} options that match your request. Here are the best ones:"
items = []
for item in results[:5]:
items.append({
"name": item.name,
"cost": str(item.cost),
"store": item.store_name,
"location": item.store_location,
"installments": item.installments_options,
"lead_time": item.lead_time
})
return JsonResponse({"reply": reply, "items": items})
else:
return JsonResponse({"reply": "I couldn't find any items matching those exact details. Try asking about cost, location, or specific features!"})
except Exception as e:
return JsonResponse({"error": str(e)}, status=400)
return JsonResponse({"error": "Invalid request"}, status=405)