System Architecture
KalshChain is built on a modern, decentralized three-layer architecture.
High-Level Architecture
The platform integrates the high-speed Solana blockchain for core logic with performant web technologies for a smooth user experience.
Blockchain Layer
Solana smart contracts handle market creation, trading execution, and settlement with cryptographic security.
Backend Services
Supabase database, edge functions, and REST API provide fast data access and business logic processing.
Frontend Layer
Next.js React application with wallet integration delivers responsive user interface and real-time updates.
Component Details
1. Frontend Application
Built with Next.js 14 using App Router for optimal performance and SEO:
- •Framework: Next.js 14 with TypeScript for type safety
- •Styling: TailwindCSS with shadcn/ui component library
- •State Management: React Context API and hooks
- •Wallet Integration: Solana Wallet Adapter for Phantom, Solflare, etc.
- •Data Visualization: Recharts for market price charts
2. Backend Services
Supabase (PostgreSQL) is used for reliable and scalable data persistence:
- •Database: PostgreSQL for market and trade metadata
- •Realtime: Supabase Realtime for instant market data updates
- •Authentication: Secure user authentication tied to Solana public keys
3. Blockchain Layer
Solana smart contracts implement core trading logic with on-chain verification:
- •Market Program: Creates and manages prediction markets
- •AMM Program: Executes trades using constant product formula
- •Settlement Program: Resolves markets and distributes payouts
- •Oracle Integration: Fetches real-world data for market resolution
Scalability Design
KalshChain leverages Solana's high throughput and its off-chain services to ensure stability and low latency:
- Database Optimization: PostgreSQL with indexes on frequently queried fields, read replicas for heavy traffic
- Off-Chain Caching: Market metadata is fetched primarily from Supabase, reducing the load on the Solana RPC layer.
- Solana Efficiency: Transaction batching and optimized instruction sets keep fees low and execution fast.
Next Steps
Now that you understand the architecture, explore specific components: