oneie 3.6.7 → 3.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/agent-backend.md +83 -0
- package/.claude/agents/agent-designer.md +97 -0
- package/.claude/agents/agent-director.md +118 -7
- package/.claude/agents/agent-documenter.md +93 -0
- package/.claude/agents/agent-frontend.md +96 -0
- package/.claude/agents/agent-ops.md +264 -32
- package/.claude/agents/agent-problem-solver.md +166 -0
- package/.claude/agents/agent-quality.md +127 -0
- package/.claude/commands/build.md +293 -0
- package/.claude/commands/cascade.md +231 -127
- package/.claude/commands/deploy.md +56 -17
- package/.claude/commands/mcp-toggle.md +93 -0
- package/.claude/commands/one.md +78 -127
- package/.claude/commands/plan.md +394 -80
- package/.claude/commands/push.md +75 -14
- package/.claude/commands/release.md +89 -25
- package/.claude/commands/server.md +2 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/.claude/hooks/root-cleanup.py +75 -0
- package/.claude/skills/INDEX.md +523 -0
- package/.claude/skills/REGISTRY.md +529 -0
- package/.claude/skills/agent-backend-create-mutation.md +319 -0
- package/.claude/skills/agent-designer-create-wireframe.md +341 -0
- package/.claude/skills/agent-frontend-create-page.md +413 -0
- package/.claude/skills/agents/README.md +238 -0
- package/dist/clone-web.js +1 -1
- package/dist/clone-web.js.map +1 -1
- package/folders.yaml +1 -1
- package/one/.obsidian/workspace.json +38 -38
- package/one/connections/api/queries-reference.md +842 -0
- package/one/connections/api-reference.md +1011 -0
- package/one/connections/integration-examples.md +875 -0
- package/one/connections/integration-guide.md +869 -0
- package/one/connections/integration-phase2.md +736 -0
- package/one/events/API_ROUTES_FIXES_SUMMARY.md +262 -0
- package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +636 -0
- package/one/events/BEFORE_AFTER_COMPARISON.md +960 -0
- package/one/events/CONNECTIONS_DEMO.md +501 -0
- package/one/events/DELIVERABLES.md +432 -0
- package/one/events/DEMO-GROUPS-PAGE.md +392 -0
- package/one/events/DEMO-TESTING-SUMMARY.md +518 -0
- package/one/events/DEMO_COMPONENTS.md +487 -0
- package/one/events/DEMO_HOOKS_INDEX.md +334 -0
- package/one/events/DEMO_INFRASTRUCTURE.md +905 -0
- package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +570 -0
- package/one/events/DEMO_INTEGRATION_CHECKLIST.md +431 -0
- package/one/events/DEMO_QUICK_REFERENCE.md +441 -0
- package/one/events/DEMO_SETUP.md +476 -0
- package/one/events/EFFECT_TS_API_PATTERN.md +478 -0
- package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +414 -0
- package/one/events/HOOKS-DEMO.md +441 -0
- package/one/events/ONTOLOGY-HOOKS-README.md +700 -0
- package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +365 -0
- package/one/events/QA-CHECKLIST.md +674 -0
- package/one/events/QUICK-START-ONTOLOGY.md +408 -0
- package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +639 -0
- package/one/events/SEARCH_DEMO_DELIVERY.md +415 -0
- package/one/events/SEARCH_DEMO_SUMMARY.md +303 -0
- package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +381 -0
- package/one/events/TEST-PLAN-INDEX.md +346 -0
- package/one/events/TEST-PLAN.md +1417 -0
- package/one/events/TESTING-DELIVERY.txt +372 -0
- package/one/events/TRANSITIONS-QUICK-START.md +141 -0
- package/one/events/TYPESCRIPT_FIXES.md +152 -0
- package/one/events/TYPESCRIPT_FIXES_COMPLETE.txt +412 -0
- package/one/events/TYPESCRIPT_FIXES_INDEX.md +341 -0
- package/one/events/VIEW-TRANSITIONS.md +428 -0
- package/one/events/backend-integration-tests.md +606 -0
- package/one/events/backend-structure-diagram.txt +393 -0
- package/one/events/backend-structure-summary.txt +269 -0
- package/one/events/cloudflare-pages-infrastructure-setup.md +264 -0
- package/one/events/convex-analysis-index.md +304 -0
- package/one/events/convex-structure-analysis.md +700 -0
- package/one/events/design-spec-complete.md +208 -0
- package/one/events/ontology-test-examples.md +562 -0
- package/one/events/phase1-backend-implementation-complete.md +518 -0
- package/one/events/test-dashboard.md +345 -0
- package/one/events/test-index.md +361 -0
- package/one/events/test-report-ontology.md +582 -0
- package/one/events/testing-summary.md +344 -0
- package/one/groups/features.md +2878 -0
- package/one/groups/strategy copy.md +869 -0
- package/one/knowledge/backend-api-reference.md +710 -0
- package/one/knowledge/documentation-summary.md +285 -0
- package/one/knowledge/lessons-learned.md +294 -4
- package/one/knowledge/ontology-visual-guide.md +360 -0
- package/one/knowledge/ontology.md +9 -17
- package/one/things/demo-accessibility-animations.md +999 -0
- package/one/things/demo-components.md +1304 -0
- package/one/things/demo-design-summary.md +629 -0
- package/one/things/demo-design-system.md +919 -0
- package/one/things/demo-page-layouts.md +989 -0
- package/one/things/designs/accessibility-audit.md +790 -0
- package/one/things/designs/component-specifications.md +757 -0
- package/one/things/designs/design-overview.md +318 -0
- package/one/things/designs/design-tokens.md +414 -0
- package/one/things/designs/wireframes-dashboard.md +653 -0
- package/one/things/docs/api-requests.md +923 -0
- package/one/things/features/0 All Features.md +2 -0
- package/one/things/implementation/backend-guide.md +412 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +11 -8
- package/one/things/plans/2-sites.md +895 -0
- package/one/things/plans/ai-elements.md +1259 -0
- package/one/things/plans/ai-integration.md +947 -0
- package/one/things/plans/ai-sdk.md +761 -0
- package/one/things/plans/app.md +1 -1
- package/one/things/plans/architecture-summary.md +283 -0
- package/one/things/plans/async-ai-agents.md +215 -0
- package/one/things/plans/backend-agnostic-frontend.md +11 -6
- package/one/things/plans/backend-cleanup-quickstart.md +346 -0
- package/one/things/plans/backend-ontology-conformance.md +416 -0
- package/one/things/plans/backend-status.md +541 -0
- package/one/things/plans/backend-structure.md +799 -0
- package/one/things/plans/backend-target-structure.md +438 -0
- package/one/things/plans/backend.md +1133 -0
- package/one/things/plans/better-auth-any-backend.md +11 -11
- package/one/things/plans/cli-updates-required.md +280 -0
- package/one/things/plans/complete-step-by-step.md +1302 -0
- package/one/things/plans/convex-agents.md +1005 -0
- package/one/things/plans/deployment-architecture.md +426 -0
- package/one/things/plans/development-plan.md +1220 -0
- package/one/things/plans/effect.md +808 -48
- package/one/things/plans/integrate-frontend-and-backend.md +579 -0
- package/one/things/plans/mcp-clear-context-prompt.md +60 -0
- package/one/things/plans/mcp-simple.md +228 -0
- package/one/things/plans/one.md +8 -7
- package/one/things/plans/ontology-6-dimensions.md +20 -14
- package/one/things/plans/quick-wins.md +1273 -0
- package/one/things/plans/readme-backend-cleanup.md +361 -0
- package/one/things/plans/separate-demo.md +830 -0
- package/one/things/plans/separate.md +3 -3
- package/one/things/plans/sequence.md +1897 -0
- package/one/things/plans/sync-checklist.md +321 -0
- package/one/things/plans/unified-implementation-plan.md +3 -3
- package/one/things/plans/update-demos.md +513 -0
- package/package.json +1 -1
- package/.claude/agents/backend-specialist.md +0 -169
- package/.claude/agents/designer.md +0 -216
- package/.claude/agents/frontend-specialist.md +0 -236
- package/.claude/commands/done.md +0 -35
- package/.claude/commands/infer.md +0 -138
- package/.claude/commands/next.md +0 -53
- package/.claude/commands/one copy.md +0 -565
- package/.claude/commands/one-template.md +0 -106
- package/.claude/commands/one-v1.md +0 -609
- package/.claude/hooks/__pycache__/knowledge-post.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/knowledge-pre.cpython-313.pyc +0 -0
- package/one/groups/nine-padel-customers.md +0 -138
- package/one/groups/nine-padel-data-structure.md +0 -167
- package/one/groups/nine-padel-ontology-specification.md +0 -359
- package/one/groups/nine-padel-ontology.md +0 -143
- package/one/groups/nine-padel-strategy.md +0 -234
- package/one/groups/nine-padel.md +0 -211
- package/one/groups/nine-padle-contents.baked.md +0 -1252
- package/one/groups/nine-padle-contents.md +0 -6
- package/one/things/features/1-1-agent-prompts/design.md +0 -470
- package/one/things/features/1-1-agent-prompts/tests.md +0 -264
- package/one/things/features/1-2-yaml-orchestrator/design.md +0 -497
- package/one/things/features/1-2-yaml-orchestrator/tests.md +0 -227
- package/one/things/features/1-3-event-coordination/design.md +0 -544
- package/one/things/features/1-3-event-coordination/tests.md +0 -223
- package/one/things/features/1-4-knowledge-management/design.md +0 -609
- package/one/things/features/1-4-knowledge-management/tests.md +0 -195
- package/one/things/features/1-5-quality-loops/design.md +0 -797
- package/one/things/features/1-5-quality-loops/tests.md +0 -212
- package/one/things/features/1-6-numbering-structure/design.md +0 -610
- package/one/things/features/1-6-numbering-structure/tests.md +0 -213
- package/one/things/features/dataprovider-interface/1-tests.md +0 -1522
|
@@ -1,59 +1,544 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Effect.ts Integration Plan: Backend-Agnostic Architecture
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Status:** ✅ Phase 1-2 Complete (DataProvider + Services) | 🚧 Phases 3-7 In Progress
|
|
4
|
+
**Version:** 2.0.0 - Backend-Agnostic Edition
|
|
5
|
+
**Last Updated:** 2025-10-24
|
|
6
|
+
|
|
7
|
+
## Executive Summary
|
|
8
|
+
|
|
9
|
+
**Effect.ts powers the backend-agnostic architecture of ONE Platform** by providing type-safe, composable services that work with ANY backend (Convex, WordPress, Supabase, Notion, etc.). This document describes how Effect.ts integrates with the DataProvider pattern to enable:
|
|
10
|
+
|
|
11
|
+
1. **Backend Independence**: Frontend works with any backend that implements the 6-dimension ontology
|
|
12
|
+
2. **Type Safety**: Complete type inference from database to UI with zero runtime overhead
|
|
13
|
+
3. **Composability**: Services compose via Layer.mergeAll for dependency injection
|
|
14
|
+
4. **Error Handling**: Tagged errors replace try/catch throughout the stack
|
|
15
|
+
5. **Testing**: Mock providers enable isolated service testing
|
|
16
|
+
|
|
17
|
+
**Key Principle:** Build the architecture right. Build features once. Never refactor for flexibility.
|
|
18
|
+
|
|
19
|
+
Based on production patterns from 14.ai (AI customer support) and the unified implementation plan (11 weeks to complete platform).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Architecture Overview: The Three Layers
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
27
|
+
│ FRONTEND (Astro + React) │
|
|
28
|
+
│ - Backend-agnostic UI and pages │
|
|
29
|
+
│ - Uses services, never calls backend directly │
|
|
30
|
+
│ - Works with ANY backend via DataProvider │
|
|
31
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
32
|
+
↓
|
|
33
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
34
|
+
│ EFFECT.TS SERVICES (Backend-Agnostic) │
|
|
35
|
+
│ - ThingService (all 66 types) │
|
|
36
|
+
│ - ConnectionService (all 25 types) │
|
|
37
|
+
│ - EventService (all 67 events) │
|
|
38
|
+
│ - KnowledgeService (RAG + vectors) │
|
|
39
|
+
│ - GroupService, PeopleService │
|
|
40
|
+
│ │
|
|
41
|
+
│ ✅ Type-safe with tagged errors │
|
|
42
|
+
│ ✅ Composable via Layer.mergeAll │
|
|
43
|
+
│ ✅ Testable with mock providers │
|
|
44
|
+
│ ✅ Backend-agnostic via DataProvider │
|
|
45
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
46
|
+
↓
|
|
47
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
48
|
+
│ DATAPROVIDER INTERFACE (Universal Backend API) │
|
|
49
|
+
│ groups: { get, list, update } │
|
|
50
|
+
│ people: { get, list, create, update } │
|
|
51
|
+
│ things: { get, list, create, update, delete } │
|
|
52
|
+
│ connections: { create, getRelated, getCount } │
|
|
53
|
+
│ events: { log, query } │
|
|
54
|
+
│ knowledge: { embed, search } │
|
|
55
|
+
│ │
|
|
56
|
+
│ ✅ Implementation-agnostic interface │
|
|
57
|
+
│ ✅ 6-dimension ontology as contract │
|
|
58
|
+
│ ✅ Swap backends by changing ONE line │
|
|
59
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
60
|
+
↓
|
|
61
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
62
|
+
│ BACKEND PROVIDERS (Choose One - ONE Line Config!) │
|
|
63
|
+
│ │
|
|
64
|
+
│ ConvexProvider ✅ Complete │
|
|
65
|
+
│ WordPressProvider 🚧 Planned (Phase 7) │
|
|
66
|
+
│ SupabaseProvider 🚧 Planned (Phase 7) │
|
|
67
|
+
│ NotionProvider 🚧 Planned (Future) │
|
|
68
|
+
│ CustomProvider 🚧 Roll your own │
|
|
69
|
+
│ │
|
|
70
|
+
│ All implement the same DataProvider interface │
|
|
71
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Key Architectural Decisions
|
|
75
|
+
|
|
76
|
+
**1. Backend-Agnostic by Default**
|
|
77
|
+
- Services use `DataProvider`, not direct backend calls
|
|
78
|
+
- Frontend can work with Convex, WordPress, Supabase, etc.
|
|
79
|
+
- Change backend = edit ONE line in `astro.config.ts`
|
|
80
|
+
|
|
81
|
+
**2. 6-Dimension Ontology as Source of Truth**
|
|
82
|
+
- Every feature maps to: groups, people, things, connections, events, knowledge
|
|
83
|
+
- DataProvider interface enforces this structure
|
|
84
|
+
- Backends implement the ontology their own way (see `one/knowledge/ontology.md`)
|
|
85
|
+
|
|
86
|
+
**3. Effect.ts for Services, Not Everywhere**
|
|
87
|
+
- Backend: Effect.ts services with typed errors
|
|
88
|
+
- Frontend: Standard React hooks (useEffectRunner for complex flows)
|
|
89
|
+
- Keep it simple: Effect where it adds value, standard TypeScript elsewhere
|
|
90
|
+
|
|
91
|
+
**4. Separation Enables Installation**
|
|
92
|
+
- When users run `npx oneie`, they get frontend only
|
|
93
|
+
- Backend is OFF by default (users can connect their own)
|
|
94
|
+
- Organizations can use existing infrastructure (WordPress, Notion, etc.)
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Current Status (from unified-implementation-plan.md)
|
|
99
|
+
|
|
100
|
+
### ✅ COMPLETED (Phases 1-2: 4 weeks)
|
|
101
|
+
|
|
102
|
+
**Phase 1: DataProvider Foundation** ✅
|
|
103
|
+
- DataProvider interface complete: `/web/src/providers/DataProvider.ts`
|
|
104
|
+
- ConvexProvider implementation complete
|
|
105
|
+
- Typed errors (ThingNotFoundError, etc.)
|
|
106
|
+
- Backend swapping works (change ONE line)
|
|
107
|
+
|
|
108
|
+
**Phase 2: Effect.ts Service Layer** ✅
|
|
109
|
+
- All 6 dimension services complete:
|
|
110
|
+
- `/web/src/services/ThingService.ts` (66 types)
|
|
111
|
+
- `/web/src/services/ConnectionService.ts` (25 types)
|
|
112
|
+
- `/web/src/services/EventService.ts` (67 events)
|
|
113
|
+
- `/web/src/services/KnowledgeService.ts` (RAG)
|
|
114
|
+
- `/web/src/services/GroupService.ts`
|
|
115
|
+
- `/web/src/services/PeopleService.ts`
|
|
116
|
+
- React hooks: `useEffectRunner` in `/web/src/hooks/`
|
|
117
|
+
- Dependency injection via Layer.mergeAll
|
|
118
|
+
- Tagged errors throughout (no try/catch)
|
|
119
|
+
|
|
120
|
+
### 🚧 REMAINING (Phases 3-7: 7 weeks)
|
|
121
|
+
|
|
122
|
+
**Phase 3: Backend Implementation** (NOT STARTED)
|
|
123
|
+
- Implement CRUD mutations for all 66 thing types
|
|
124
|
+
- Add event logging to all mutations
|
|
125
|
+
- Enforce group scoping
|
|
126
|
+
- Add rate limiting
|
|
127
|
+
|
|
128
|
+
**Phase 4: Frontend Integration** (NOT STARTED)
|
|
129
|
+
- Multi-tenant dashboard
|
|
130
|
+
- Entity management UI (all 66 types)
|
|
131
|
+
- Connection visualization
|
|
132
|
+
- Real-time event timeline
|
|
133
|
+
|
|
134
|
+
**Phase 5: RAG & Knowledge** (NOT STARTED)
|
|
135
|
+
- Chunking service (800 tokens, 200 overlap)
|
|
136
|
+
- Embedding service (OpenAI integration)
|
|
137
|
+
- RAG ingestion pipeline
|
|
138
|
+
- Vector search
|
|
139
|
+
|
|
140
|
+
**Phase 6: Testing** (PARTIAL - auth tests exist)
|
|
141
|
+
- Backend service coverage (90%)
|
|
142
|
+
- Frontend coverage (70%)
|
|
143
|
+
- Multi-backend tests
|
|
144
|
+
- CI/CD pipeline
|
|
145
|
+
|
|
146
|
+
**Phase 7: Multi-Backend** (OPTIONAL)
|
|
147
|
+
- WordPressProvider
|
|
148
|
+
- SupabaseProvider
|
|
149
|
+
- CompositeProvider (multi-backend routing)
|
|
150
|
+
|
|
151
|
+
---
|
|
4
152
|
|
|
5
153
|
## Integration approaches
|
|
6
154
|
|
|
7
|
-
### Understanding confect's role
|
|
155
|
+
### Understanding confect's role (Optional - For Convex Backend Only)
|
|
8
156
|
|
|
9
157
|
Confect isn't just a thin wrapper—it's a comprehensive framework that **deeply integrates Effect.ts with Convex**. Created by RJ Dellecese, confect replaces Convex's native validator system with Effect's schema library and transforms all Convex APIs to return `Effect` types instead of `Promise`. Where Convex returns `A | null`, confect returns `Option<A>`, and errors become explicit in the Effect type signature. This provides end-to-end type safety from database operations through business logic to HTTP APIs with automatic OpenAPI documentation.
|
|
10
158
|
|
|
11
|
-
### Project structure with Effect
|
|
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
|
-
└──
|
|
159
|
+
### Project structure with backend-agnostic Effect.ts
|
|
160
|
+
|
|
161
|
+
ONE Platform uses a clean separation between frontend (Effect.ts services) and backend (any provider):
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
ONE/
|
|
165
|
+
├── web/ # Frontend (Backend-Agnostic)
|
|
166
|
+
│ ├── src/
|
|
167
|
+
│ │ ├── pages/ # Astro pages (SSR)
|
|
168
|
+
│ │ ├── components/ # React components + shadcn/ui
|
|
169
|
+
│ │ ├── services/ # ✅ Effect.ts services (backend-agnostic)
|
|
170
|
+
│ │ │ ├── ThingService.ts
|
|
171
|
+
│ │ │ ├── ConnectionService.ts
|
|
172
|
+
│ │ │ ├── EventService.ts
|
|
173
|
+
│ │ │ ├── KnowledgeService.ts
|
|
174
|
+
│ │ │ ├── GroupService.ts
|
|
175
|
+
│ │ │ └── PeopleService.ts
|
|
176
|
+
│ │ ├── providers/ # ✅ DataProvider interface & implementations
|
|
177
|
+
│ │ │ ├── DataProvider.ts # Universal interface
|
|
178
|
+
│ │ │ ├── convex/
|
|
179
|
+
│ │ │ │ └── ConvexProvider.ts # Convex implementation
|
|
180
|
+
│ │ │ ├── wordpress/
|
|
181
|
+
│ │ │ │ └── WordPressProvider.ts # WordPress implementation (planned)
|
|
182
|
+
│ │ │ └── supabase/
|
|
183
|
+
│ │ │ └── SupabaseProvider.ts # Supabase implementation (planned)
|
|
184
|
+
│ │ ├── hooks/ # React hooks
|
|
185
|
+
│ │ │ ├── useEffectRunner.ts # Run Effect programs in React
|
|
186
|
+
│ │ │ └── useProvider.ts # Access current DataProvider
|
|
187
|
+
│ │ └── lib/
|
|
188
|
+
│ │ └── errors.ts # Tagged error types
|
|
189
|
+
│ └── astro.config.ts # ✅ Configure provider here (ONE LINE!)
|
|
190
|
+
│
|
|
191
|
+
├── backend/ # Backend (Convex - OPTIONAL)
|
|
192
|
+
│ └── convex/
|
|
193
|
+
│ ├── schema.ts # 6-dimension ontology (groups, entities, connections, events, knowledge)
|
|
194
|
+
│ ├── auth.ts # Better Auth configuration
|
|
195
|
+
│ ├── queries/ # Read operations
|
|
196
|
+
│ ├── mutations/ # Write operations
|
|
197
|
+
│ └── _generated/ # Auto-generated types
|
|
198
|
+
│
|
|
199
|
+
├── one/ # Platform documentation (41 files)
|
|
200
|
+
│ ├── knowledge/
|
|
201
|
+
│ │ ├── ontology.md # ✅ 6-dimension data model (source of truth)
|
|
202
|
+
│ │ └── todo.md # 100-inference execution template
|
|
203
|
+
│ └── things/plans/
|
|
204
|
+
│ ├── effect.md # This file
|
|
205
|
+
│ ├── separate.md # Backend separation plan
|
|
206
|
+
│ └── unified-implementation-plan.md # Complete 11-week plan
|
|
207
|
+
│
|
|
208
|
+
└── apps/ # Distribution targets
|
|
209
|
+
├── oneie/ # Main site (one.ie) - backend ON
|
|
210
|
+
└── one/ # Demo site (demo.one.ie) - backend OFF
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Key Differences from Standard Convex:**
|
|
214
|
+
1. Services live in `/web/src/services/` (not backend)
|
|
215
|
+
2. Services use `DataProvider` (not direct Convex calls)
|
|
216
|
+
3. Backend is optional (users can bring their own)
|
|
217
|
+
4. Frontend works standalone with mock providers for testing
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## The Backend-Agnostic Pattern (Current Implementation)
|
|
222
|
+
|
|
223
|
+
### DataProvider Interface (Universal Contract)
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
// web/src/providers/DataProvider.ts
|
|
227
|
+
import { Effect, Context } from "effect";
|
|
228
|
+
|
|
229
|
+
// Universal interface ALL backends implement
|
|
230
|
+
export interface DataProvider {
|
|
231
|
+
// Dimension 1: Groups
|
|
232
|
+
groups: {
|
|
233
|
+
get: (id: string) => Effect.Effect<Group, GroupNotFoundError>;
|
|
234
|
+
list: (params?: { status?: string }) => Effect.Effect<Group[], Error>;
|
|
235
|
+
update: (id: string, updates: Partial<Group>) => Effect.Effect<void, Error>;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// Dimension 2: People
|
|
239
|
+
people: {
|
|
240
|
+
get: (id: string) => Effect.Effect<Person, PersonNotFoundError>;
|
|
241
|
+
list: (params: { groupId?: string; role?: string }) => Effect.Effect<Person[], Error>;
|
|
242
|
+
create: (input: CreatePersonInput) => Effect.Effect<string, Error>;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// Dimension 3: Things
|
|
246
|
+
things: {
|
|
247
|
+
get: (id: string) => Effect.Effect<Thing, ThingNotFoundError>;
|
|
248
|
+
list: (params: { type: ThingType; groupId?: string }) => Effect.Effect<Thing[], Error>;
|
|
249
|
+
create: (input: CreateThingInput) => Effect.Effect<string, Error>;
|
|
250
|
+
update: (id: string, updates: Partial<Thing>) => Effect.Effect<void, Error>;
|
|
251
|
+
delete: (id: string) => Effect.Effect<void, Error>;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// Dimension 4: Connections
|
|
255
|
+
connections: {
|
|
256
|
+
create: (input: CreateConnectionInput) => Effect.Effect<string, Error>;
|
|
257
|
+
getRelated: (thingId: string) => Effect.Effect<Connection[], Error>;
|
|
258
|
+
getCount: (thingId: string) => Effect.Effect<number, Error>;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// Dimension 5: Events
|
|
262
|
+
events: {
|
|
263
|
+
log: (event: LogEventInput) => Effect.Effect<void, Error>;
|
|
264
|
+
query: (params: QueryEventsInput) => Effect.Effect<Event[], Error>;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// Dimension 6: Knowledge
|
|
268
|
+
knowledge: {
|
|
269
|
+
embed: (text: string) => Effect.Effect<number[], Error>;
|
|
270
|
+
search: (params: SearchKnowledgeInput) => Effect.Effect<KnowledgeChunk[], Error>;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export const DataProvider = Context.GenericTag<DataProvider>("DataProvider");
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Backend-Agnostic Service Example
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
// web/src/services/ThingService.ts
|
|
281
|
+
import { Effect } from "effect";
|
|
282
|
+
import { DataProvider } from "@/providers/DataProvider";
|
|
283
|
+
|
|
284
|
+
export class ThingService extends Effect.Service<ThingService>()(
|
|
285
|
+
"ThingService",
|
|
286
|
+
{
|
|
287
|
+
effect: Effect.gen(function* () {
|
|
288
|
+
const provider = yield* DataProvider; // Backend-agnostic!
|
|
289
|
+
|
|
290
|
+
return {
|
|
291
|
+
// Create any of the 66 thing types
|
|
292
|
+
create: (type: ThingType, input: CreateThingInput) =>
|
|
293
|
+
Effect.gen(function* () {
|
|
294
|
+
// 1. Validate input (same for all backends)
|
|
295
|
+
yield* validateThingInput(type, input);
|
|
296
|
+
|
|
297
|
+
// 2. Create via provider (backend-specific implementation)
|
|
298
|
+
const thingId = yield* provider.things.create({
|
|
299
|
+
type,
|
|
300
|
+
name: input.name,
|
|
301
|
+
groupId: input.groupId,
|
|
302
|
+
properties: input.properties,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// 3. Log event automatically (via provider)
|
|
306
|
+
yield* provider.events.log({
|
|
307
|
+
type: "entity_created",
|
|
308
|
+
actorId: input.actorId,
|
|
309
|
+
targetId: thingId,
|
|
310
|
+
groupId: input.groupId,
|
|
311
|
+
metadata: { thingType: type },
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
return thingId;
|
|
315
|
+
}),
|
|
316
|
+
|
|
317
|
+
// Get thing by ID
|
|
318
|
+
get: (id: string) => provider.things.get(id),
|
|
319
|
+
|
|
320
|
+
// List things by type
|
|
321
|
+
list: (type: ThingType, groupId: string) =>
|
|
322
|
+
provider.things.list({ type, groupId }),
|
|
323
|
+
|
|
324
|
+
// Update thing
|
|
325
|
+
update: (id: string, updates: Partial<Thing>) =>
|
|
326
|
+
Effect.gen(function* () {
|
|
327
|
+
yield* provider.things.update(id, updates);
|
|
328
|
+
|
|
329
|
+
// Log event
|
|
330
|
+
yield* provider.events.log({
|
|
331
|
+
type: "entity_updated",
|
|
332
|
+
actorId: updates.actorId,
|
|
333
|
+
targetId: id,
|
|
334
|
+
groupId: updates.groupId,
|
|
335
|
+
metadata: { updates },
|
|
336
|
+
});
|
|
337
|
+
}),
|
|
338
|
+
};
|
|
339
|
+
}),
|
|
340
|
+
dependencies: [DataProvider], // Inject provider
|
|
341
|
+
}
|
|
342
|
+
) {}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### ConvexProvider Implementation
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
// web/src/providers/convex/ConvexProvider.ts
|
|
349
|
+
import { Effect, Layer } from "effect";
|
|
350
|
+
import { ConvexHttpClient } from "convex/browser";
|
|
351
|
+
import { DataProvider } from "../DataProvider";
|
|
352
|
+
import { api } from "@/convex/_generated/api";
|
|
353
|
+
|
|
354
|
+
export class ConvexProvider implements DataProvider {
|
|
355
|
+
constructor(private client: ConvexHttpClient) {}
|
|
356
|
+
|
|
357
|
+
things = {
|
|
358
|
+
create: (input) =>
|
|
359
|
+
Effect.tryPromise({
|
|
360
|
+
try: () => this.client.mutation(api.mutations.things.create, input),
|
|
361
|
+
catch: (error) => new Error(String(error)),
|
|
362
|
+
}),
|
|
363
|
+
|
|
364
|
+
get: (id) =>
|
|
365
|
+
Effect.tryPromise({
|
|
366
|
+
try: () => this.client.query(api.queries.things.get, { id }),
|
|
367
|
+
catch: (error) => new ThingNotFoundError(id),
|
|
368
|
+
}),
|
|
369
|
+
|
|
370
|
+
list: (params) =>
|
|
371
|
+
Effect.tryPromise({
|
|
372
|
+
try: () => this.client.query(api.queries.things.list, params),
|
|
373
|
+
catch: (error) => new Error(String(error)),
|
|
374
|
+
}),
|
|
375
|
+
|
|
376
|
+
update: (id, updates) =>
|
|
377
|
+
Effect.tryPromise({
|
|
378
|
+
try: () => this.client.mutation(api.mutations.things.update, { id, ...updates }),
|
|
379
|
+
catch: (error) => new Error(String(error)),
|
|
380
|
+
}),
|
|
381
|
+
|
|
382
|
+
delete: (id) =>
|
|
383
|
+
Effect.tryPromise({
|
|
384
|
+
try: () => this.client.mutation(api.mutations.things.delete, { id }),
|
|
385
|
+
catch: (error) => new Error(String(error)),
|
|
386
|
+
}),
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// ... implement other dimensions (people, groups, connections, events, knowledge)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export const convexProvider = (config: { url: string }) =>
|
|
393
|
+
Layer.succeed(
|
|
394
|
+
DataProvider,
|
|
395
|
+
new ConvexProvider(new ConvexHttpClient(config.url))
|
|
396
|
+
);
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Configure Provider (ONE LINE!)
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
// web/astro.config.ts
|
|
403
|
+
import { defineConfig } from "astro/config";
|
|
404
|
+
import react from "@astrojs/react";
|
|
405
|
+
import { convexProvider } from "./src/providers/convex";
|
|
406
|
+
// import { wordpressProvider } from "./src/providers/wordpress"; // Alternative
|
|
407
|
+
// import { supabaseProvider } from "./src/providers/supabase"; // Alternative
|
|
408
|
+
|
|
409
|
+
export default defineConfig({
|
|
410
|
+
integrations: [
|
|
411
|
+
react(),
|
|
412
|
+
one({
|
|
413
|
+
// ✅ Change this ONE line to swap backends!
|
|
414
|
+
provider: convexProvider({ url: import.meta.env.PUBLIC_CONVEX_URL }),
|
|
415
|
+
|
|
416
|
+
// OR use WordPress:
|
|
417
|
+
// provider: wordpressProvider({ url: "https://blog.com", apiKey: env.WP_KEY }),
|
|
418
|
+
|
|
419
|
+
// OR use Supabase:
|
|
420
|
+
// provider: supabaseProvider({ url: env.SUPABASE_URL, key: env.SUPABASE_KEY }),
|
|
421
|
+
}),
|
|
422
|
+
],
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Frontend Usage (Completely Backend-Agnostic)
|
|
427
|
+
|
|
428
|
+
```tsx
|
|
429
|
+
// web/src/components/CreateCourse.tsx
|
|
430
|
+
import { useEffectRunner } from "@/hooks/useEffectRunner";
|
|
431
|
+
import { ThingService } from "@/services/ThingService";
|
|
432
|
+
import { Effect } from "effect";
|
|
433
|
+
|
|
434
|
+
export function CreateCourseForm() {
|
|
435
|
+
const { run, loading } = useEffectRunner();
|
|
436
|
+
|
|
437
|
+
const handleSubmit = async (formData: CourseFormData) => {
|
|
438
|
+
// Define Effect program
|
|
439
|
+
const program = Effect.gen(function* () {
|
|
440
|
+
const thingService = yield* ThingService;
|
|
441
|
+
|
|
442
|
+
// This works with ANY backend (Convex, WordPress, Supabase, etc.)!
|
|
443
|
+
const courseId = yield* thingService.create("course", {
|
|
444
|
+
name: formData.name,
|
|
445
|
+
groupId: currentGroup.id,
|
|
446
|
+
properties: {
|
|
447
|
+
description: formData.description,
|
|
448
|
+
price: formData.price,
|
|
449
|
+
duration: formData.duration,
|
|
450
|
+
},
|
|
451
|
+
actorId: currentUser.id,
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
return courseId;
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// Run program (uses configured provider automatically)
|
|
458
|
+
const courseId = await run(program);
|
|
459
|
+
|
|
460
|
+
// Redirect to course page
|
|
461
|
+
navigate(`/courses/${courseId}`);
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
return <form onSubmit={handleSubmit}>...</form>;
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Benefits of This Architecture
|
|
469
|
+
|
|
470
|
+
**1. True Backend Independence**
|
|
471
|
+
- Frontend code never imports backend-specific modules
|
|
472
|
+
- Services use DataProvider interface only
|
|
473
|
+
- Swap backends without changing a single service or component
|
|
474
|
+
|
|
475
|
+
**2. Testing Without Backend**
|
|
476
|
+
```typescript
|
|
477
|
+
// web/src/services/__tests__/ThingService.test.ts
|
|
478
|
+
import { Effect, Layer } from "effect";
|
|
479
|
+
import { ThingService } from "../ThingService";
|
|
480
|
+
|
|
481
|
+
const MockProvider = Layer.succeed(
|
|
482
|
+
DataProvider,
|
|
483
|
+
{
|
|
484
|
+
things: {
|
|
485
|
+
create: (input) => Effect.succeed("mock-id-123"),
|
|
486
|
+
get: (id) => Effect.succeed({ _id: id, type: "course", name: "Test" }),
|
|
487
|
+
// ... other methods
|
|
488
|
+
},
|
|
489
|
+
// ... other dimensions
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
test("should create course", async () => {
|
|
494
|
+
const program = Effect.gen(function* () {
|
|
495
|
+
const service = yield* ThingService;
|
|
496
|
+
return yield* service.create("course", { ... });
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
const result = await Effect.runPromise(
|
|
500
|
+
program.pipe(Effect.provide(MockProvider))
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
expect(result).toBe("mock-id-123");
|
|
504
|
+
});
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**3. Organizations Use Existing Infrastructure**
|
|
508
|
+
```typescript
|
|
509
|
+
// Organization A: Uses Convex (real-time)
|
|
510
|
+
provider: convexProvider({ url: "..." })
|
|
511
|
+
|
|
512
|
+
// Organization B: Uses WordPress (existing CMS)
|
|
513
|
+
provider: wordpressProvider({ url: "https://blog.org", apiKey: "..." })
|
|
514
|
+
|
|
515
|
+
// Organization C: Uses Supabase (PostgreSQL)
|
|
516
|
+
provider: supabaseProvider({ url: "...", key: "..." })
|
|
517
|
+
|
|
518
|
+
// Same frontend code works for all three!
|
|
55
519
|
```
|
|
56
520
|
|
|
521
|
+
**4. Deployment Flexibility**
|
|
522
|
+
```bash
|
|
523
|
+
# Development: Full stack
|
|
524
|
+
ONE_BACKEND=on
|
|
525
|
+
|
|
526
|
+
# Production (one.ie): Backend enabled
|
|
527
|
+
ONE_BACKEND=on
|
|
528
|
+
|
|
529
|
+
# Demo (demo.one.ie): Backend disabled
|
|
530
|
+
ONE_BACKEND=off
|
|
531
|
+
|
|
532
|
+
# User installation (npx oneie): Backend OFF by default
|
|
533
|
+
ONE_BACKEND=off
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## Optional: Convex-Specific Integration with confect
|
|
539
|
+
|
|
540
|
+
**Note:** This section is only relevant if you're using Convex as your backend AND want deeper Effect.ts integration in the backend layer. For most use cases, the DataProvider pattern above is sufficient.
|
|
541
|
+
|
|
57
542
|
### Schema definition with confect
|
|
58
543
|
|
|
59
544
|
Replace Convex validators with Effect schemas for stronger type guarantees:
|
|
@@ -970,4 +1455,279 @@ const robustAgentGeneration = (prompt: string) =>
|
|
|
970
1455
|
);
|
|
971
1456
|
```
|
|
972
1457
|
|
|
973
|
-
This integration of Effect.ts and confect into your Astro-shadcn-Convex stack provides industrial-strength reliability for production AI agents. The combination delivers type safety, robust error handling, and reactive data synchronization—critical capabilities for systems that users depend on. Start with confect for schema-first database design, introduce Effect for LLM integration with retry logic, and structure your agent logic as composable services. The learning investment pays dividends in reduced bugs, improved testability, and cleaner codebase architecture.
|
|
1458
|
+
This integration of Effect.ts and confect into your Astro-shadcn-Convex stack provides industrial-strength reliability for production AI agents. The combination delivers type safety, robust error handling, and reactive data synchronization—critical capabilities for systems that users depend on. Start with confect for schema-first database design, introduce Effect for LLM integration with retry logic, and structure your agent logic as composable services. The learning investment pays dividends in reduced bugs, improved testability, and cleaner codebase architecture.
|
|
1459
|
+
|
|
1460
|
+
---
|
|
1461
|
+
|
|
1462
|
+
## Summary: How Everything Connects
|
|
1463
|
+
|
|
1464
|
+
### The Complete Picture
|
|
1465
|
+
|
|
1466
|
+
```
|
|
1467
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
1468
|
+
│ ONE Platform Architecture │
|
|
1469
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
1470
|
+
|
|
1471
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
1472
|
+
│ 1. SOURCE OF TRUTH: 6-Dimension Ontology (one/knowledge/) │
|
|
1473
|
+
│ - Groups (multi-tenant isolation, hierarchical nesting) │
|
|
1474
|
+
│ - People (authorization & governance) │
|
|
1475
|
+
│ - Things (66 types: creators, courses, tokens, agents...) │
|
|
1476
|
+
│ - Connections (25 types: owns, follows, enrolled_in...) │
|
|
1477
|
+
│ - Events (67 types: created, purchased, completed...) │
|
|
1478
|
+
│ - Knowledge (RAG: labels, chunks, vectors) │
|
|
1479
|
+
│ │
|
|
1480
|
+
│ ✅ Universal data model for ALL features │
|
|
1481
|
+
│ ✅ Scales from children to enterprises │
|
|
1482
|
+
│ ✅ Never needs breaking changes │
|
|
1483
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
1484
|
+
↓
|
|
1485
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
1486
|
+
│ 2. BACKEND-AGNOSTIC SERVICES: Effect.ts (web/src/services/) │
|
|
1487
|
+
│ - ThingService (create, get, list, update, delete) │
|
|
1488
|
+
│ - ConnectionService (create, getRelated, getCount) │
|
|
1489
|
+
│ - EventService (log, query) │
|
|
1490
|
+
│ - KnowledgeService (embed, search) │
|
|
1491
|
+
│ - GroupService, PeopleService │
|
|
1492
|
+
│ │
|
|
1493
|
+
│ ✅ Use DataProvider interface (not backend-specific) │
|
|
1494
|
+
│ ✅ Tagged errors (no try/catch) │
|
|
1495
|
+
│ ✅ Composable via Layer.mergeAll │
|
|
1496
|
+
│ ✅ Testable with mock providers │
|
|
1497
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
1498
|
+
↓
|
|
1499
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
1500
|
+
│ 3. DATAPROVIDER INTERFACE (web/src/providers/) │
|
|
1501
|
+
│ - Universal contract ALL backends implement │
|
|
1502
|
+
│ - Enforces 6-dimension ontology structure │
|
|
1503
|
+
│ - Swap backends by changing ONE line │
|
|
1504
|
+
│ │
|
|
1505
|
+
│ Current: ConvexProvider ✅ │
|
|
1506
|
+
│ Planned: WordPressProvider, SupabaseProvider 🚧 │
|
|
1507
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
1508
|
+
↓
|
|
1509
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
1510
|
+
│ 4. FRONTEND (web/src/) │
|
|
1511
|
+
│ - Astro 5 pages (SSR) │
|
|
1512
|
+
│ - React 19 components (islands) │
|
|
1513
|
+
│ - shadcn/ui (50+ components) │
|
|
1514
|
+
│ - Tailwind v4 (CSS config) │
|
|
1515
|
+
│ │
|
|
1516
|
+
│ ✅ Uses services, never calls backend directly │
|
|
1517
|
+
│ ✅ Works with ANY backend via DataProvider │
|
|
1518
|
+
│ ✅ Can run without backend (demo mode) │
|
|
1519
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
1520
|
+
↓
|
|
1521
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
1522
|
+
│ 5. DEPLOYMENT (Release Strategy) │
|
|
1523
|
+
│ │
|
|
1524
|
+
│ Development (/web) → git push │
|
|
1525
|
+
│ ↓ │
|
|
1526
|
+
│ one-ie/web (website source) │
|
|
1527
|
+
│ ↓ │
|
|
1528
|
+
│ ┌────────────────┬──────────────────┐ │
|
|
1529
|
+
│ ↓ ↓ ↓ │
|
|
1530
|
+
│ one.ie demo.one.ie npx oneie │
|
|
1531
|
+
│ (full) (demo) (install) │
|
|
1532
|
+
│ Backend ON Backend OFF Backend OFF │
|
|
1533
|
+
│ │
|
|
1534
|
+
│ ✅ Single codebase │
|
|
1535
|
+
│ ✅ Multiple deployments │
|
|
1536
|
+
│ ✅ Environment-based features │
|
|
1537
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
### Key Principles Realized
|
|
1541
|
+
|
|
1542
|
+
**1. ONE Ontology = Universal Data Model**
|
|
1543
|
+
- Every feature maps to 6 dimensions
|
|
1544
|
+
- DataProvider interface enforces this structure
|
|
1545
|
+
- Backends implement the ontology their way (Convex uses 5 tables, WordPress uses posts/meta, Supabase uses PostgreSQL schema)
|
|
1546
|
+
- Frontend doesn't care HOW data is stored, only THAT it follows the ontology
|
|
1547
|
+
|
|
1548
|
+
**2. Backend-Agnostic = Maximum Flexibility**
|
|
1549
|
+
- Services use `DataProvider` (not Convex directly)
|
|
1550
|
+
- Organizations can use existing infrastructure (WordPress, Notion, etc.)
|
|
1551
|
+
- Frontend can run standalone (demo mode, testing, development)
|
|
1552
|
+
- Change backend = edit ONE line in `astro.config.ts`
|
|
1553
|
+
|
|
1554
|
+
**3. Effect.ts = Type-Safe Services**
|
|
1555
|
+
- Tagged errors replace try/catch throughout services
|
|
1556
|
+
- Dependency injection via Layer.mergeAll
|
|
1557
|
+
- Testable with mock providers (no backend required)
|
|
1558
|
+
- Optional: Deep Convex integration with confect for advanced use cases
|
|
1559
|
+
|
|
1560
|
+
**4. Separation Enables Distribution**
|
|
1561
|
+
```bash
|
|
1562
|
+
# When users run:
|
|
1563
|
+
npx oneie
|
|
1564
|
+
|
|
1565
|
+
# They get:
|
|
1566
|
+
- Frontend (web/) ✅
|
|
1567
|
+
- Documentation (one/) ✅
|
|
1568
|
+
- Claude config (.claude/) ✅
|
|
1569
|
+
- Backend OFF by default ✅
|
|
1570
|
+
|
|
1571
|
+
# Organizations can:
|
|
1572
|
+
- Use existing WordPress/Notion ✅
|
|
1573
|
+
- Connect their own Convex ✅
|
|
1574
|
+
- Build custom DataProvider ✅
|
|
1575
|
+
```
|
|
1576
|
+
|
|
1577
|
+
### Release Strategy (architecture-summary.md)
|
|
1578
|
+
|
|
1579
|
+
**Single Source → Multiple Targets**
|
|
1580
|
+
|
|
1581
|
+
```
|
|
1582
|
+
/web (development - full features)
|
|
1583
|
+
↓
|
|
1584
|
+
git push → one-ie/web (website source)
|
|
1585
|
+
↓
|
|
1586
|
+
./scripts/release.sh patch main
|
|
1587
|
+
→ apps/oneie/ → git push → one-ie/oneie → one.ie (backend ON)
|
|
1588
|
+
|
|
1589
|
+
./scripts/release.sh patch demo
|
|
1590
|
+
→ apps/one/ → git push → one-ie/one → demo.one.ie (backend OFF)
|
|
1591
|
+
```
|
|
1592
|
+
|
|
1593
|
+
**Environment Configuration:**
|
|
1594
|
+
|
|
1595
|
+
```bash
|
|
1596
|
+
# Development (.env.local)
|
|
1597
|
+
ONE_BACKEND=on
|
|
1598
|
+
ENABLE_ADMIN_FEATURES=true
|
|
1599
|
+
|
|
1600
|
+
# Production one.ie (.env.main)
|
|
1601
|
+
ONE_BACKEND=on
|
|
1602
|
+
ENABLE_ADMIN_FEATURES=false
|
|
1603
|
+
|
|
1604
|
+
# Demo demo.one.ie (.env.demo)
|
|
1605
|
+
ONE_BACKEND=off
|
|
1606
|
+
ENABLE_ADMIN_FEATURES=false
|
|
1607
|
+
|
|
1608
|
+
# User installation (npx oneie)
|
|
1609
|
+
ONE_BACKEND=off # Default
|
|
1610
|
+
```
|
|
1611
|
+
|
|
1612
|
+
### Implementation Status (unified-implementation-plan.md)
|
|
1613
|
+
|
|
1614
|
+
**✅ COMPLETE (Phases 1-2: 4 weeks)**
|
|
1615
|
+
- DataProvider interface and ConvexProvider
|
|
1616
|
+
- All 6 Effect.ts services (Thing, Connection, Event, Knowledge, Group, People)
|
|
1617
|
+
- React hooks (useEffectRunner, useProvider)
|
|
1618
|
+
- Tagged errors throughout
|
|
1619
|
+
- Backend-agnostic architecture validated
|
|
1620
|
+
|
|
1621
|
+
**🚧 IN PROGRESS (Phases 3-7: 7 weeks remaining)**
|
|
1622
|
+
- Phase 3: Backend implementation (66 thing types, event logging, group scoping)
|
|
1623
|
+
- Phase 4: Frontend integration (multi-tenant dashboard, entity management UI)
|
|
1624
|
+
- Phase 5: RAG & Knowledge (chunking, embedding, vector search)
|
|
1625
|
+
- Phase 6: Testing (90% backend coverage, 70% frontend coverage)
|
|
1626
|
+
- Phase 7: Multi-Backend (WordPress, Supabase, Composite providers) - OPTIONAL
|
|
1627
|
+
|
|
1628
|
+
### How to Use This Document
|
|
1629
|
+
|
|
1630
|
+
**For AI Agents:**
|
|
1631
|
+
1. Read `one/knowledge/ontology.md` first (6-dimension model)
|
|
1632
|
+
2. Implement features using Effect.ts services (backend-agnostic)
|
|
1633
|
+
3. Services use DataProvider (never call backend directly)
|
|
1634
|
+
4. Follow the 100-inference sequence in `one/knowledge/todo.md`
|
|
1635
|
+
|
|
1636
|
+
**For Developers:**
|
|
1637
|
+
1. Frontend development: Use Effect.ts services via hooks
|
|
1638
|
+
2. Backend development: Implement DataProvider for your backend
|
|
1639
|
+
3. Testing: Use mock providers (no backend required)
|
|
1640
|
+
4. Deployment: Configure provider in `astro.config.ts` (ONE LINE!)
|
|
1641
|
+
|
|
1642
|
+
**For Organizations:**
|
|
1643
|
+
1. Install: `npx oneie` (gets frontend only, backend OFF)
|
|
1644
|
+
2. Choose backend: Convex, WordPress, Supabase, or custom
|
|
1645
|
+
3. Implement DataProvider for your chosen backend
|
|
1646
|
+
4. Configure: Edit ONE line in `astro.config.ts`
|
|
1647
|
+
|
|
1648
|
+
### The Payoff
|
|
1649
|
+
|
|
1650
|
+
**Before Backend-Agnostic Architecture:**
|
|
1651
|
+
- Frontend tightly coupled to Convex
|
|
1652
|
+
- Organizations must use Convex (no choice)
|
|
1653
|
+
- Can't test without backend
|
|
1654
|
+
- Can't use existing infrastructure
|
|
1655
|
+
- Hard to demo without signup
|
|
1656
|
+
|
|
1657
|
+
**After Backend-Agnostic Architecture:**
|
|
1658
|
+
- Frontend works with ANY backend
|
|
1659
|
+
- Organizations use their existing systems
|
|
1660
|
+
- Test with mock providers (instant)
|
|
1661
|
+
- Leverage existing infrastructure investments
|
|
1662
|
+
- Demo works without backend
|
|
1663
|
+
|
|
1664
|
+
**Build Once. Deploy Anywhere. Connect Anything.**
|
|
1665
|
+
|
|
1666
|
+
---
|
|
1667
|
+
|
|
1668
|
+
## Next Steps
|
|
1669
|
+
|
|
1670
|
+
### For Immediate Implementation
|
|
1671
|
+
|
|
1672
|
+
**1. Complete Phase 3: Backend Implementation**
|
|
1673
|
+
```bash
|
|
1674
|
+
# Backend mutations for all 66 thing types
|
|
1675
|
+
cd backend/convex/mutations/things.ts
|
|
1676
|
+
# Implement create/update/delete for each type
|
|
1677
|
+
# Add event logging to all mutations
|
|
1678
|
+
# Enforce group scoping
|
|
1679
|
+
```
|
|
1680
|
+
|
|
1681
|
+
**2. Complete Phase 4: Frontend Integration**
|
|
1682
|
+
```bash
|
|
1683
|
+
# Multi-tenant dashboard
|
|
1684
|
+
cd web/src/pages/admin/
|
|
1685
|
+
# Build dashboard using ThingService
|
|
1686
|
+
# Add entity management UI
|
|
1687
|
+
# Visualize connections
|
|
1688
|
+
```
|
|
1689
|
+
|
|
1690
|
+
**3. Complete Phase 5: RAG & Knowledge**
|
|
1691
|
+
```bash
|
|
1692
|
+
# Implement KnowledgeService features
|
|
1693
|
+
cd web/src/services/KnowledgeService.ts
|
|
1694
|
+
# Add chunking (800 tokens, 200 overlap)
|
|
1695
|
+
# Add embedding (OpenAI integration)
|
|
1696
|
+
# Add vector search
|
|
1697
|
+
```
|
|
1698
|
+
|
|
1699
|
+
### For Future Exploration
|
|
1700
|
+
|
|
1701
|
+
**1. Multi-Backend Support (Phase 7)**
|
|
1702
|
+
- WordPressProvider (REST API + WP metadata)
|
|
1703
|
+
- SupabaseProvider (PostgreSQL queries)
|
|
1704
|
+
- CompositeProvider (route by feature)
|
|
1705
|
+
|
|
1706
|
+
**2. Advanced Effect.ts Features**
|
|
1707
|
+
- Stream for real-time LLM responses
|
|
1708
|
+
- Fiber for advanced concurrency
|
|
1709
|
+
- STM for transactional memory
|
|
1710
|
+
|
|
1711
|
+
**3. Optional Convex Enhancements**
|
|
1712
|
+
- confect integration (schema-first)
|
|
1713
|
+
- Effect.ts in Convex backend
|
|
1714
|
+
- Deep type safety end-to-end
|
|
1715
|
+
|
|
1716
|
+
---
|
|
1717
|
+
|
|
1718
|
+
## Related Documentation
|
|
1719
|
+
|
|
1720
|
+
- **`one/knowledge/ontology.md`** - 6-dimension data model (SOURCE OF TRUTH)
|
|
1721
|
+
- **`one/knowledge/todo.md`** - 100-inference execution template
|
|
1722
|
+
- **`one/things/plans/separate.md`** - Backend separation strategy
|
|
1723
|
+
- **`one/things/plans/unified-implementation-plan.md`** - Complete 11-week plan
|
|
1724
|
+
- **`one/things/plans/improve-codebase.md`** - Alternative 14-week plan (backend-first)
|
|
1725
|
+
- **`one/things/plans/architecture-summary.md`** - Deployment architecture
|
|
1726
|
+
- **`CLAUDE.md`** - Development workflow and patterns
|
|
1727
|
+
- **`web/AGENTS.md`** - Quick reference for Convex patterns
|
|
1728
|
+
|
|
1729
|
+
---
|
|
1730
|
+
|
|
1731
|
+
**The architecture is sound. The foundation is complete. Phases 1-2 prove the concept works. Now we finish the implementation and ship the complete platform.**
|
|
1732
|
+
|
|
1733
|
+
**Build features once. Work with any backend. Scale infinitely.**
|