A full-stack decentralized savings circle application built on the Stellar Network. Enables groups of people to pool money, take turns receiving lump sums, vote on governance decisions, and manage contributions with full transparency through smart contracts.
- Overview
- Features
- Technology Stack
- Project Structure
- Setup Instructions
- API Documentation
- Smart Contract
- Deployment
Ajo (or Esusu in West African cultures) is a traditional savings circle where members pool money and take turns receiving the total amount. Stellar Ajo brings this ancient concept to Web3 using:
- Smart Contracts (Soroban): Secure fund management and automation
- Stellar Network: Fast, low-cost transactions
- Decentralized Governance: Community voting on circle rules
- Full Transparency: All transactions on-chain
- ✅ Circle Management: Create and manage savings circles
- ✅ Member Contributions: Track contributions from all members
- ✅ Rotation Payouts: Automated payout distribution in rounds
- ✅ Contribution Scheduling: Set up recurring contribution schedules
- ✅ Governance Voting: Members vote on circle decisions
- ✅ Partial Withdrawals: Emergency access to funds with penalties
- ✅ User Accounts: Email/password authentication with JWT
- ✅ Wallet Integration: Connect Stellar wallets (Freighter, Lobstr)
- Circle creation and management
- Member management
- Contribution tracking
- Transaction history
- Real-time circle statistics
- Governance proposal voting
- Framework: Next.js 16 (App Router)
- UI Components: shadcn/ui
- Styling: Tailwind CSS 4
- State Management: SWR (for data fetching)
- Wallet Connection: Freighter / Stellar Wallets Kit
- Runtime: Node.js (Next.js API Routes)
- Database: SQLite (development) / PostgreSQL (production)
- ORM: Prisma
- Authentication: JWT + Password Hashing (bcryptjs)
- Network: Stellar Network (Testnet/Mainnet)
- Smart Contracts: Soroban (Rust)
- Contract Deployment: Stellar SDK
- RPC: Soroban RPC Server
- Language: TypeScript
- Package Manager: pnpm
- Deployment: Vercel
.
├── app/
│ ├── api/ # Next.js API routes
│ │ ├── auth/ # Authentication endpoints
│ │ └── circles/ # Circle management APIs
│ ├── auth/ # Authentication pages
│ │ ├── login/
│ │ └── register/
│ ├── circles/ # Circle pages
│ │ ├── create/
│ │ └── [id]/
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Home page
├── components/
│ ├── ui/ # shadcn/ui components
│ └── wallet-button.tsx # Wallet connection component
├── contracts/
│ └── ajo-circle/ # Soroban smart contract
│ ├── src/
│ │ └── lib.rs # Contract implementation
│ └── Cargo.toml
├── lib/
│ ├── auth.ts # Authentication utilities
│ ├── prisma.ts # Prisma client
│ ├── stellar-config.ts # Stellar SDK configuration
│ └── wallet-context.tsx # Wallet context provider
├── prisma/
│ └── schema.prisma # Database schema
├── public/ # Static assets
└── scripts/ # Utility scripts
- Node.js 18+ or compatible version
- pnpm (recommended) or npm
- Freighter wallet extension (for wallet integration)
- Vercel account (for deployment)
# Install dependencies
pnpm install
# Set up environment variables
cp .env.example .env.localEdit .env.local with your configuration:
# Stellar Network (use testnet for development)
NEXT_PUBLIC_STELLAR_NETWORK=testnet
NEXT_PUBLIC_STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE=Test SDF Network ; September 2015
# Soroban RPC
NEXT_PUBLIC_SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
NEXT_PUBLIC_AJO_CONTRACT_ADDRESS=<your-contract-address>
# Database
DATABASE_URL=file:./dev.db
# JWT Secret (change for production!)
JWT_SECRET=your-super-secret-jwt-key-change-this
# API
NEXT_PUBLIC_API_URL=http://localhost:3000/api# Generate Prisma client
pnpm prisma generate
# Create database and run migrations
pnpm prisma migrate dev
# Seed database (optional)
pnpm prisma db seed# Install Soroban CLI
# See: https://developers.stellar.org/docs/smart-contracts/getting-started/setup
# Build the contract
cd contracts/ajo-circle
cargo build --target wasm32-unknown-unknown --release
# Deploy to testnet (requires Stellar account with XLM)
# Follow Soroban deployment guide with the compiled WASM
# Update NEXT_PUBLIC_AJO_CONTRACT_ADDRESS in .env.localpnpm devOpen http://localhost:3000 to view the app.
POST /api/auth/register
Content-Type: application/json
{
"email": "[email protected]",
"password": "SecurePassword123!",
"firstName": "John",
"lastName": "Doe"
}POST /api/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "SecurePassword123!"
}POST /api/circles
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "Office Savings Circle",
"description": "Monthly savings circle for office team",
"contributionAmount": 100.50,
"contributionFrequencyDays": 7,
"maxRounds": 12
}GET /api/circles
Authorization: Bearer <token>GET /api/circles/:id
Authorization: Bearer <token>POST /api/circles/:id/contribute
Authorization: Bearer <token>
Content-Type: application/json
{
"amount": 100.50
}The Soroban smart contract (contracts/ajo-circle/src/lib.rs) implements:
initialize_circle()- Create a new circleadd_member()- Add member to circlecontribute()- Record member contributionclaim_payout()- Claim payout when it's member's turnpartial_withdraw()- Withdraw portion with penaltyget_circle_state()- Query current circle statusget_member_balance()- Query member detailsget_members()- List all members
- Circle metadata (organizer, amounts, frequency, rounds)
- Member records (contributions, withdrawals, payout status)
- Contribution tracking
cd contracts/ajo-circle
# Build WASM
cargo build --target wasm32-unknown-unknown --release
# The compiled WASM will be in:
# target/wasm32-unknown-unknown/release/ajo_circle.wasm- Push code to GitHub:
git add .
git commit -m "Initial commit"
git push origin main- Deploy to Vercel:
- Connect your GitHub repository at vercel.com
- Set environment variables in Vercel dashboard
- Deploy!
- Network:
Test SDF Network ; September 2015 - Horizon:
https://horizon-testnet.stellar.org - Soroban RPC:
https://soroban-testnet.stellar.org
- Network:
Public Global Stellar Network ; September 2015 - Horizon:
https://horizon.stellar.org - Soroban RPC:
https://soroban.stellar.org
Before mainnet deployment:
- Change JWT_SECRET to a secure random string
- Enable HTTPS on production
- Set up rate limiting on API routes
- Implement input validation on all endpoints
- Audit smart contract code
- Set up database backups
- Enable wallet signature verification
- Implement proper error handling
The application uses Prisma ORM with the following main tables:
- User: User accounts and profiles
- Circle: Savings circles
- CircleMember: Circle membership and rotation tracking
- Contribution: Contribution transactions
- PaymentSchedule: Payout schedule tracking
- GovernanceProposal: Voting proposals
- GovernanceVote: Vote records
- Withdrawal: Partial withdrawal requests
- Session: Authentication sessions
See prisma/schema.prisma for complete schema details.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
For issues, questions, or suggestions, please open an issue on GitHub.
- Stellar Development Foundation - For the incredible Stellar Network and Soroban
- Vercel - For deployment infrastructure
- shadcn/ui - For beautiful UI components
- Traditional Ajo/Esusu communities - For inspiring this project
Built with ❤️ for communities saving together.