Skip to content

StabilityNexus/Gluon-Ergo-UI

Repository files navigation

Gluon Ergo UI

A modern DeFi interface built with Next.js, Tailwind CSS, Shadcn UI, Zustand, Framer Motion, and bun as package manager.

πŸ“ TODO

  • Setup Eslint and Prettier rules
  • Setup shadcn/ui theming
  • Setup theme switcher
  • Rework the homepage to be more dynamic and modern
  • Create layout components (navbar, footer, sidebar, etc)
  • Implement Nautilus Wallet connector
  • Implement ErgoPay Connector
  • Implement Ergo Gluon SDK
  • Rework the dashboard with real protocol data
  • Handle wallet logic for testnet / mainnet
  • Handle Gluon information based on SDK availability
  • Implement real-time protocol metrics and wallet integration
  • Add responsive design across all dashboard components
  • Add transaction history and detailed analytics
  • Performance optimization and caching strategies (maybe websockets to confirm transactions)

πŸš€ Getting Started

Install bun, if you don't have it already, you can find it here.

If you don't want to use bun, you can always use NPM or PNPM.

  1. Install dependencies:
bun install
  1. Start the development server:
bun dev

Adding Shadcn Components

To install new shadcn components:

bun x shadcn@latest add <component-name>

or with NPM / PNPM:

npx shadcn@latest add <component-name>

While working with shadcn, all components are installed to src/lib/components/ui You will have access to the core component file, which means you can edit the whole component as you please.

⚠️ Note: Avoid reinstalling existing components when prompted, as this will reset any custom styling in the component files.

πŸ“ Folder Structure

The project follows a modular approach. Components or functions that will be used multiple times should be designed to accept various props or be moved to separate files.

Directory Overview

src/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ components/          # All React components
β”‚   β”‚   β”œβ”€β”€ ui/             # Shadcn UI components
β”‚   β”‚   β”œβ”€β”€ blocks/         # Page-specific sections (dashboard, home)
β”‚   β”‚   β”œβ”€β”€ layout/         # Layout components (navbar, sidebar, SEO)
β”‚   β”‚   β”œβ”€β”€ blockchain/     # Wallet and protocol integrations
β”‚   β”‚   └── icons/          # Custom icon components
β”‚   β”œβ”€β”€ constants/          # Application constants and addresses
β”‚   β”œβ”€β”€ functions/          # Business logic and protocol functions
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”œβ”€β”€ providers/          # Context providers (Ergo, theme)
β”‚   β”œβ”€β”€ services/           # External service integrations
β”‚   β”œβ”€β”€ stores/             # State management (Zustand)
β”‚   β”œβ”€β”€ types/              # TypeScript type definitions
β”‚   └── utils/              # Utility functions and helpers
β”œβ”€β”€ pages/                  # Next.js pages and API routes
└── styles/                 # Global styles and CSS

Component Organization Guidelines

  • UI Components: All shadcn-related components go in lib/components/ui
  • Page Sections: Add page-specific sections (e.g., dashboard stats) in components/blocks
  • Layout Components: Place layout elements (navbar, sidebar, footer) in components/layout
  • Blockchain Components: Wallet connectors and protocol interactions in components/blockchain
  • New Features: Create dedicated folders in appropriate locations

πŸ”— Gluon SDK Integration

The application integrates with the Gluon Gold SDK for protocol interactions:

Key Integration Points

  • Protocol Data: Real-time price feeds, volume metrics, and reserve ratios
  • Wallet Integration: Balance fetching and transaction handling via ErgoProvider
  • Network Support: Automatic testnet/mainnet detection and configuration

Usage Pattern

const gluon = new sdk.Gluon()
gluon.config.NETWORK = process.env.NEXT_PUBLIC_DEPLOYMENT || 'testnet'
const gluonBox = await gluon.getGluonBox()
const oracleBox = await gluon.getGoldOracleBox()

🎨 Design System

Dashboard Architecture

  • Real-time Data: Protocol metrics update every 5 minutes, ERG price every 30 minutes
  • Responsive Design: Mobile-first approach with proper breakpoints
  • Motion Design: Framer Motion for smooth animations and transitions
  • Theming: Full dark/light mode support with shadcn theming

Data Formatting Standards

  • Decimals: Meaningful precision for small numbers (GAU/GAUC show 6 decimals)
  • Large Numbers: Smart formatting (K/M/B notation)
  • Loading States: Skeleton loaders for all data fetching
  • Error Handling: Graceful fallbacks with user feedback

🏷️ Naming Conventions

Type Convention Example
Small UI Components kebab-case my-new-component.tsx β†’ export as YourComponent
Complex Components PascalCase ThisComponentName.tsx
Single Functions camelCase useThisFunction.ts, getThisValue.ts
Multiple Functions / Utils kebab-case error-handler.ts, node-service.ts
Constants UPPERCASE LIKE_THIS.ts

πŸ”„ Pull Request Workflow

Branch Structure

  • mainnet - Production branch
  • testnet - Development/testing branch
  • develop - Feature integration branch

Development Process

  1. Create feature branches from develop: yourname/feature-name
  2. Submit PR to testnet with detailed description
  3. After testing on testnet deployment, it will be merged to mainnet
  4. Feature branches may be deleted after merging to mainnet

Environment Handling

Environment variables are used for network detection. Code should be compatible with both testnet and mainnet:

// Network configuration
gluon.config.NETWORK = process.env.NEXT_PUBLIC_DEPLOYMENT || 'testnet'

// Environment-specific logic
if (process.env.NEXT_PUBLIC_DEPLOYMENT === 'testnet') {
    // testnet-specific code
    // wallet checkers, explorer URLs, etc.
}

πŸ’‘ Best Practices

TypeScript Guidelines

  • Type everything possible to improve code quality
  • Avoid unnecessary interfaces
  • Keep type definitions simple and practical for day-to-day reading
  • Add types to src/lib/types to keep the codebase clean and organized

Component Development

  • Props Design: Create reusable components with flexible props
  • Error Boundaries: Implement proper error handling in components
  • Loading States: Always provide loading feedback for async operations
  • Accessibility: Include proper ARIA labels and keyboard navigation

Protocol Integration

  • Data Polling: Use appropriate intervals (avoid overwhelming the network)
  • Error Recovery: Implement retry logic for failed API calls
  • Cache Strategy: Cache protocol data when appropriate
  • Real Data: Always prefer real protocol data over mocked values

Performance Guidelines

  • Bundle Size: Monitor component bundle impact
  • Re-renders: Use React.memo and useMemo appropriately
  • Animation: Keep animations smooth and purposeful
  • Responsive Images: Optimize images for different screen sizes

Collaborative Development

  • Follow established conventions
  • Respect team members' work
  • Share and discuss implementation ideas
  • Test thoroughly on both testnet and mainnet
  • Maintain a clean and organized codebase

For questions or discussions, please join our Discord community.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6