version:1.0

This commit is contained in:
Flatlogic Bot 2026-01-21 19:28:45 +00:00
parent 6f5e84ab13
commit 0777577aa6
16 changed files with 538 additions and 195 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,17 @@
from django.contrib import admin
from .models import Organization, Profile, ChatMessage
# Register your models here.
@admin.register(Organization)
class OrganizationAdmin(admin.ModelAdmin):
list_display = ('name', 'slug', 'created_at')
prepopulated_fields = {'slug': ('name',)}
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
list_display = ('user', 'organization', 'role')
list_filter = ('role', 'organization')
@admin.register(ChatMessage)
class ChatMessageAdmin(admin.ModelAdmin):
list_display = ('user', 'organization', 'created_at')
readonly_fields = ('created_at',)

View File

@ -0,0 +1,46 @@
# Generated by Django 5.2.7 on 2026-01-21 19:24
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Organization',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('slug', models.SlugField(unique=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='ChatMessage',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('message', models.TextField()),
('response', models.TextField()),
('created_at', models.DateTimeField(auto_now_add=True)),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('organization', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.organization')),
],
),
migrations.CreateModel(
name='Profile',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('role', models.CharField(choices=[('SUPER_ADMIN', 'Super Admin'), ('ORG_ADMIN', 'Organization Admin'), ('USER', 'User')], default='USER', max_length=20)),
('organization', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='members', to='core.organization')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]

View File

