1# Frontend Architecture
2
3This directory contains the frontend application with a clean, scalable architecture following React best practices and separation of concerns.
4
5## Directory Structure
7```
8frontend/
9โโโ components/ # React components (UI rendering only)
10โ โโโ GlimpseView.tsx # Main glimpse viewing component
11โ โโโ NotionBlock.tsx # Notion block rendering with semantic HTML
12โ โโโ NotionProperty.tsx # Notion property rendering with type-specific formatting
13โโโ hooks/ # Custom React hooks (stateful logic)
14โ โโโ useAuth.ts # Authentication and authorization
15โ โโโ useGlimpseData.ts # Glimpse data fetching and state
33โ โโโ notion-content.css # Notion-specific styling
34โโโ pages/ # Page entry points
35โ โโโ glimpse.tsx # Glimpse page React entry point
36โโโ *.html # HTML templates with semantic structure
37```
48### **Data Flow**
49```
50HTML Template โ React Entry Point โ Components โ Hooks โ Services โ Utils
51 โ โ โ โ โ
52 DOM Mount UI Rendering State API Calls Pure Logic
703. **HTML template** served with semantic structure (header/main/footer)
714. **Initial data injection** - glimpse data embedded in `window.__GLIMPSE_DATA__`
725. **React entry point** (`glimpse.tsx`) mounts to `#root`
73
74#### **React Initialization**
751. **`glimpse.tsx`** extracts initial data from window
762. **`GlimpseView`** component renders with initial data
83- **Orchestrates** all data and UI logic
84- **Uses custom hooks** for all stateful operations
85- **Renders header content** via React portals to HTML header
86- **Conditionally shows** agent connection UI and page content
87- **Handles loading/error states** with user-friendly UI
175### **Technical Features**
176- **Server-side data injection** - eliminates loading states
177- **React portals** - dynamic header content population
178- **Automatic polling** - real-time agent data updates
179- **Smart error handling** - graceful degradation
259### **Adding New Pages**
2601. **Create HTML template** with same header/footer structure
2612. **Create React entry point** following glimpse.tsx pattern
2623. **Reuse existing hooks** for common functionality
2634. **Add page-specific components** as needed
2731. **Utils** - Unit test pure functions
2742. **Services** - Mock API responses
2753. **Hooks** - Test with React Testing Library
2764. **Components** - Test rendering with mocked dependencies
277
278This architecture provides a solid foundation for building scalable, maintainable React applications with clear separation of concerns and excellent developer experience.