NeuroWealth is an autonomous AI investment agent that automatically manages and grows users' crypto assets on the Stellar blockchain. Deposit once, the AI finds the best yield opportunities across Stellar's DeFi ecosystem; users can withdraw anytime with no lock-ups.
This repository contains the backend API (Express + TypeScript), Stellar integration, Prisma schema and migrations, and utilities for authentication (Stellar signature challenge + JWT sessions).
- Copy the example environment file and adjust secrets:
copy .env.example .env- Edit
.envand set secure values:
DATABASE_URL— PostgreSQL connection string (see below)DB_NAME,DB_PASSWORD— used bydocker-compose.ymlwhen running Postgres locallyJWT_SEED— 64-hex secret (generate withopenssl rand -hex 64)WALLET_ENCRYPTION_KEY— 32-byte hex (generate withopenssl rand -hex 32)
To run a local Postgres instance used by the project:
docker compose up -d
docker compose ps
docker compose logs anylistDB --tail 200The docker-compose.yml expects these env vars (set them in your .env):
DB_NAME=neurowealth
DB_PASSWORD=postgres_password_here
DATABASE_URL=postgresql://postgres:postgres_password_here@localhost:5432/neurowealth
Generate the Prisma client (run after any schema.prisma change):
npx prisma generateCreate and apply a migration (development):
npx prisma migrate dev --name initNotes:
migrate devwill create a new migration inprisma/migrations/and apply it to the database specified byDATABASE_URL.- To reset a development database (WARNING: destroys data):
npx prisma migrate reset
# or if your Prisma version requires preview option
npx prisma migrate reset --preview-featureApply migrations in production (use CI or a deployment task):
npx prisma migrate deployIf you have a seed script (see prisma/seed.ts), run:
npx prisma db seedDevelopment (with ts-node + nodemon):
npm install
npm run devBuild and run:
npm run build
npm startRun unit tests (Jest):
npm testPOST /api/auth/challenge— client postsstellarPubKey, server returns a one-timenonce.- Client signs
noncewith their Stellar key (Freighter) and sends signature toPOST /api/auth/verify. - Server verifies signature, creates user if missing, issues JWT (stored as a session in DB).
- Protected endpoints require
Authorization: Bearer <token>and are validated against thesessionstable; logout removes the session.
- If the app logs
Cannot connect to database, checkDATABASE_URL, and that Postgres is running (Docker or external). - If migrating fails, confirm the DB user has permission to CREATE/ALTER tables.
- Ensure
JWT_SEEDandWALLET_ENCRYPTION_KEYare set when running the server.