File size: 16,786 Bytes
7a5bb5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fcc8c39
7a5bb5d
fcc8c39
7a5bb5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
import React, { useState } from 'react';
import { UploadCloud, Activity, CheckCircle, Layers, BarChart2, ArrowRight, ShieldCheck, Zap, Globe, Cpu, Settings, User } from 'lucide-react';
import './App.css';

interface HistoryRecord {
  id: number;
  timestamp: string;
  filename: string;
  confidence: number;
  thumbnail: string;
}

function LandingPage({ onEnter }: { onEnter: () => void }) {
  return (
    <div className="landing-container">
      <nav className="nav-bar">
        <div className="logo">
          <div className="logo-icon"><Activity size={20} color="#fff" /></div>
          DeepOceans
        </div>
        <div className="nav-actions">
          <button className="btn-text">Documentation</button>
          <button className="btn-text">API Features</button>
          <button className="btn-primary" onClick={onEnter}>View Dashboard</button>
        </div>
      </nav>

      <main>
        <section className="hero-section">
          <div className="hero-badge">DeepOceans v1.2 Engine Live</div>
          <h1 className="hero-title">Protecting Marine Life with Precision AI.</h1>
          <p className="hero-description">
            Enterprise-grade anomaly detection for satellite telemetry. Monitor coastal regions and detect oceanic oil spills automatically using our state-of-the-art segmentation network.
          </p>
          <div className="hero-buttons">
            <button className="btn-primary-lg" onClick={onEnter}>Start Monitoring <ArrowRight size={20} /></button>
            <button className="btn-secondary-lg">Talk to Sales</button>
          </div>
          <div className="hero-background-glow"></div>
        </section>

        <section className="features-section">
          <div className="feature-grid">
            <div className="feature-card">
              <div className="feature-icon-wrapper"><Zap size={24} className="feature-icon" /></div>
              <h3>Real-Time Inference</h3>
              <p>Achieve sub-200ms latency on 256x256 image segmentation masks utilizing optimized T4 compute instances.</p>
            </div>
            <div className="feature-card">
              <div className="feature-icon-wrapper"><Globe size={24} className="feature-icon" /></div>
              <h3>Satellite Agnostic</h3>
              <p>Process telemetry from SAR, Sentinel-1, or multi-spectral sources effortlessly through our robust API.</p>
            </div>
            <div className="feature-card">
              <div className="feature-icon-wrapper"><ShieldCheck size={24} className="feature-icon" /></div>
              <h3>Validated Accuracy</h3>
              <p>Averaging 0.84 IoU against validation datasets, ensuring you capture maximum spill events with minimal noise.</p>
            </div>
            <div className="feature-card">
              <div className="feature-icon-wrapper"><Cpu size={24} className="feature-icon" /></div>
              <h3>Seamless Integration</h3>
              <p>Plug predictions directly into your existing command center via standard REST protocols.</p>
            </div>
          </div>
        </section>

        <section className="how-it-works-section">
          <div className="section-header">
            <h2>Streamlined Operations</h2>
            <p>From raw signal to actionable intelligence in three steps.</p>
          </div>
          <div className="steps-container">
            <div className="step-card">
              <span className="step-numeral">01</span>
              <h4>Data Ingestion</h4>
              <p>Upload your optical or synthetic aperture radar imagery directly into our secure pipeline.</p>
            </div>
            <div className="step-card">
              <span className="step-numeral">02</span>
              <h4>Neural Processing</h4>
              <p>Our proprietary U-Net architecture isolates hydrocarbon signatures instantly.</p>
            </div>
            <div className="step-card">
              <span className="step-numeral">03</span>
              <h4>Spatial Analytics</h4>
              <p>Generate highly accurate masks and probability scores to dispatch cleanup crews faster.</p>
            </div>
          </div>
        </section>

        <section className="preview-section">
          <div className="preview-app-window">
             <div className="app-window-header">
               <div className="mac-dots"><div className="mac-dot red"></div><div className="mac-dot yellow"></div><div className="mac-dot green"></div></div>
               <div className="app-title">app.deepoceans.ai/workspace</div>
             </div>
             <div className="app-window-body">
                <div className="app-mockup-skeleton">
                   <div className="mock-nav"></div>
                   <div className="mock-layout">
                     <div className="mock-top">
                       <div className="mock-stat"></div>
                       <div className="mock-stat"></div>
                       <div className="mock-stat"></div>
                       <div className="mock-stat"></div>
                     </div>
                     <div className="mock-main">
                        <div className="mock-side"></div>
                        <div className="mock-center"></div>
                     </div>
                   </div>
                </div>
             </div>
          </div>
        </section>

        <section className="cta-section">
          <h2>Ready to revolutionize your monitoring?</h2>
          <p>Join the marine conservation operations running on DeepOceans.</p>
          <button className="btn-primary-lg" onClick={onEnter}>Launch Product <ArrowRight size={20} /></button>
        </section>
      </main>

      <footer className="landing-footer">
        <div className="footer-content">
          <div className="logo"><Activity size={20} color="var(--accent)" /> DeepOceans</div>
          <p>© 2026 DeepOceans AI. Securing marine futures.</p>
        </div>
      </footer>
    </div>
  );
}