@ -1,3 +1,44 @@
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
# Create your models here.
class Organization(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(unique=True)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.name
class Profile(models.Model):
ROLE_CHOICES = (
('SUPER_ADMIN', 'Super Admin'),
('ORG_ADMIN', 'Organization Admin'),
('USER', 'User'),
)
user = models.OneToOneField(User, on_delete=models.CASCADE)
organization = models.ForeignKey(Organization, on_delete=models.SET_NULL, null=True, blank=True, related_name='members')
role = models.CharField(max_length=20, choices=ROLE_CHOICES, default='USER')
def __str__(self):
return f"{self.user.username} - {self.role}"
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
instance.profile.save()
class ChatMessage(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True)
message = models.TextField()
response = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"Chat at {self.created_at}"

View File

@ -1,25 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{% block title %}Knowledge Base{% 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 %}
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
{% block head %}{% endblock %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}AIBiz Platform - AI-Driven B2B SaaS{% 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 %}
<!-- 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=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
{% load static %}
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
{% block head %}{% endblock %}
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom sticky-top">
<div class="container">
<a class="navbar-brand fw-bold text-primary" href="/">AIBiz Platform</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto align-items-center">
<li class="nav-item"><a class="nav-link" href="#features">Features</a></li>
<li class="nav-item"><a class="nav-link" href="#pricing">Pricing</a></li>
<li class="nav-item mx-2"><a class="btn btn-outline-primary btn-sm" href="/admin/">Admin Panel</a></li>
<li class="nav-item"><a class="btn btn-primary btn-sm px-4" href="#">Get Started</a></li>
</ul>
</div>
</div>
</nav>
<body>
{% block content %}{% endblock %}
<main>
{% block content %}{% endblock %}
</main>
<footer class="bg-navy text-white py-5 mt-5">
<div class="container">
<div class="row">
<div class="col-md-4">
<h5 class="fw-bold text-primary">AIBiz Platform</h5>
<p class="text-muted">Empowering businesses with production-ready AI workflows.</p>
</div>
<div class="col-md-8 text-end">
<p class="text-muted small">&copy; 2026 AIBiz Platform. All rights reserved.</p>
</div>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
</html>

View File

@ -1,145 +1,128 @@
{% extends "base.html" %}
{% block title %}{{ project_name }}{% endblock %}
{% 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%;
}
100% {
background-position: 100% 100%;
}
}
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);
}
}
.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 %}
{% load static %}
{% 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>
<section class="hero-section">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6 mb-5 mb-lg-0">
<span class="badge bg-primary-subtle text-primary px-3 py-2 rounded-pill mb-3">Enterprise Ready AI</span>
<h1 class="display-4 fw-bold mb-4 text-navy">Scale Your Business with <span class="text-primary">Intelligent Workflows</span></h1>
<p class="lead text-muted mb-5">The ultimate AI-driven SaaS platform for multitenant organizations. Manage teams, automate documents, and chat with your business intelligence.</p>
<div class="d-flex gap-3">
<a href="#" class="btn btn-primary btn-lg px-5">Start Free Trial</a>
<a href="#features" class="btn btn-outline-secondary btn-lg px-5">View Features</a>
</div>
</div>
<div class="col-lg-6">
<div class="glass-card p-0 overflow-hidden shadow-lg">
<div class="bg-navy p-3 text-white d-flex align-items-center">
<div class="feature-icon bg-primary mb-0 me-3" style="width:30px; height:30px; font-size: 1rem;">AI</div>
<h6 class="mb-0">AIBiz Assistant</h6>
</div>
<div class="chat-container">
<div class="chat-messages d-flex flex-column" id="chat-messages">
<div class="chat-bubble bubble-ai">
Hello! I'm your AIBiz Assistant. How can I help you optimize your business today?
</div>
</div>
<div class="chat-input-area">
<div class="input-group">
<input type="text" id="chat-input" class="form-control border-0 shadow-none" placeholder="Ask about AI workflows..." aria-label="Chat input">
<button class="btn btn-primary rounded-pill px-4 ms-2" type="button" id="send-btn">Send</button>
</div>
</div>
</div>
</div>
</div>
</div>
</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 %}
</section>
<section id="features" class="py-5 bg-white">
<div class="container py-5">
<div class="text-center mb-5">
<h2 class="fw-bold">Everything You Need to Succeed</h2>
<p class="text-muted">Powerful tools designed for the modern B2B ecosystem.</p>
</div>
<div class="row g-4">
<div class="col-md-4">
<div class="feature-card">
<div class="feature-icon">🏢</div>
<h5 class="fw-bold">Multitenancy</h5>
<p class="text-muted small">Built-in organization management with isolated data and custom roles.</p>
</div>
</div>
<div class="col-md-4">
<div class="feature-card">
<div class="feature-icon">🤖</div>
<h5 class="fw-bold">AI Chat</h5>
<p class="text-muted small">Context-aware assistant trained on your business data and workflows.</p>
</div>
</div>
<div class="col-md-4">
<div class="feature-card">
<div class="feature-icon">📄</div>
<h5 class="fw-bold">Doc Ingestion</h5>
<p class="text-muted small">Automated summarization and data extraction from complex business documents.</p>
</div>
</div>
</div>
</div>
</section>
<script>
const chatMessages = document.getElementById('chat-messages');
const chatInput = document.getElementById('chat-input');
const sendBtn = document.getElementById('send-btn');
function addMessage(text, isAi = false) {
const bubble = document.createElement('div');
bubble.className = `chat-bubble ${isAi ? 'bubble-ai' : 'bubble-user'}`;
bubble.innerText = text;
chatMessages.appendChild(bubble);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
async function handleSend() {
const message = chatInput.value.trim();
if (!message) return;
addMessage(message, false);
chatInput.value = '';
// Show typing indicator or just wait
const typingBubble = document.createElement('div');
typingBubble.className = 'chat-bubble bubble-ai italic text-muted';
typingBubble.innerText = 'Assistant is thinking...';
chatMessages.appendChild(typingBubble);
try {
const response = await fetch('{% url "ai_chat" %}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: message })
});
const data = await response.json();
chatMessages.removeChild(typingBubble);
if (data.reply) {
addMessage(data.reply, true);
} else {
addMessage('Error: ' + (data.error || 'Unknown error'), true);
}
} catch (error) {
chatMessages.removeChild(typingBubble);
addMessage('Error connecting to the AI service.', true);
}
}
sendBtn.addEventListener('click', handleSend);
chatInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') handleSend();
});
</script>
{% endblock %}

View File

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

View File

@ -1,25 +1,59 @@
import os
import platform
import json
from django import get_version as django_version
from django.shortcuts import render
from django.http import JsonResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from ai.local_ai_api import LocalAIApi
from .models import ChatMessage, Organization
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"
"""Render the landing screen with AI Chat Assistant."""
now = timezone.now()
context = {
"project_name": "New Style",
"agent_brand": agent_brand,
"project_name": "AIBiz Platform",
"django_version": django_version(),
"python_version": platform.python_version(),
"current_time": now,
"host_name": host_name,
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
"project_description": os.getenv("PROJECT_DESCRIPTION", "AI-Driven B2B SaaS Platform for modern enterprises."),
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
}
return render(request, "core/index.html", context)
@csrf_exempt
def ai_chat(request):
if request.method == "POST":
try:
data = json.loads(request.body)
user_message = data.get("message")
if not user_message:
return JsonResponse({"error": "No message provided"}, status=400)
# Construct the prompt for the AI
messages = [
{"role": "system", "content": "You are AIBiz Assistant, an expert in business workflows, SaaS, and AI automation. Help the user with their business questions concisely and professionally."},
{"role": "user", "content": user_message},
]
response = LocalAIApi.create_response(
{"input": messages},
{"poll_interval": 2, "poll_timeout": 60}
)
if response.get("success"):
ai_reply = LocalAIApi.extract_text(response) or "I'm sorry, I couldn't generate a response."
# Save message to DB if user is authenticated (optional for landing)
# ChatMessage.objects.create(message=user_message, response=ai_reply)
return JsonResponse({"reply": ai_reply})
else:
return JsonResponse({"error": response.get("error", "AI service error")}, status=500)
except Exception as e:
return JsonResponse({"error": str(e)}, status=500)
return JsonResponse({"error": "Invalid request"}, status=400)

