Skip to content

StellarLend/Stellarlend-frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

106 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Stellarlend

Fast & Secure DeFi Lending on Stellar

Stellarlend is a decentralized finance (DeFi) lending platform built on the Stellar blockchain. It enables users to borrow and lend digital assets with ultra-low fees, instant settlements, and full transparencyβ€”powered by Soroban smart contracts. The platform is designed for both crypto-native users and those new to DeFi, offering an intuitive interface for managing lending and borrowing operations on one of the most efficient blockchain networks.

This frontend application provides a modern, responsive web interface for interacting with the Stellarlend protocol, featuring real-time transaction tracking, interest rate calculations, and comprehensive dashboard analytics.

πŸš€ Features

  • Lending & Borrowing: Earn interest by lending assets or borrow against collateral
  • Multi-Asset Support: Support for XLM, USDC, BTC, ETH, and other Stellar-based assets
  • Real-Time Asset Pricing: Cached price oracle proxy for secure price feeds
  • Real-Time Calculations: Dynamic interest rate and payment calculations
  • Transaction Management: Track all lending, borrowing, and payment transactions
  • Dashboard Analytics: Comprehensive metrics and insights
  • Responsive Design: Optimized for desktop, tablet, and mobile devices
  • Component Library: Built with Storybook for component development and documentation

πŸ“‹ Requirements

  • Node.js: v18.0.0 or higher
  • Package Manager: npm, yarn, pnpm, or bun
  • Git: For version control

πŸ› οΈ Setup Instructions

1. Clone the Repository

git clone <repository-url>
cd Stellarlend-frontend

2. Install Dependencies

Choose your preferred package manager:

# Using npm
npm install

# Using yarn
yarn install

# Using pnpm (recommended)
pnpm install

# Using bun
bun install

3. Environment Variables

Create a .env.local file in the root directory:

cp .env.example .env.local

Edit .env.local with your configuration:

# Stellar Network Configuration
NEXT_PUBLIC_STELLAR_NETWORK=testnet
NEXT_PUBLIC_STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
NEXT_PUBLIC_SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
NEXT_PUBLIC_SOROBAN_CONTRACT_ID=GXXXXXXXXXXXXXXX...YOUR_CONTRACT_ID

# API Configuration (if applicable)
NEXT_PUBLIC_API_URL=http://localhost:3001/api

# Feature Flags
NEXT_PUBLIC_ENABLE_ANALYTICS=false

# Server Logging Configuration
SERVER_LOG_LEVEL=info

Logging is emitted as structured JSON by lib/logger.ts and includes:

  • timestamp
  • level
  • route
  • method
  • status
  • durationMs
  • message
  • context

Sensitive information such as authorization headers, API keys, auth tokens, and Stellar public/secret keys are redacted automatically.

Note: For production, use the Stellar mainnet configuration and secure your environment variables.

4. Run the Development Server

# Using npm
npm run dev

# Using yarn
yarn dev

# Using pnpm
pnpm dev

# Using bun
bun dev

Open http://localhost:3000 in your browser to see the application.

5. Build for Production

npm run build
npm start

πŸ§ͺ Testing

Run Tests

# Run all tests
npm test

# Run tests in watch mode
npm test -- --watch

# Run tests with coverage
npm test -- --coverage

Component Testing with Storybook

# Start Storybook development server
npm run storybook

# Build Storybook for static hosting
npm run build-storybook

Storybook will be available at http://localhost:6006

πŸ“ Project Structure

Stellarlend-frontend/
β”œβ”€β”€ app/                      # Next.js App Router pages
β”‚   β”œβ”€β”€ account/             # User account pages
β”‚   β”œβ”€β”€ dashboard/           # Dashboard pages
β”‚   β”œβ”€β”€ lending/             # Lending & borrowing pages
β”‚   └── layout.tsx           # Root layout
β”œβ”€β”€ components/              # React components
β”‚   β”œβ”€β”€ atoms/              # Atomic design: smallest components
β”‚   β”œβ”€β”€ molecules/          # Composite components
β”‚   β”œβ”€β”€ organisms/          # Complex components
β”‚   β”œβ”€β”€ features/           # Feature-specific components
β”‚   β”‚   β”œβ”€β”€ account/        # Account feature components
β”‚   β”‚   β”œβ”€β”€ dashboard/      # Dashboard feature components
β”‚   β”‚   └── lending/        # Lending feature components
β”‚   β”œβ”€β”€ marketing/          # Marketing page components
β”‚   └── shared/             # Shared components
β”‚       β”œβ”€β”€ ui/             # UI components (buttons, icons, etc.)
β”‚       β”œβ”€β”€ layout/         # Layout components (navbar, sidebar, etc.)
β”‚       └── common/         # Common utility components
β”œβ”€β”€ constants/              # Application constants
β”‚   └── design-tokens.ts   # Design system tokens
β”œβ”€β”€ context/               # React context providers
β”‚   └── SidebarContext.tsx
β”œβ”€β”€ lib/                   # Utility libraries
β”‚   β”œβ”€β”€ auth.ts            # Authentication utilities
β”‚   β”œβ”€β”€ utils/             # Utility functions
β”‚   β”‚   β”œβ”€β”€ cn.ts          # Class name utilities (Tailwind merge)
β”‚   β”‚   └── index.ts       # Utils barrel export
β”‚   └── index.ts           # Lib barrel export
β”œβ”€β”€ types/                 # TypeScript type definitions
β”‚   β”œβ”€β”€ Transaction.ts     # Transaction-related types
β”‚   β”œβ”€β”€ common.ts          # Common utility types
β”‚   └── index.ts           # Types barrel export
β”œβ”€β”€ public/                # Static assets
β”‚   β”œβ”€β”€ icons/             # Icon assets
β”‚   └── images/            # Image assets
β”œβ”€β”€ scripts/               # Build and utility scripts
β”‚   β”œβ”€β”€ svgToComponent.js  # SVG to React component converter
β”‚   └── generate-component.js
β”œβ”€β”€ test/                 # Test utilities and helpers
β”‚   β”œβ”€β”€ test-utils.tsx
β”‚   └── component-helpers.ts
└── stories/              # Storybook stories

🎨 Component Development

Generate New Components

We use Plop for component scaffolding:

npm run generate-component

Follow the prompts to create a new component with proper structure, tests, and Storybook stories.

Convert SVG to React Components

Place SVG files in public/images and run:

npm run svg

This will automatically convert SVGs to React components in components/shared/ui/icons/.

πŸ—„οΈ Backend & API

The server-side API surface is documented in two places:

Resource Description
docs/backend-architecture.md Architecture overview β€” lib/ modules, caching model, security, and how to add a new route
openapi.yaml OpenAPI 3.1 spec for all app/api/* routes, params, and response shapes

Available API Routes

Method Path Auth Description
GET /api/health Public Platform & Stellar network health
POST/GET/DELETE /api/auth/session β€” Session lifecycle
GET /api/prices Public Asset spot prices (cached 5 s)
GET /api/markets Public Per-asset supply/borrow APR & utilization (cached 30 s)
GET /api/positions Optional User lending/borrowing positions
GET/POST /api/transactions Public Transaction history and creation
GET /api/transactions/export Public Transactions CSV export
POST /api/quote Public Lending/borrowing quote calculation
GET /api/notifications Required List in-app notifications
PATCH /api/notifications/:id Required Mark notification as read

πŸ”— Helpful Links

Documentation

Development Tools

Design & Styling

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for detailed guidelines.

Quick Start:

  1. Fork the repository and create a feature branch
  2. Follow the code style - We use ESLint and Prettier (configured with Husky pre-commit hooks)
  3. Write tests for new features and bug fixes
  4. Update documentation as needed
  5. Submit a pull request with a clear description of changes

Code Style

  • Linting: Run npm run lint before committing
  • Formatting: Prettier is configured to run automatically on commit
  • TypeScript: Strict mode enabled - ensure all types are properly defined

Commit Guidelines

We use Conventional Commits. Examples:

  • feat: add new lending form component
  • fix: resolve transaction status display issue
  • docs: update README with setup instructions

For more details, see CONTRIBUTING.md.

🚒 Deployment

Vercel (Recommended)

The easiest way to deploy is using Vercel:

  1. Push your code to GitHub
  2. Import the repository in Vercel
  3. Configure environment variables
  4. Deploy!

Manual Deployment

# Build the application
npm run build

# Start production server
npm start

For more deployment options, see the Next.js deployment documentation.

πŸ“ Scripts Reference

Command Description
npm run dev Start development server
npm run build Build for production
npm start Start production server
npm run lint Run ESLint
npm test Run tests with Vitest
npm run storybook Start Storybook
npm run build-storybook Build Storybook for static hosting
npm run svg Convert SVG files to React components
npm run generate-component Generate new component scaffold

πŸ”’ Security

  • Never commit .env.local or any files containing secrets
  • Use environment variables for all sensitive configuration
  • Regularly update dependencies to patch security vulnerabilities
  • Review and audit smart contract interactions before production use

πŸ“„ License

[Add your license information here]

πŸ™‹ Support

For questions, issues, or feature requests:

  • Open an issue on GitHub
  • Contact the development team
  • Check the documentation links above

Built with ❀️ for the Stellar ecosystem

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors