UNPKG

oneie

Version:

Build apps, websites, and AI agents in English. Zero-interaction setup for AI agents (Claude Code, Cursor, Windsurf). Download to your computer, run in the cloud, deploy to the edge. Open source and free forever.

350 lines (243 loc) 9.77 kB
--- title: Readme Simplification dimension: things category: plans tags: ai, architecture, frontend related_dimensions: events scope: global created: 2025-11-03 updated: 2025-11-03 version: 1.0.0 ai_context: | This document is part of the things dimension in the plans category. Location: one/things/plans/README-SIMPLIFICATION.md Purpose: Documents frontend architecture simplification project Related dimensions: events For AI agents: Read this to understand README SIMPLIFICATION. --- # Frontend Architecture Simplification Project ## Overview Comprehensive analysis and simplification roadmap for the ONE Platform frontend architecture. The current system has excessive abstraction layers (5+ levels deep) that slow development and add 1,300+ LOC of boilerplate to support a provider-swapping feature that has never been used. **Key finding:** Remove abstraction layers, develop 30-50% faster, improve maintainability by 50%. --- ## Documents in This Analysis ### 1. QUICK-START-SIMPLIFICATION.md **Start here.** 5-minute executive overview for decision makers. Contains: - TL;DR of the problem and solution - Before/after code patterns - Decision tree - Migration checklist - Key metrics **Use when:** You need to decide whether to proceed --- ### 2. SIMPLIFICATION-SUMMARY.md **Executive summary.** 15-minute overview for technical leads. Contains: - Problem statement with visuals - What's being removed and why - Impact analysis by the numbers - Layer comparison with concrete examples - Error handling improvements - Testing improvements - ROI analysis **Use when:** You need to convince stakeholders or understand the scope --- ### 3. SIMPLIFICATION-EXAMPLES.md **Code walkthrough.** 20-minute deep dive with real examples. Contains: - Example 1: Creating a course (8 layers → 2 layers) - Example 2: Listing courses with filtering - Example 3: Testing (50+ LOC mocks → 5 LOC mocks) - Example 4: Service layer comparison - Example 5: Error handling consolidation **Use when:** You need to understand what the code actually looks like --- ### 4. ARCHITECTURE-SIMPLIFICATION.md **Full analysis.** 45-minute comprehensive technical document. Contains: - Detailed analysis of each abstraction layer - What's redundant and why - Cross-file duplication patterns - Measured performance impact - Specific simplification recommendations with before/after - Migration path (low risk, parallel implementation) - Open questions for decision - Success metrics **Use when:** You're implementing the simplification or need full context --- ## Quick Navigation ### For Decision Makers 1. Read QUICK-START-SIMPLIFICATION.md (5 min) 2. Skim SIMPLIFICATION-SUMMARY.md (5 min) 3. Decision: Proceed or defer? ### For Technical Leads 1. Read SIMPLIFICATION-SUMMARY.md (15 min) 2. Read ARCHITECTURE-SIMPLIFICATION.md sections on: - Impact Analysis - Recommendations - Migration Path 3. Plan implementation approach ### For Developers 1. Read QUICK-START-SIMPLIFICATION.md (5 min) 2. Review SIMPLIFICATION-EXAMPLES.md (20 min) 3. Start with Phase 1 implementation tasks ### For Architects 1. Read ARCHITECTURE-SIMPLIFICATION.md (full) (45 min) 2. Review decision points section 3. Plan long-term implications --- ## Key Findings Summary ### Current State - **Abstraction layers:** 5+ deep (component → hook → Effect → DI → Provider → Convex → DB) - **Code overhead:** 1,314+ LOC of abstraction for 0 production features - **Call depth:** 8 layers to read a single item from database - **Error handling:** 30+ error classes (411 LOC) - **Testing:** 50+ LOC mock setup per test - **Development speed:** 30 min per new data operation - **Learning curve:** Must learn 7 frameworks to use data layer ### Proposed State - **Abstraction layers:** 2 deep (component → Convex → DB) - **Code overhead:** 0 LOC (use Convex types directly) - **Call depth:** 1 layer to read a single item - **Error handling:** Standard JavaScript Error - **Testing:** 5 LOC mock setup per test - **Development speed:** 10 min per new data operation (3x faster) - **Learning curve:** Must learn 2 frameworks (React + Convex) ### Impact - **Code reduction:** 800-1,100 LOC deleted (70% of abstraction) - **Development speed:** 30-50% faster - **Cognitive load:** 50% reduction - **Testing:** 70% simpler - **Performance:** 3-5x faster (direct vs Effect wrapper) --- ## What's Being Removed | File | LOC | Reason | | -------------------- | ---------- | --------------------------------------------------- | | DataProvider.ts | 411 | Interface for swappable backends (only Convex used) | | ConvexProvider.ts | 363 | Thin Promise → Effect wrapper (no value added) | | ClientLayer.ts | 76 | DI layer combining 6 services (never swapped) | | ThingService.ts | 156 | Passthrough to DataProvider | | ConnectionService.ts | 46 | Passthrough to DataProvider | | EventService.ts | 32 | Passthrough to DataProvider | | KnowledgeService.ts | ~50 | Passthrough to DataProvider | | GroupService.ts | ~60 | Passthrough to DataProvider | | PeopleService.ts | ~40 | Passthrough to DataProvider | | useEffectRunner.ts | 36 | Effect.ts wrapper (React handles loading) | | EffectContext.tsx | 28 | Context for DI (only ever provides ClientLayer) | | **Total** | **1,314+** | **All unused abstraction** | --- ## What's Staying - React component structure - Convex backend and queries/mutations - TypeScript types and safety - Tailwind styling - Astro page framework - Error handling (simplified to standard Error) --- ## Implementation Approach ### Parallel Implementation (Recommended) 1. **Week 1:** Create new simplified hooks alongside old ones 2. **Week 2-3:** Migrate features one by one 3. **Week 3-4:** Delete old implementations when confident 4. **Week 4:** Validate and measure results **Benefit:** Zero risk of breaking changes. Both implementations coexist during migration. ### Timeline - **Preparation:** 1 week (read docs, plan, setup) - **Migration:** 2-3 weeks (refactor hooks, update usages) - **Cleanup:** 1 week (delete abstraction layers) - **Validation:** 1 week (testing, measurement) - **Total:** 4-5 weeks ### ROI - **Cost:** 3-4 weeks engineering time - **Benefit:** 30-50% faster development forever - **Payback:** 2-3 weeks of future development - **Break-even:** Month 1, infinite returns month 2+ --- ## Success Criteria When complete: - [ ] Zero useEffectRunner imports - [ ] Zero DataProvider imports - [ ] All hooks using direct Convex - [ ] 800+ LOC deleted - [ ] All tests passing - [ ] Performance improved or unchanged - [ ] New features 3x faster to add - [ ] Developer satisfaction high --- ## Open Questions ### Strategic Decisions Required 1. **Provider swapping future?** - None planned → Delete all (saves 1,300 LOC) - Planned → Keep at backend only (saves 1,000 LOC) - **Decision:** ? 2. **Effect.ts value?** - Only on frontend → Delete (saves 500+ LOC) - Planned for backend → Keep for backend only (saves 400+ LOC) - **Decision:** ? 3. **Timeline preference?** - Immediate (4 weeks, parallel, lowest risk) - Gradual (8 weeks, one feature per sprint) - Minimal (2 weeks, only remove harmful code) - **Decision:** ? --- ## Reading Order by Role ### Product Manager 1. QUICK-START-SIMPLIFICATION.md (5 min) 2. Skip to "Why This Matters" section ### Engineering Manager 1. QUICK-START-SIMPLIFICATION.md (5 min) 2. SIMPLIFICATION-SUMMARY.md (10 min) 3. Review "Implementation Timeline" and "ROI" ### Architect 1. ARCHITECTURE-SIMPLIFICATION.md (full read) (45 min) 2. Focus on "Recommendations" and "Open Questions" ### Developer 1. QUICK-START-SIMPLIFICATION.md (5 min) 2. SIMPLIFICATION-EXAMPLES.md sections (10 min) 3. Pick a hook, start migrating ### QA/Testing 1. SIMPLIFICATION-EXAMPLES.md "Testing" section (5 min) 2. ARCHITECTURE-SIMPLIFICATION.md "Testing Impact" (5 min) --- ## Files Analyzed ### Providers - `/web/src/providers/DataProvider.ts` (411 LOC) - `/web/src/providers/ConvexProvider.ts` (363 LOC) - `/web/src/providers/index.ts` ### Services - `/web/src/services/ClientLayer.ts` (76 LOC) - `/web/src/services/ThingService.ts` (156 LOC) - `/web/src/services/ConnectionService.ts` (46 LOC) - `/web/src/services/EventService.ts` (32 LOC) - `/web/src/services/KnowledgeService.ts` - `/web/src/services/GroupService.ts` - `/web/src/services/PeopleService.ts` - `/web/src/services/index.ts` ### Hooks - `/web/src/hooks/useEffectRunner.ts` (36 LOC) - `/web/src/hooks/useService.ts` - `/web/src/hooks/ontology/useThing.ts` - `/web/src/hooks/index.ts` ### Context - `/web/src/context/EffectContext.tsx` (28 LOC) --- ## Version History - **v1.0** (Nov 2024) - Initial comprehensive analysis - 4 documents - 62 KB of detailed analysis - Ready for decision --- ## Next Steps 1. **Read:** Start with QUICK-START-SIMPLIFICATION.md 2. **Decide:** Use decision tree to determine scope 3. **Plan:** Review implementation timeline 4. **Build:** Create parallel implementations 5. **Migrate:** Move features one by one 6. **Validate:** Measure improvements --- ## Contact & Questions See ARCHITECTURE-SIMPLIFICATION.md "Open Questions for Decision" section for strategic questions. --- ## License These analysis documents are part of the ONE Platform documentation and follow the same license as the codebase.