View File

@ -1,4 +1,104 @@
/* Custom styles for the application */
body {
font-family: system-ui, -apple-system, sans-serif;
:root {
--primary-color: #2563eb;
--secondary-color: #0f172a;
--accent-color: #10b981;
--bg-light: #f8fafc;
--navy: #0f172a;
}
body {
font-family: 'Plus Jakarta Sans', sans-serif;
color: #334155;
background-color: var(--bg-light);
}
.text-primary { color: var(--primary-color) !important; }
.btn-primary {
background-color: var(--primary-color);
border-color: var(--primary-color);
font-weight: 600;
}
.btn-primary:hover {
background-color: #1d4ed8;
}
.bg-navy { background-color: var(--navy); }
/* Hero Section */
.hero-section {
padding: 100px 0;
background: radial-gradient(circle at top right, rgba(37, 99, 235, 0.05), transparent),
radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent);
}
.glass-card {
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}
/* Chat Assistant Widget */
.chat-container {
height: 400px;
display: flex;
flex-direction: column;
}
.chat-messages {
flex-grow: 1;
overflow-y: auto;
padding: 15px;
}
.chat-bubble {
padding: 10px 15px;
border-radius: 15px;
margin-bottom: 10px;
max-width: 85%;
font-size: 0.9rem;
}
.bubble-ai {
background-color: #f1f5f9;
color: #1e293b;
align-self: flex-start;
}
.bubble-user {
background-color: var(--primary-color);
color: white;
align-self: flex-end;
margin-left: auto;
}
.chat-input-area {
padding: 15px;
border-top: 1px solid #e2e8f0;
}
.feature-card {
padding: 30px;
border-radius: 20px;
background: white;
transition: transform 0.3s ease;
border: 1px solid #e2e8f0;
}
.feature-card:hover {
transform: translateY(-5px);
}
.feature-icon {
width: 50px;
height: 50px;
background: rgba(37, 99, 235, 0.1);
color: var(--primary-color);
display: flex;
align-items: center;
justify-content: center;
border-radius: 12px;
margin-bottom: 20px;
font-size: 1.5rem;
}

View File

@ -1,21 +1,104 @@
: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);
--primary-color: #2563eb;
--secondary-color: #0f172a;
--accent-color: #10b981;
--bg-light: #f8fafc;
--navy: #0f172a;
}
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;
font-family: 'Plus Jakarta Sans', sans-serif;
color: #334155;
background-color: var(--bg-light);
}
.text-primary { color: var(--primary-color) !important; }
.btn-primary {
background-color: var(--primary-color);
border-color: var(--primary-color);
font-weight: 600;
}
.btn-primary:hover {
background-color: #1d4ed8;
}
.bg-navy { background-color: var(--navy); }
/* Hero Section */
.hero-section {
padding: 100px 0;
background: radial-gradient(circle at top right, rgba(37, 99, 235, 0.05), transparent),
radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent);
}
.glass-card {
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 20px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}
/* Chat Assistant Widget */
.chat-container {
height: 400px;
display: flex;
flex-direction: column;
}
.chat-messages {
flex-grow: 1;
overflow-y: auto;
padding: 15px;
}
.chat-bubble {
padding: 10px 15px;
border-radius: 15px;
margin-bottom: 10px;
max-width: 85%;
font-size: 0.9rem;
}
.bubble-ai {
background-color: #f1f5f9;
color: #1e293b;
align-self: flex-start;
}
.bubble-user {
background-color: var(--primary-color);
color: white;
align-self: flex-end;
margin-left: auto;
}
.chat-input-area {
padding: 15px;
border-top: 1px solid #e2e8f0;
}
.feature-card {
padding: 30px;
border-radius: 20px;
background: white;
transition: transform 0.3s ease;
border: 1px solid #e2e8f0;
}
.feature-card:hover {
transform: translateY(-5px);
}
.feature-icon {
width: 50px;
height: 50px;
background: rgba(37, 99, 235, 0.1);
color: var(--primary-color);
display: flex;
align-items: center;
justify-content: center;
border-radius: 12px;
margin-bottom: 20px;
font-size: 1.5rem;
}