function Dashboard() {
  const [selectedFile, setSelectedFile] = useState<File | null>(null);
  const [preview, setPreview] = useState<string | null>(null);
  const [maskSrc, setMaskSrc] = useState<string | null>(null);
  const [isLoading, setIsLoading] = useState(false);
  const [confidence, setConfidence] = useState<number | null>(null);
  const [latency, setLatency] = useState<number | null>(null);
  const [threshold, setThreshold] = useState<number>(0.5);
  
  const [history, setHistory] = useState<HistoryRecord[]>([
    {
      id: 1,
      timestamp: new Date(Date.now() - 14400000).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}),
      filename: 'sentinel_scan_alpha.png',
      confidence: 84.2,
      thumbnail: 'https://images.unsplash.com/photo-1621213038477-9dfaf942dcde?auto=format&fit=crop&w=48&h=48'
    }
  ]);

  const [isDragActive, setIsDragActive] = useState(false);

  const handleFile = (file: File) => {
    setSelectedFile(file);
    const url = URL.createObjectURL(file);
    setPreview(url);
    setMaskSrc(null);
    setConfidence(null);
    setLatency(null);
  };

  const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    if (e.target.files && e.target.files.length > 0) handleFile(e.target.files[0]);
  };

  const onDragOver = (e: React.DragEvent) => { e.preventDefault(); setIsDragActive(true); };
  const onDragLeave = () => { setIsDragActive(false); };
  const onDrop = (e: React.DragEvent) => {
    e.preventDefault();
    setIsDragActive(false);
    if (e.dataTransfer.files && e.dataTransfer.files.length > 0) handleFile(e.dataTransfer.files[0]);
  };

  const handleUpload = async () => {
    if (!selectedFile || !preview) return;

    setIsLoading(true);
    const formData = new FormData();
    formData.append("file", selectedFile);

    const API_URL = import.meta.env.VITE_API_URL || "";
    try {
      const response = await fetch(`${API_URL}/predict`, {
        method: "POST",
        body: formData,
      });

      if (response.ok) {
        const confHeader = response.headers.get("X-Confidence-Score");
        const latHeader = response.headers.get("X-Inference-Latency-Ms");
        
        let confValue = 0;
        if (confHeader) {
          confValue = parseFloat(confHeader);
          setConfidence(confValue);
        }
        if (latHeader) setLatency(parseInt(latHeader));

        const blob = await response.blob();
        const maskUrl = URL.createObjectURL(blob);
        setMaskSrc(maskUrl);

        const newRecord: HistoryRecord = {
          id: Date.now(),
          timestamp: new Date().toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}),
          filename: selectedFile.name,
          confidence: confValue,
          thumbnail: preview
        };
        setHistory(prev => [newRecord, ...prev].slice(0, 10));
      } else {
        alert("Inference server returned an error. Ensure backend is running.");
      }
    } catch (error) {
      console.error(error);
      alert("Connection failure to inference node.");
    } finally {
      setIsLoading(false);
    }
  };

  return (
    <div className="app-layout">
      {/* SaaS App Header */}
      <header className="app-header">
        <div className="app-logo">
          <div className="logo-icon"><Activity size={18} color="#fff" /></div>
          DeepOceans <span className="app-badge">Workspace</span>
        </div>
        <div className="header-actions">
          <div className="connection-status">
            <div className="status-orb"></div> Node Operational
          </div>
          <button className="icon-btn"><Settings size={18} /></button>
          <button className="profile-btn"><User size={18} /></button>
        </div>
      </header>

      <main className="dashboard-content">
        <div className="dashboard-grid">
          
          {/* Top Row: Metrics Grid */}
          <div className="metrics-row">
            <div className="stat-card">
               <div className="stat-icon-wrapper"><BarChart2 size={20} className="stat-icon" /></div>
               <div className="stat-content">
                 <div className="stat-label">Spill Probability</div>
                 <div className="stat-value" style={{ color: confidence && confidence > 50 ? 'var(--alert)' : 'var(--text-primary)' }}>
                   {confidence !== null ? `${confidence.toFixed(1)}%` : '--'}
                 </div>
               </div>
            </div>
            <div className="stat-card">
               <div className="stat-icon-wrapper"><Activity size={20} className="stat-icon" /></div>
               <div className="stat-content">
                 <div className="stat-label">Inference Latency</div>
                 <div className="stat-value">{latency !== null ? `${latency}ms` : '--'}</div>
               </div>
            </div>
            <div className="stat-card">
               <div className="stat-icon-wrapper"><CheckCircle size={20} className="stat-icon" /></div>
               <div className="stat-content">
                 <div className="stat-label">Model IoU (Validation)</div>
                 <div className="stat-value">0.842</div>
               </div>
            </div>
            <div className="stat-card">
               <div className="stat-icon-wrapper"><Layers size={20} className="stat-icon" /></div>
               <div className="stat-content">
                 <div className="stat-label">Detection Threshold</div>
                 <div className="stat-control">
                   <input type="range" min="0.1" max="0.9" step="0.1" value={threshold} onChange={(e) => setThreshold(parseFloat(e.target.value))} />
                   <span className="range-val">{threshold.toFixed(2)}</span>
                 </div>
               </div>
            </div>
          </div>

          <div className="main-interaction-row">
            {/* Left: Uploader */}
            <div className="upload-container panel">
              <h3 className="panel-title">Data Ingestion</h3>
              
              <div 
                className={`dropzone ${isDragActive ? 'drag-active' : ''} ${selectedFile ? 'has-file' : ''}`}
                onDragOver={onDragOver}
                onDragLeave={onDragLeave}
                onDrop={onDrop}
              >
                <input type="file" id="file-upload" accept="image/*" onChange={handleFileChange} />
                <UploadCloud size={48} className="dropzone-icon" />
                <div className="dropzone-text">
                  <span className="dropzone-primary">Click to upload</span> or drag and drop
                </div>
                <div className="dropzone-secondary">JPG or PNG (Optimal size: 256x256)</div>
                {selectedFile && <div className="selected-file-chip">{selectedFile.name}</div>}
              </div>

              <button 
                className="btn-action-lg" 
                onClick={handleUpload} 
                disabled={!selectedFile || isLoading}
              >
                {isLoading ? <span className="loader" style={{marginRight: '8px'}}></span> : null}
                {isLoading ? "Running Prediction Pipeline..." : "Execute Detection"}
              </button>
            </div>

            {/* Right: History Log */}
            <div className="history-container panel">
              <div className="panel-header">
                <h3 className="panel-title">Analysis History</h3>
                <span className="record-count">{history.length} Records</span>
              </div>
              <div className="history-list">
                {history.length === 0 ? (
                  <div className="empty-state">No telemetry analyzed yet.</div>
                ) : (
                  history.map(record => (
                    <div key={record.id} className="history-row fade-in">
                      <img src={record.thumbnail} alt="snapshot" className="history-thumb" />
                      <div className="history-details">
                        <div className="history-filename" title={record.filename}>{record.filename}</div>
                        <div className="history-time">{record.timestamp}</div>
                      </div>
                      <div className="history-status">
                        <div className={`status-badge ${record.confidence > 50 ? 'alert' : 'clear'}`}>
                          {record.confidence > 50 ? 'Anomaly Detected' : 'All Clear'}
                        </div>
                        <div className="history-score">{record.confidence.toFixed(1)}%</div>
                      </div>
                    </div>
                  ))
                )}
              </div>
            </div>
          </div>

          {/* Bottom Row: Visualizations */}
          <div className="visualization-container panel">
             <div className="panel-header" style={{ marginBottom: '24px' }}>
                <h3 className="panel-title">Spatial Rendering Analysis</h3>
                <span className="badge-pill">U-Net Feature Map</span>
             </div>
             
             <div className="frames-grid">
               <div className="frame-card">
                 <div className="frame-header">Source Imagery</div>
                 <div className="frame-content">
                    {preview ? <img src={preview} alt="Raw" className="fade-in" /> : <div className="empty-state">Awaiting Feed</div>}
                 </div>
               </div>
               
               <div className="frame-card">
                 <div className="frame-header">Segmentation Mask</div>
                 <div className="frame-content dark-mode">
                    {maskSrc ? <img src={maskSrc} alt="Mask" className="fade-in invert-render" /> : <div className="empty-state">No Output</div>}
                 </div>
               </div>
               
               <div className="frame-card">
                 <div className="frame-header">Anomaly Overlay</div>
                 <div className="frame-content">
                    {preview && maskSrc ? (
                      <>
                        <img src={preview} alt="Base" />
                        <img src={maskSrc} alt="Overlay" className="fade-in feature-overlay" />
                      </>
                    ) : <div className="empty-state">No Output</div>}
                 </div>
               </div>
             </div>
          </div>

        </div>
      </main>
    </div>
  );
}

function App() {
  const [view, setView] = useState<'landing' | 'dashboard'>('landing');

  return (
    <>
      {view === 'landing' ? <LandingPage onEnter={() => setView('dashboard')} /> : <Dashboard />}
    </>
  );
}

export default App;