Skip to content

Commit f9a0413

Browse files
committed
feat: add federated database support and update environment configuration
1 parent fd21326 commit f9a0413

27 files changed

Lines changed: 7026 additions & 4548 deletions

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
DATABASE_URL=""
1+
DATABASE_URL=""
2+
FEDERATED_DB_URL="

CLAUDE.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Sarafu Network Visualizer
2+
3+
A Next.js application that visualizes blockchain transaction data from the Sarafu Network using interactive 2D and 3D force-directed graphs.
4+
5+
## AI Team Configuration (autogenerated by team-configurator, 2025-12-05)
6+
7+
**Important: YOU MUST USE subagents when available for the task.**
8+
9+
### Detected Tech Stack
10+
11+
- **Frontend Framework**: Next.js 13.4 (Pages Router) with React 18.2
12+
- **UI Styling**: Tailwind CSS 3.3 (JIT mode) with HeadlessUI and Framer Motion
13+
- **Visualization**:
14+
- 3D Force Graph 1.71
15+
- React Force Graph 2D/3D (1.25/1.23)
16+
- Three.js 0.153 with three-forcegraph
17+
- **Database**: PostgreSQL with Kysely 0.25 (type-safe SQL query builder)
18+
- Multiple databases: Graph DB and Federated DB
19+
- Type generation via kysely-codegen
20+
- **Caching**: Upstash Redis 1.35
21+
- **Blockchain**: viem 2.41, web3 4.0, multicoin-address-validator
22+
- **Data Fetching**: SWR 2.2
23+
- **Language**: TypeScript 5.4 (strict mode disabled)
24+
- **Testing**: Jest 29.5
25+
- **Build Tools**: ESBuild 0.18, PostCSS, Autoprefixer
26+
- **Deployment**: Vercel (@vercel/node 2.7)
27+
28+
### Specialist Agents for This Project
29+
30+
Use these specialists based on the task at hand:
31+
32+
| Task | Agent | Notes |
33+
|------|-------|-------|
34+
| **Next.js SSR/SSG/API Routes** | `@react-nextjs-expert` | Primary specialist for Next.js features, pages, API routes, data fetching patterns, and optimization. Always check latest Next.js docs before implementing. |
35+
| **UI Components & Tailwind Styling** | `@tailwind-frontend-expert` | Utility-first styling, responsive design, container queries. Use for all component styling work. |
36+
| **Frontend Components (General)** | `@frontend-developer` | Alternative for React components when Next.js-specific features not needed. Use for client-side logic and state management. |
37+
| **API Design & Contracts** | `@api-architect` | Design REST endpoints, define request/response schemas, pagination strategies, error handling patterns. |
38+
| **Backend/Database Logic** | `@backend-developer` | PostgreSQL queries with Kysely, database migrations, data processing, caching strategies with Redis. |
39+
| **Code Reviews & Quality** | `@code-reviewer` | MUST USE before merging features or PRs. Provides security, maintainability, and performance reviews. |
40+
| **Performance Optimization** | `@performance-optimizer` | MUST USE for graph rendering performance, data processing optimization, bundle size reduction, caching strategies. |
41+
| **Documentation** | `@documentation-specialist` | Update README, API docs, architecture guides. Use after major features or when onboarding. |
42+
| **Codebase Analysis** | `@code-archaeologist` | Deep exploration of unfamiliar code, legacy analysis, architecture documentation, risk assessment. |
43+
44+
### Project-Specific Guidance
45+
46+
#### Graph Visualization Work
47+
- **Primary concerns**: Performance with large datasets, rendering optimization, user interactivity
48+
- **Key files**:
49+
- `/Users/chui/Dev/grassroots/vis/components/network-graph/` - Graph components
50+
- `/Users/chui/Dev/grassroots/vis/utils/render_graph.ts` - Graph data generation logic
51+
- **Recommended agents**: `@performance-optimizer` for rendering performance, `@react-nextjs-expert` for component architecture, `@frontend-developer` for Three.js/D3 integration
52+
53+
#### Database & Data Processing
54+
- **Stack**: PostgreSQL with Kysely ORM, multiple database connections (graphDB, federatedDB)
55+
- **Key files**:
56+
- `/Users/chui/Dev/grassroots/vis/db/db.ts` - Database connections
57+
- `/Users/chui/Dev/grassroots/vis/db/graph-db.d.ts` - Auto-generated types (regenerate with `npm run generate:graph`)
58+
- `/Users/chui/Dev/grassroots/vis/db/federated-db.d.ts` - Auto-generated types
59+
- **Recommended agents**: `@backend-developer` for query optimization and data layer work, `@api-architect` for API contract design
60+
61+
#### API Routes
62+
- **Pattern**: Next.js API routes in `/Users/chui/Dev/grassroots/vis/pages/api/`
63+
- **Current routes**:
64+
- `/api/data` - Main graph data endpoint with caching
65+
- **Recommended agents**: `@react-nextjs-expert` for Next.js-specific API features, `@api-architect` for endpoint design, `@backend-developer` for data processing
66+
67+
#### Styling & Components
68+
- **Style system**: Tailwind CSS with JIT mode, HeadlessUI for accessible components
69+
- **Animation**: Framer Motion for transitions
70+
- **Key files**: `/Users/chui/Dev/grassroots/vis/tailwind.config.js`
71+
- **Recommended agents**: `@tailwind-frontend-expert` for all styling work, `@frontend-developer` for component logic
72+
73+
#### Performance Considerations
74+
- Large dataset visualization (blockchain transactions)
75+
- Redis caching with 24-hour TTL
76+
- Graph data processing optimization (using Maps for O(1) lookups)
77+
- Dynamic imports for heavy visualization libraries
78+
- **Recommended agent**: `@performance-optimizer` for any performance work
79+
80+
#### Blockchain Integration
81+
- Multiple blockchain libraries (viem, web3.js)
82+
- Address validation with multicoin-address-validator
83+
- Token transfer tracking and voucher system
84+
- **Recommended agents**: `@backend-developer` for blockchain data processing, `@code-reviewer` for security review of blockchain interactions
85+
86+
### Workflow Recommendations
87+
88+
1. **New Features**: Start with `@react-nextjs-expert` or `@api-architect` depending on frontend vs backend
89+
2. **Performance Issues**: Always consult `@performance-optimizer` for graph rendering or data processing bottlenecks
90+
3. **Before Merging**: ALWAYS run `@code-reviewer` for security and quality checks
91+
4. **Complex Queries**: Use `@backend-developer` for Kysely query optimization
92+
5. **UI/UX Work**: Use `@tailwind-frontend-expert` for styling, `@frontend-developer` for component logic
93+
6. **Documentation**: After major changes, use `@documentation-specialist` to update docs
94+
95+
### Example Commands
96+
97+
```bash
98+
# Next.js feature development
99+
"@react-nextjs-expert Build a new API route for filtering graph data by date range"
100+
101+
# Performance optimization
102+
"@performance-optimizer Analyze and optimize the graph rendering performance in network-graph-3d.tsx"
103+
104+
# Styling work
105+
"@tailwind-frontend-expert Create a responsive header component with dark mode support"
106+
107+
# Code review before PR
108+
"@code-reviewer Review the changes in pages/api/data.ts and utils/cache.ts for security and performance"
109+
110+
# Database optimization
111+
"@backend-developer Optimize the transaction query in pages/api/data.ts to reduce load time"
112+
113+
# Architecture analysis
114+
"@code-archaeologist Analyze the graph data processing pipeline and document the architecture"
115+
```
116+
117+
---
118+
119+
**Last Updated**: 2025-12-05
120+
**Configured By**: team-configurator agent

