Skip to content

Commit 421f446

Browse files
orionmizclaude
andcommitted
docs: add CLAUDE.md project memory documentation
Add comprehensive project memory documentation that includes: - Project overview and key features - Architecture and core components - Development commands and testing approach - Plugin system documentation - Common usage patterns and examples 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent bfdd37f commit 421f446

1 file changed

Lines changed: 171 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Stackflow Project Memory
2+
3+
## Project Overview
4+
5+
Stackflow is a JavaScript library that implements Stack Navigation UX commonly used in mobile applications (iOS/Android). It provides a framework-agnostic core with React integration for building hybrid apps and webviews with native-like navigation experiences.
6+
7+
**Key Features:**
8+
- Stack-based navigation with state preservation
9+
- Native-like transition effects and iOS-style swipe back
10+
- Plugin system for extensibility
11+
- Framework agnostic core (currently React integration available)
12+
- Server-Side Rendering support
13+
- TypeScript support with strict typing
14+
15+
## Architecture
16+
17+
### Core Components
18+
19+
1. **@stackflow/core** (`/core`)
20+
- Event-driven architecture using domain events
21+
- Stack state management
22+
- Plugin system interface
23+
- Effect system for side effects
24+
- Transition state management
25+
26+
2. **@stackflow/react** (`/integrations/react`)
27+
- React integration layer
28+
- Provides `stackflow()` factory function
29+
- `<Stack />` component and `useFlow()` hooks
30+
- Activity component management
31+
- Both stable and future API versions
32+
33+
3. **@stackflow/config** (`/config`)
34+
- Configuration definitions
35+
- Activity definitions and type inference
36+
- TypeScript type utilities
37+
38+
### Key Concepts
39+
40+
- **Activity**: A screen/page in the navigation stack
41+
- **Stack**: Collection of activities with transition states
42+
- **Event**: Domain events that drive state changes (Pushed, Popped, Replaced, etc.)
43+
- **Plugin**: Extensions that can hook into lifecycle events
44+
- **Effect**: Side effects produced by state changes
45+
- **Step**: Sub-navigation within an activity
46+
47+
## Project Structure
48+
49+
```
50+
/
51+
├── core/ # Core library
52+
├── integrations/ # Framework integrations
53+
│ └── react/ # React integration
54+
├── extensions/ # Official plugins and extensions
55+
│ ├── link/ # Link component
56+
│ ├── plugin-basic-ui/ # Basic UI components
57+
│ ├── plugin-devtools/ # Development tools
58+
│ ├── plugin-history-sync/ # Browser history sync
59+
│ └── ...
60+
├── demo/ # Demo application
61+
├── docs/ # Documentation site (Next.js)
62+
└── config/ # Configuration package
63+
```
64+
65+
## Development Commands
66+
67+
```bash
68+
# Install dependencies
69+
yarn install
70+
71+
# Development mode (all packages)
72+
yarn dev
73+
74+
# Build all packages
75+
yarn build
76+
77+
# Run tests
78+
yarn test
79+
80+
# Type checking
81+
yarn typecheck
82+
83+
# Format code
84+
yarn format
85+
86+
# Lint code
87+
yarn lint
88+
89+
# Release process
90+
yarn release
91+
92+
# Canary release
93+
yarn release:canary
94+
```
95+
96+
## Testing
97+
98+
- Uses Jest with SWC for transformation
99+
- Test files: `*.spec.ts` pattern
100+
- Run tests: `yarn test`
101+
- Tests are located alongside source files
102+
103+
## Key Dependencies
104+
105+
- **React**: >=16.8.0 (peer dependency)
106+
- **TypeScript**: ^5.5.3
107+
- **Biome**: Code formatting and linting
108+
- **Ultra Runner**: Monorepo task runner
109+
- **Changesets**: Version management and publishing
110+
111+
## Plugin System
112+
113+
Plugins can hook into various lifecycle events:
114+
- `onInitialized`
115+
- `onBeforePush/onPushed`
116+
- `onBeforePop/onPopped`
117+
- `onBeforeReplace/onReplaced`
118+
- Activity transition events
119+
120+
## Important Patterns
121+
122+
1. **Event Sourcing**: All state changes are driven by events
123+
2. **Immutable State**: Stack state is immutable and updated via reducers
124+
3. **Effect System**: Side effects are separated from state updates
125+
4. **Plugin Architecture**: Extensible through plugin hooks
126+
5. **Type Safety**: Extensive TypeScript types for activities and parameters
127+
128+
## Common Tasks
129+
130+
### Adding a New Activity
131+
```typescript
132+
const { Stack, useFlow } = stackflow({
133+
activities: {
134+
HomePage: HomeActivity,
135+
DetailPage: DetailActivity,
136+
},
137+
transitionDuration: 300,
138+
});
139+
```
140+
141+
### Navigation
142+
```typescript
143+
const { push, pop, replace } = useFlow();
144+
push("DetailPage", { id: "123" });
145+
pop();
146+
replace("HomePage", {});
147+
```
148+
149+
### Creating a Plugin
150+
```typescript
151+
const myPlugin = () => ({
152+
onPushed(params) {
153+
// Handle push event
154+
},
155+
});
156+
```
157+
158+
## Build System
159+
160+
- Uses esbuild for JavaScript/TypeScript compilation
161+
- Separate builds for CommonJS and ESM
162+
- TypeScript declarations generated separately
163+
- Monorepo managed with Yarn workspaces
164+
165+
## Important Notes
166+
167+
- Always use `yarn` commands (not npm)
168+
- The project uses Yarn Berry (v4)
169+
- Changesets are used for versioning
170+
- Biome is used for formatting/linting (not ESLint/Prettier)
171+
- Documentation site is built with Next.js and deployed to Cloudflare

0 commit comments

Comments
 (0)