scaffold: kind+Tilt cluster, api/ui/docs stubs, green at nvi.local.ar

This commit is contained in:
2026-06-03 00:33:51 -03:00
commit 131f4d9b86
39 changed files with 3571 additions and 0 deletions

14
ui/app/index.html Normal file
View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>nvi — analytics agent</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

23
ui/app/package.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "nvi-ui",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@vue-flow/core": "^1.48.2",
"soleprint-ui": "link:../framework",
"uplot": "^1.6.32",
"vue": "^3.5",
"vue-router": "^4.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5",
"typescript": "^5.7",
"vite": "^6.0"
}
}

114
ui/app/src/App.vue Normal file
View File

@@ -0,0 +1,114 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute()
// Docs live in a separate service. Resolve the URL from the current host so
// the same build works in dev (per-project subdomain) and in either AWS
// hosting mode (per-project or aggregated under docs.mcrn.ar/nivii).
const docsUrl = computed(() => {
const { protocol, hostname } = window.location
if (hostname.endsWith('.local.ar')) {
// dev: docs.nvi.local.ar (served by in-cluster Caddy)
return `${protocol}//docs.${hostname}`
}
if (hostname === 'nivii.mcrn.ar') {
// aws: aggregated docs site, nvi's entry is /nivii
return 'https://docs.mcrn.ar/nivii'
}
if (hostname === 'docs.nivii.mcrn.ar') {
// aws redundancy: per-project docs subdomain
return 'https://docs.nivii.mcrn.ar'
}
return '/docs/'
})
</script>
<template>
<div class="app">
<header class="app-header">
<div class="app-title">
<h1>NVI</h1>
<span class="app-subtitle">analytics agent</span>
</div>
<nav class="app-nav">
<router-link to="/" :class="{ active: route.path === '/' }">Ask</router-link>
<a :href="docsUrl" class="docs-link" target="_blank">Docs</a>
</nav>
</header>
<main class="app-main">
<router-view />
</main>
</div>
</template>
<style scoped>
.app {
display: flex;
flex-direction: column;
height: 100vh;
}
.app-header {
display: flex;
align-items: center;
gap: 24px;
padding: 12px 24px;
background: var(--surface-1);
border-bottom: var(--panel-border);
}
.app-title h1 {
font-family: var(--font-mono);
font-size: 18px;
font-weight: 600;
letter-spacing: 2px;
color: var(--accent);
}
.app-subtitle {
font-size: 11px;
color: var(--text-dim);
text-transform: uppercase;
letter-spacing: 1px;
}
.app-nav {
display: flex;
gap: 4px;
margin-left: auto;
}
.app-nav a {
padding: 6px 16px;
font-size: 13px;
font-family: var(--font-mono);
color: var(--text-secondary);
text-decoration: none;
border: var(--panel-border);
transition: all 0.15s;
}
.app-nav a:hover {
background: var(--surface-2);
color: var(--text-primary);
}
.app-nav a.active {
background: var(--accent-dim);
color: var(--text-primary);
border-color: var(--accent);
}
.app-nav .docs-link {
color: var(--text-dim);
font-size: 11px;
}
.app-main {
flex: 1;
overflow: auto;
padding: 24px;
}
</style>

16
ui/app/src/main.ts Normal file
View File

@@ -0,0 +1,16 @@
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import 'soleprint-ui/src/tokens.css'
import App from './App.vue'
import Ask from './pages/Ask.vue'
import RunInspector from './pages/RunInspector.vue'
const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', component: Ask },
{ path: '/runs/:id', component: RunInspector, props: true },
],
})
createApp(App).use(router).mount('#app')

80
ui/app/src/pages/Ask.vue Normal file
View File

@@ -0,0 +1,80 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const question = ref('Which districts had the sharpest rise in loan defaults?')
const submitting = ref(false)
const error = ref<string | null>(null)
const router = useRouter()
async function submit() {
if (!question.value.trim()) return
submitting.value = true
error.value = null
try {
const res = await fetch('/ask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question: question.value }),
})
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`)
const { run_id } = await res.json()
router.push(`/runs/${run_id}`)
} catch (e: any) {
error.value = e.message ?? String(e)
} finally {
submitting.value = false
}
}
</script>
<template>
<div class="ask">
<h2>Ask a question</h2>
<textarea v-model="question" rows="3" :disabled="submitting" />
<div class="actions">
<button @click="submit" :disabled="submitting || !question.trim()">
{{ submitting ? 'Submitting…' : 'Ask' }}
</button>
</div>
<p v-if="error" class="error">{{ error }}</p>
</div>
</template>
<style scoped>
.ask {
max-width: 720px;
display: flex;
flex-direction: column;
gap: 12px;
}
textarea {
background: var(--surface-2);
color: var(--text-primary);
border: var(--panel-border);
padding: 12px;
font-family: var(--font-mono);
font-size: 14px;
}
.actions {
display: flex;
justify-content: flex-end;
}
button {
padding: 8px 20px;
font-family: var(--font-mono);
background: var(--accent-dim);
color: var(--text-primary);
border: var(--panel-border);
cursor: pointer;
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.error {
color: var(--status-error, #f55);
font-family: var(--font-mono);
font-size: 12px;
}
</style>

View File

@@ -0,0 +1,47 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
const props = defineProps<{ id: string }>()
const state = ref<any>(null)
const error = ref<string | null>(null)
onMounted(async () => {
try {
const res = await fetch(`/runs/${props.id}`)
if (!res.ok) throw new Error(`${res.status}`)
state.value = await res.json()
} catch (e: any) {
error.value = e.message ?? String(e)
}
})
</script>
<template>
<div class="inspector">
<h2>Run {{ id }}</h2>
<p v-if="error" class="error">{{ error }}</p>
<pre v-else-if="state">{{ JSON.stringify(state, null, 2) }}</pre>
<p v-else>Loading</p>
</div>
</template>
<style scoped>
.inspector {
display: flex;
flex-direction: column;
gap: 12px;
}
pre {
background: var(--surface-2);
color: var(--text-primary);
border: var(--panel-border);
padding: 12px;
font-family: var(--font-mono);
font-size: 12px;
overflow: auto;
}
.error {
color: var(--status-error, #f55);
}
</style>

17
ui/app/tsconfig.json Normal file
View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"types": ["vite/client"]
},
"include": ["src/**/*", "src/**/*.vue"]
}

17
ui/app/vite.config.ts Normal file
View File

@@ -0,0 +1,17 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
port: 5173,
proxy: {
'/ask': 'http://localhost:8000',
'/runs': {
target: 'http://localhost:8000',
changeOrigin: true,
},
'/healthz': 'http://localhost:8000',
},
},
})