KV_SETUP.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
Requires DATABASE_URL to be set
77

88
```
9-
yarn && yarn dev
9+
pnpm && pnpm dev
1010
```
1111

1212
## Build
1313

1414
```
15-
yarn && yarn build
16-
yarn start
15+
pnpm && pnpm build
16+
pnpm start
1717
```

components/icons.tsx

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
export const PlayIcon = ({ onClick }) => {
2+
return (
3+
<svg
4+
className="w-8 h-8 p-2 z-10 cursor-pointer"
5+
viewBox="0 0 60 60"
6+
onClick={onClick}
7+
stroke="white"
8+
fill="white"
9+
>
10+
<polygon points="0,0 50,30 0,60" />
11+
</svg>
12+
);
13+
};
14+
export const PauseIcon = ({ onClick }) => {
15+
return (
16+
<svg
17+
className="w-8 h-8 p-2 center z-10 cursor-pointer"
18+
viewBox="0 0 60 60"
19+
stroke="white"
20+
fill="white"
21+
onClick={onClick}
22+
>
23+
<polygon points="0,0 15,0 15,60 0,60" />
24+
<polygon points="25,0 40,0 40,60 25,60" />
25+
</svg>
26+
);
27+
};
28+
export function GearIcon(props: { onClick: () => void }) {
29+
return (
30+
<svg
31+
xmlns="http://www.w3.org/2000/svg"
32+
fill="none"
33+
viewBox="0 0 24 24"
34+
strokeWidth={1.5}
35+
stroke="white"
36+
className="w-10 h-10 p-2 z-10 cursor-pointer"
37+
onClick={() => props.onClick()}
38+
>
39+
<path
40+
strokeLinecap="round"
41+
strokeLinejoin="round"
42+
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z"
43+
/>
44+
<path
45+
strokeLinecap="round"
46+
strokeLinejoin="round"
47+
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
48+
/>
49+
</svg>
50+
);
51+
}
52+
53+
export function CloseIcon(props: { onClick: () => void; className?: string }) {
54+
return (
55+
<svg
56+
xmlns="http://www.w3.org/2000/svg"
57+
fill="none"
58+
viewBox="0 0 24 24"
59+
strokeWidth={2}
60+
stroke="currentColor"
61+
className={props.className || "w-5 h-5 cursor-pointer text-gray-500 hover:text-gray-700 transition-colors"}
62+
onClick={props.onClick}
63+
>
64+
<path
65+
strokeLinecap="round"
66+
strokeLinejoin="round"
67+
d="M6 18L18 6M6 6l12 12"
68+
/>
69+
</svg>
70+
);
71+
}
72+
73+
export function ChevronDownIcon(props: { className?: string }) {
74+
return (
75+
<svg
76+
xmlns="http://www.w3.org/2000/svg"
77+
fill="none"
78+
viewBox="0 0 24 24"
79+
strokeWidth={2}
80+
stroke="currentColor"
81+
className={props.className || "w-4 h-4"}
82+
>
83+
<path
84+
strokeLinecap="round"
85+
strokeLinejoin="round"
86+
d="M19 9l-7 7-7-7"
87+
/>
88+
</svg>
89+
);
90+
}

0 commit comments

Comments
 (0)