<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NETA - AI Electrical Assistant</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- React Libraries -->
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<!-- Babel for JSX transpilation -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Lucide Icons -->
<script src="https://unpkg.com/lucide-react@latest/dist/umd/lucide-react.js"></script>
<!-- Custom CSS for animation and font -->
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
body {
font-family: 'Inter', sans-serif;
}
html {
scroll-behavior: smooth;
}
@keyframes pulse-glow {
0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4); }
50% { box-shadow: 0 0 10px 8px rgba(56, 189, 248, 0); }
}
.animate-pulse-glow {
animation: pulse-glow 2.5s infinite;
}
</style>
</head>
<body class="bg-gray-50 dark:bg-gray-900">
<div id="root"></div>
<script type="text/babel">
// --- Setup for Lucide Icons ---
const { Bot, User, Zap, ShieldCheck, UploadCloud, HardHat, ArrowRight, LoaderCircle, CheckCircle, AlertTriangle, Gift } = lucide;
// --- Helper Components ---
const IconWrapper = ({ children }) => (
<div className="bg-sky-100 dark:bg-sky-900 text-sky-600 dark:text-sky-400 p-3 rounded-full">
{children}
</div>
);
const FeatureCard = ({ icon, title, children }) => (
<div className="bg-white dark:bg-gray-800 p-6 rounded-2xl shadow-lg hover:shadow-xl transition-shadow duration-300 transform hover:-translate-y-1 border border-gray-200 dark:border-gray-700">
<div className="flex items-center space-x-4 mb-4">
<IconWrapper>{icon}</IconWrapper>
<h3 className="text-xl font-bold text-gray-800 dark:text-white">{title}</h3>
</div>
<p className="text-gray-600 dark:text-gray-300">{children}</p>
</div>
);
const MessageBox = ({ message, role }) => {
const isUser = role === 'user';
return (
<div className={`flex items-start gap-4 my-4 ${isUser ? 'justify-end' : ''}`}>
{!isUser && <div className="flex-shrink-0 w-10 h-10 bg-sky-500 text-white rounded-full flex items-center justify-center"><Bot /></div>}
<div className={`max-w-xl p-4 rounded-2xl ${isUser ? 'bg-sky-600 text-white rounded-br-none' : 'bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-bl-none'}`}>
<p style={{ whiteSpace: 'pre-wrap' }}>{message}</p>
</div>
{isUser && <div className="flex-shrink-0 w-10 h-10 bg-gray-300 dark:bg-gray-600 text-gray-800 dark:text-white rounded-full flex items-center justify-center"><User /></div>}
</div>
);
};
const ImageAnalysisResult = ({ analysis, error }) => {
if (error) {
return (
<div className="mt-6 p-4 bg-red-100 dark:bg-red-900 border border-red-300 dark:border-red-700 rounded-lg">
<div className="flex items-center">
<AlertTriangle className="h-6 w-6 text-red-600 dark:text-red-400 mr-3" />
<p className="text-red-800 dark:text-red-200 font-semibold">{error}</p>
</div>
</div>
);
}
if (!analysis) return null;
return (
<div className="mt-6 p-6 bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700">
<h4 className="text-xl font-bold text-gray-800 dark:text-white mb-4">NETA Analysis Results</h4>
<div className="prose prose-blue dark:prose-invert max-w-none">
<p style={{ whiteSpace: 'pre-wrap' }}>{analysis}</p>
</div>
</div>
);
};
// --- Main App Component ---
function App() {
const [chatHistory, setChatHistory] = React.useState([
{ role: 'model', parts: [{ text: "Hello! I'm NETA, your AI electrical expert. I'm completely free to use. Ask me anything about NEC codes, troubleshooting, or general electrical questions." }] }
]);
const [userInput, setUserInput] = React.useState('');
const [isGenerating, setIsGenerating] = React.useState(false);
const [imageFile, setImageFile] = React.useState(null);
const [imagePreview, setImagePreview] = React.useState(null);
const [imageAnalysis, setImageAnalysis] = React.useState('');
const [isAnalyzing, setIsAnalyzing] = React.useState(false);
const [analysisError, setAnalysisError] = React.useState('');
const fileInputRef = React.useRef(null);
const chatEndRef = React.useRef(null);
React.useEffect(() => {
chatEndRef.current?.scrollIntoView({ behavior: "smooth" });
}, [chatHistory]);
const handleSendMessage = async () => {
if (!userInput.trim() || isGenerating) return;
const newUserMessage = { role: 'user', parts: [{ text: userInput }] };
setChatHistory(prev => [...prev, newUserMessage]);
setUserInput('');
setIsGenerating(true);
try {
const prompt = `You are NETA, an expert AI assistant for electricians. Your knowledge is based on the National Electrical Code (NEC) and extensive electrical work experience. Answer the following user question accurately and concisely. If it involves code, try to cite the specific NEC article if possible. User question: "${userInput}"`;
const payload = { contents: [{ role: "user", parts: [{text: prompt}]}] };
const apiKey = "";
const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${apiKey}`;
const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`API call failed with status: ${response.status}`);
}
const result = await response.json();
let text = "Sorry, I couldn't generate a response. Please try again.";
if (result.candidates && result.candidates[0]?.content?.parts[0]?.text) {
text = result.candidates[0].content.parts[0].text;
}
setChatHistory(prev => [...prev, { role: 'model', parts: [{ text }] }]);
} catch (error) {
console.error("Error generating response:", error);
setChatHistory(prev => [...prev, { role: 'model', parts: [{ text: "I'm having trouble connecting right now. Please check your connection and try again later." }] }]);
} finally {
setIsGenerating(false);
}
};
const handleImageChange = (e) => {
const file = e.target.files[0];
if (file) {
setImageFile(file);
setImageAnalysis('');
setAnalysisError('');
const reader = new FileReader();
reader.onloadend = () => {
setImagePreview(reader.result);
};
reader.readAsDataURL(file);
}
};
const fileToGenerativePart = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const base64Data = reader.result.split(',')[1];
resolve({
inlineData: {
mimeType: file.type,
data: base64Data
}
});
};
reader.onerror = (error) => reject(error);
reader.readAsDataURL(file);
});
};
const handleImageAnalysis = async () => {
if (!imageFile || isAnalyzing) return;
setIsAnalyzing(true);
setImageAnalysis('');
setAnalysisError('');
try {
const imagePart = await fileToGenerativePart(imageFile);
const prompt = "You are NETA, an AI electrical safety inspector. Analyze this image of electrical work. Identify any potential NEC code violations, safety issues, or areas for improvement. Provide a clear, concise report. State if the work looks compliant or if there are issues to address.";
const payload = {
contents: [{
parts: [ { text: prompt }, imagePart ]
}],
};
const apiKey = "";
const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=${apiKey}`;
const response = await fetch(apiUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(`API call failed with status: ${response.status}`);
}
const result = await response.json();
let text = "Sorry, I couldn't analyze the image. The content may be unsupported.";
if (result.candidates && result.candidates[0]?.content?.parts[0]?.text) {
text = result.candidates[0].content.parts[0].text;
} else if (result.candidates && result.candidates[0]?.finishReason === "SAFETY") {
text = "Analysis could not be completed due to safety policies. The image may contain sensitive content.";
}
setImageAnalysis(text);
} catch (error) {
console.error("Error analyzing image:", error);
setAnalysisError("Failed to analyze the image. Please try a different image or check your connection.");
} finally {
setIsAnalyzing(false);
}
};
return (
<div className="text-gray-900 dark:text-gray-100">
{/* Header */}
<header className="sticky top-0 z-50 bg-white/80 dark:bg-gray-900/80 backdrop-blur-lg shadow-sm">
<nav className="container mx-auto px-6 py-4 flex justify-between items-center">
<div className="flex items-center space-x-2">
<Zap className="w-8 h-8 text-sky-500" />
<span className="text-2xl font-bold text-gray-800 dark:text-white">NETA</span>
</div>
<div className="hidden md:flex items-center space-x-6">
<a href="#features" className="text-gray-600 dark:text-gray-300 hover:text-sky-600 dark:hover:text-sky-400 transition">Features</a>
<a href="#free" className="text-gray-600 dark:text-gray-300 hover:text-sky-600 dark:hover:text-sky-400 transition">Free for Life</a>
<a href="#contact" className="text-gray-600 dark:text-gray-300 hover:text-sky-600 dark:hover:text-sky-400 transition">Contact</a>
</div>
<button className="bg-sky-600 text-white px-5 py-2.5 rounded-lg font-semibold hover:bg-sky-700 transition-colors shadow">Get Started Free</button>
</nav>
</header>
<main>
{/* Hero Section with Interactive Demo */}
<section className="py-20 md:py-24 text-center bg-white dark:bg-gray-800/50">
<div className="container mx-auto px-6">
<h1 className="text-4xl md:text-6xl font-extrabold text-gray-900 dark:text-white leading-tight mb-4">
Your AI Partner in the <span className="text-sky-500">Electrical</span> Field
</h1>
<p className="text-lg md:text-xl text-gray-600 dark:text-gray-300 max-w-3xl mx-auto mb-12">
Get instant NEC code answers, troubleshoot complex issues, and pass inspections the first time. NETA is the ultimate tool for modern electricians—<strong className="text-sky-500">and it's free for life.</strong>
</p>
<div id="interactive-demo" className="text-left">
<div className="text-center mb-12">
<h2 className="text-3xl md:text-4xl font-bold text-gray-800 dark:text-white">Experience NETA Now</h2>
<p className="text-lg text-gray-600 dark:text-gray-400 mt-4 max-w-2xl mx-auto">Ask a question or upload an image to see NETA in action.</p>
</div>
<div className="grid lg:grid-cols-2 gap-12 items-start max-w-6xl mx-auto">
<div className="bg-white dark:bg-gray-800 p-6 rounded-2xl shadow-xl border border-gray-200 dark:border-gray-700 animate-pulse-glow">
<h3 className="text-2xl font-bold mb-4 text-center text-gray-800 dark:text-white">Chat with NETA</h3>
<div className="h-96 overflow-y-auto p-4 bg-gray-100 dark:bg-gray-900 rounded-lg mb-4">
{chatHistory.map((msg, index) => (
<MessageBox key={index} message={msg.parts[0].text} role={msg.role} />
))}
{isGenerating && (
<div className="flex items-start gap-4 my-4">
<div className="flex-shrink-0 w-10 h-10 bg-sky-500 text-white rounded-full flex items-center justify-center"><Bot /></div>
<div className="max-w-xl p-4 rounded-2xl bg-gray-200 dark:bg-gray-700">
<LoaderCircle className="w-6 h-6 animate-spin text-sky-500" />
</div>
</div>
)}
<div ref={chatEndRef} />
</div>
<div className="flex items-center space-x-2">
<input
type="text"
value={userInput}
onChange={(e) => setUserInput(e.target.value)}
onKeyPress={(e) => e.key === 'Enter' && handleSendMessage()}
placeholder="e.g., 'What is the NEC code for outlet spacing?'"
className="w-full p-3 border border-gray-300 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-700 focus:ring-2 focus:ring-sky-500 focus:outline-none transition"
disabled={isGenerating}
/>
<button onClick={handleSendMessage} disabled={isGenerating || !userInput.trim()} className="bg-sky-600 text-white p-3 rounded-lg font-semibold hover:bg-sky-700 disabled:bg-sky-300 disabled:cursor-not-allowed transition-colors">
<ArrowRight className="w-6 h-6"/>
</button>
</div>
</div>
<div className="bg-white dark:bg-gray-800 p-6 rounded-2xl shadow-xl border border-gray-200 dark:border-gray-700">
<h3 className="text-2xl font-bold mb-4 text-center text-gray-800 dark:text-white">Pre-Inspection Check</h3>
<div className="relative border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center cursor-pointer hover:border-sky-500 dark:hover:border-sky-400 transition" onClick={() => fileInputRef.current.click()}>
<input type="file" ref={fileInputRef} onChange={handleImageChange} accept="image/*" className="hidden" />
{imagePreview ? (
<img src={imagePreview} alt="Upload preview" className="mx-auto max-h-64 rounded-lg object-contain" />
) : (
<div className="flex flex-col items-center text-gray-500 dark:text-gray-400">
<UploadCloud className="w-12 h-12 mb-4" />
<p className="font-semibold">Click to upload an image</p>
<p className="text-sm">PNG, JPG, or WEBP</p>
</div>
)}
</div>
{imageFile && (
<button onClick={handleImageAnalysis} disabled={isAnalyzing} className="w-full mt-4 py-3 rounded-lg bg-sky-600 text-white font-semibold hover:bg-sky-700 disabled:bg-sky-300 flex items-center justify-center space-x-2 transition-colors">
{isAnalyzing ? <LoaderCircle className="w-6 h-6 animate-spin" /> : <ShieldCheck className="w-6 h-6" />}
<span>{isAnalyzing ? 'Analyzing...' : 'Analyze My Work'}</span>
</button>
)}
{(imageAnalysis || analysisError) && <ImageAnalysisResult analysis={imageAnalysis} error={analysisError} />}
</div>
</div>
</div>
</div>
</section>
<section id="features" className="py-20 bg-gray-50 dark:bg-gray-900">
<div className="container mx-auto px-6">
<div className="text-center mb-12">
<h2 className="text-3xl md:text-4xl font-bold text-gray-800 dark:text-white">Core Features Included for Free</h2>
<p className="text-lg text-gray-600 dark:text-gray-400 mt-4 max-w-2xl mx-auto">From apprentices to masters, NETA empowers you to work smarter, faster, and safer.</p>
</div>
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
<FeatureCard icon={<Zap className="w-8 h-8" />} title="Instant NEC Code Lookup">
Stop flipping through pages. Get the exact NEC cod