Skip to content
BigNathan1Public

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

836 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CoopLumen

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

License: MIT PRs Welcome codecov 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
β”‚   β”œβ”€β”€ scripts/                # Manual testnet verification scripts
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/     # Auth, CSRF, validation, rate limiting, errors
β”‚   β”‚   β”‚   β”œβ”€β”€ routes/         # One router per resource
β”‚   β”‚   β”‚   β”œβ”€β”€ schemas/        # Zod request schemas
β”‚   β”‚   β”‚   └── utils/          # Session tokens, cookies, pagination, Horizon errors
β”‚   β”‚   β”œβ”€β”€ cache/              # Redis and in-process caches
β”‚   β”‚   β”œβ”€β”€ contracts/          # Stellar SDK layer: assets, trustlines, payments
β”‚   β”‚   β”œβ”€β”€ services/           # Non-Stellar integrations (market price feed)
β”‚   β”‚   β”œβ”€β”€ db/                 # PostgreSQL pool, migrations and seed data
β”‚   β”‚   β”œβ”€β”€ testing/            # Shared test setup, teardown and fixtures
β”‚   β”‚   └── utils/              # Logger
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ frontend/                   # Next.js (App Router)
β”‚   β”œβ”€β”€ e2e/                    # Playwright end-to-end suite and its support code
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                # Routes, layout, global CSS
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/             # Design-system primitives
β”‚   β”‚   β”‚   β”œβ”€β”€ layout/         # Header, footer, sidebar, navigation, theme and locale
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/           # Protected routes and re-authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ community/      # Community and member forms and lists
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/      # Dashboard view
β”‚   β”‚   β”‚   β”œβ”€β”€ landing/        # Marketing landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ loans/          # Lending flow
β”‚   β”‚   β”‚   β”œβ”€β”€ multisig/       # Multi-signature proposals
β”‚   β”‚   β”‚   β”œβ”€β”€ profile/        # Account profile
β”‚   β”‚   β”‚   β”œβ”€β”€ reputation/     # Borrower reputation
β”‚   β”‚   β”‚   β”œβ”€β”€ tokens/         # Token issuance, transfer and listing
β”‚   β”‚   β”‚   β”œβ”€β”€ transactions/   # Transaction history and live feed
β”‚   β”‚   β”‚   β”œβ”€β”€ treasury/       # Treasury balances and signers
β”‚   β”‚   β”‚   └── wallet/         # Wallet connection and balances
β”‚   β”‚   β”œβ”€β”€ hooks/              # SWR data-fetching and mutation hooks
β”‚   β”‚   └── lib/                # API client, SWR config, schemas, design tokens
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ contracts/governance/       # Soroban governance contract (Rust)
β”œβ”€β”€ deploy/                     # nginx config for blue/green production deploys
β”œβ”€β”€ docs/                       # Guides, design and the OpenAPI spec
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ ci/                     # Branch protection setup
β”‚   β”œβ”€β”€ db/                     # Backup and constraint-validation scripts
β”‚   β”œβ”€β”€ deploy/                 # Deploy, rollback, smoke-test and notify scripts
β”‚   └── issues/                 # Backlog tooling
β”œβ”€β”€ .github/                    # CI, release, publish and deploy workflows
└── docker-compose*.yml         # Local, test, E2E and production stacks

Quick Start

Prerequisites

1. Clone

git clone https://github.com/BigNathan1/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
STELLAR_WEBHOOK_SECRET - HMAC secret for Stellar callbacks
KYC_WEBHOOK_SECRET - HMAC secret for KYC provider callbacks
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/v1/tokens/build-issue Build an unsigned issuance transaction for the issuer's wallet to sign
POST /api/v1/tokens/build-trustline Build an unsigned trustline transaction for the holder's wallet to sign
POST /api/v1/tokens/build-burn Build an unsigned burn transaction for the holder's wallet to sign
POST /api/v1/tokens/build-airdrop Build one unsigned transaction paying every community member
POST /api/v1/tokens/submit Submit a signed transaction envelope
GET /api/v1/tokens List every token (operators only)

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

# End-to-end (Playwright, needs the Docker Compose stack)
docker compose -f docker-compose.yml -f docker-compose.e2e.yml up -d --build --wait
cd frontend && npm run test:e2e

The end-to-end suite drives a browser against the whole stack. See Testing for how to run it and how to write a spec.


Documentation

Community


License

MIT Β© CoopLumen Contributors

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages