Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(05-01): add search route, schema, index registration, and client API function

Adam Eivyea077ee355d4
diff --git a/client/src/services/api.js b/client/src/services/api.js
index b307b8f66c..d1710c7685 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -40,6 +40,9 @@ async function request(endpoint, options = {}) {
return response.json();
}
+// Search
+export const search = (q) => request(`/search?q=${encodeURIComponent(q)}`);
+
// Apple Health
export const ingestAppleHealth = (data) => request('/health/ingest', {
method: 'POST',
diff --git a/server/index.js b/server/index.js
index 1b7450a03a..69841caac1 100644
--- a/server/index.js
+++ b/server/index.js
@@ -43,6 +43,7 @@ import insightsRoutes from './routes/insights.js';
import jiraRoutes from './routes/jira.js';
import autobiographyRoutes from './routes/autobiography.js';
import backupRoutes from './routes/backup.js';
+import searchRoutes from './routes/search.js';
import identityRoutes from './routes/identity.js';
import instancesRoutes from './routes/instances.js';
import meatspaceRoutes from './routes/meatspace.js';
@@ -190,6 +191,7 @@ app.use('/api/commands', commandsRoutes);
app.use('/api/git', gitRoutes);
app.use('/api/usage', usageRoutes);
app.use('/api/screenshots', screenshotsRoutes);
+app.use('/api/search', searchRoutes);
app.use('/api/attachments', attachmentsRoutes);
app.use('/api/backup', backupRoutes);
app.use('/api/uploads', uploadsRoutes);
diff --git a/server/lib/validation.js b/server/lib/validation.js
index cb1bf06450..61e9c9100a 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -407,6 +407,14 @@ export const insightRefreshSchema = z.object({
model: z.string().optional()
});
+// =============================================================================
+// SEARCH SCHEMAS
+// =============================================================================
+
+export const searchQuerySchema = z.object({
+ q: z.string().min(2).max(200).trim()
+});
+
// =============================================================================
// BACKUP SCHEMAS
// =============================================================================
diff --git a/server/routes/search.js b/server/routes/search.js
new file mode 100644
index 0000000000..9759b1e710
--- /dev/null
+++ b/server/routes/search.js
@@ -0,0 +1,23 @@
+/**
+ * Search Routes
+ *
+ * GET /api/search?q=<query>
+ * Fan-out keyword search across all PortOS data sources.
+ * Returns categorized results grouped by source.
+ */
+
+import { Router } from 'express';
+import { asyncHandler } from '../lib/errorHandler.js';
+import { validateRequest, searchQuerySchema } from '../lib/validation.js';
+import { fanOutSearch } from '../services/search.js';
+
+const router = Router();
+
+// GET /api/search?q=<query>
+router.get('/', asyncHandler(async (req, res) => {
+ const { q } = validateRequest(searchQuerySchema, req.query);
+ const sources = await fanOutSearch(q);
+ res.json({ query: q, sources });
+}));
+
+export default router;