Skip to content

BigNathan1/CoopLumen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CoopLumen

Decentralized community finance on the Stellar blockchain β€” open source, contributor-first.

License: MIT PRs Welcome Node.js Next.js Stellar


Why CoopLumen?

Traditional finance excludes billions of people through geographic barriers, credit requirements, and prohibitive fees. CoopLumen uses the Stellar network β€” with its 5-second finality, near-zero fees, and built-in DEX β€” to give any group (NGO, cooperative, local community, diaspora network) the tools to issue community tokens, run peer-to-peer lending pools, and govern shared treasuries without a bank in the middle.

Why Stellar specifically?

  • Speed & cost: Transactions settle in 3–5 seconds for fractions of a cent
  • Built-in asset primitives: Native support for custom assets, trustlines, and multi-sig
  • Soroban smart contracts: Path to on-chain governance in Phase 3
  • Freighter wallet: Mature browser extension for end-user signing

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Browser / PWA                         β”‚
β”‚   Next.js 14 (App Router)  Β·  Freighter Wallet Extension    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚ REST (JSON)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Node.js / Express API  (port 4000)              β”‚
β”‚   /api/communities   /api/tokens   /api/balances             β”‚
β”‚                                                              β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚  /contracts      β”‚   β”‚  PostgreSQL (off-chain meta) β”‚   β”‚
β”‚   β”‚  assets.ts       β”‚   β”‚  communities Β· members       β”‚   β”‚
β”‚   β”‚  trustlines.ts   β”‚   β”‚  loans                       β”‚   β”‚
β”‚   β”‚  transactions.ts β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚ Stellar SDK (Horizon REST)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Stellar Network (Testnet / Mainnet)              β”‚
β”‚        Horizon API Β· Asset issuance Β· Trustlines             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

cooplumen/
β”œβ”€β”€ backend/                  # Node.js / Express API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/   # errorHandler, notFound
β”‚   β”‚   β”‚   └── routes/       # communities, tokens, balances
β”‚   β”‚   β”œβ”€β”€ contracts/        # Stellar SDK wrappers
β”‚   β”‚   β”‚   β”œβ”€β”€ assets.ts     # Asset issuance
β”‚   β”‚   β”‚   β”œβ”€β”€ trustlines.ts # Trustline management
β”‚   β”‚   β”‚   β”œβ”€β”€ transactions.ts # Payment building & submission
β”‚   β”‚   β”‚   └── stellar.ts    # Horizon server singleton
β”‚   β”‚   β”œβ”€β”€ db/               # PostgreSQL pool & migrations
β”‚   β”‚   └── utils/            # Logger
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ frontend/                 # Next.js 14 (App Router)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/              # Routes, layout, global CSS
β”‚   β”‚   β”œβ”€β”€ components/       # Dashboard, WalletConnect, CommunityCard, BalancePanel
β”‚   β”‚   └── hooks/            # useWallet, useCommunities, useBalances
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ README.md
β”œβ”€β”€ PRD.md
└── CONTRIBUTING.md

Quick Start

Prerequisites

1. Clone

git clone https://github.com/yourname/cooplumen.git
cd cooplumen

2. Configure environment

# Backend
cp backend/.env.example backend/.env

# Frontend
cp frontend/.env.example frontend/.env.local

Edit backend/.env to set your Stellar keys and network preference.

3. Start with Docker (recommended)

docker-compose up

This starts:

  • PostgreSQL on localhost:5432
  • Backend API on localhost:4000
  • Frontend on localhost:3000

4. Run database migrations

docker-compose exec backend npm run db:migrate

5. Open the app

Navigate to http://localhost:3000 and connect Freighter.


Local Development (without Docker)

# Terminal 1 β€” Backend
cd backend
npm install
npm run dev          # starts ts-node-dev on :4000

# Terminal 2 β€” Frontend
cd frontend
npm install
npm run dev          # starts Next.js on :3000

You will need a local PostgreSQL instance. Set DATABASE_URL in backend/.env.


Environment Variables

Backend (backend/.env)

Variable Default Description
PORT 4000 API server port
DATABASE_URL β€” PostgreSQL connection string
STELLAR_NETWORK testnet testnet or mainnet
STELLAR_HORIZON_URL Testnet Horizon Override Horizon endpoint
FRONTEND_URL http://localhost:3000 CORS allowed origin
LOG_LEVEL info winston log level

Frontend (frontend/.env.local)

Variable Default Description
NEXT_PUBLIC_API_URL http://localhost:4000 Backend API base URL
NEXT_PUBLIC_STELLAR_NETWORK TESTNET Network shown in UI

API Reference

Communities

Method Path Description
GET /api/communities List all communities
GET /api/communities/:id Get a single community
POST /api/communities Register a new community
GET /api/communities/:id/members List community members
POST /api/communities/:id/members Add a member

Tokens

Method Path Description
POST /api/tokens/issue Issue community token on Stellar
POST /api/tokens/trustline Establish trustline for a member

Balances

Method Path Description
GET /api/balances/:publicKey Get all balances for an account
GET /api/balances/:publicKey/loans Get loans for an account
GET /api/balances/community/:id/loans Get all loans in a community

Health

GET /health  β†’  { "status": "ok", "version": "0.1.0" }

Example: Register a community via cURL

curl -X POST http://localhost:4000/api/communities \
  -H "Content-Type: application/json" \
  -d '{
    "name": "EcoDAO Lagos",
    "description": "Eco-finance cooperative for Lagos community",
    "issuerPublicKey": "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    "assetCode": "ECOLGS",
    "assetIssuer": "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  }'

Testing

# Backend
cd backend && npm test
cd backend && npm run test:coverage

# Frontend
cd frontend && npm test

Links

Community


License

MIT Β© CoopLumen Contributors

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors