diff --git a/Readme.md b/Readme.md
index 02e1a0d..b304f80 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,90 +1,203 @@

-
+
# StellarSettle Web App
-
- **Modern web interface for decentralized invoice financing**
-
- [](https://opensource.org/licenses/MIT)
+
+ **Web interface for decentralized invoice financing and creator-key markets on Stellar**
+
[](https://nextjs.org)
+ [](https://react.dev)
[](https://www.typescriptlang.org/)
+ [](https://stellar.org)
-## ๐ Overview
+## Table of Contents
+
+- [Overview](#overview)
+- [Tech Stack](#tech-stack)
+- [Project Structure](#project-structure)
+- [Feature Areas](#feature-areas)
+ - [Authentication & Wallet](#authentication--wallet)
+ - [KYC](#kyc)
+ - [Invoice Marketplace (Sellers & Investors)](#invoice-marketplace-sellers--investors)
+ - [Creator Keys](#creator-keys)
+ - [Admin Panel](#admin-panel)
+ - [Notifications & Activity](#notifications--activity)
+- [API Layer](#api-layer)
+- [Getting Started](#getting-started)
+- [Environment Variables](#environment-variables)
+- [Available Scripts](#available-scripts)
+- [Testing](#testing)
+- [Continuous Integration](#continuous-integration)
+- [Contributing](#contributing)
+- [License](#license)
+
+## Overview
+
+StellarSettle is a Next.js (App Router) frontend built on two related product surfaces:
+
+1. **Invoice financing marketplace** โ sellers publish invoices for funding, investors browse and invest, funded invoices are tracked through settlement and payout, all gated behind a KYC flow.
+2. **Creator Keys** โ a tokenized creator-economy layer: buyable/burnable "keys" per creator with governance voting, vesting schedules, whitelisting, dividend distribution, and admin-controlled trading pauses/timelocks.
+
+Both surfaces share a wallet-based auth layer (Stellar via Freighter), a common API client (`lib/api/index.ts`), and an admin panel that reviews invoices, manages settlements, and controls key trading.
+
+> Note: this Readme was rewritten from the actual current codebase (routes, `lib/api` exports, `package.json` scripts) rather than the project's original template copy, which described only the invoice-marketplace half and referenced scripts/tooling (Playwright e2e, a11y tests, Docker, Vercel CLI steps) that aren't present in this repo. See [Getting Started](#getting-started) and [Available Scripts](#available-scripts) below for what actually exists today.
+
+## Tech Stack
+
+| Concern | Library |
+|---|---|
+| Framework | Next.js 15 (App Router, Turbopack dev server) |
+| UI runtime | React 19 |
+| Language | TypeScript 5.7 |
+| Styling | Tailwind CSS 4 (`@tailwindcss/postcss`) |
+| Component primitives | Radix UI + `radix-ui`, styled as shadcn/ui ("New York" style) |
+| Icons | lucide-react |
+| Data fetching / cache | TanStack React Query 5 |
+| HTTP client | axios |
+| Forms | React Hook Form + `@hookform/resolvers` |
+| Validation | Zod |
+| Charts | Recharts |
+| Dates | date-fns |
+| Toasts | sonner |
+| Theming | next-themes |
+| Stellar wallet | `@stellar/freighter-api` |
+| Stellar SDK | `stellar-sdk` |
+| Unit/component testing | Vitest 4 + Testing Library (React, DOM, user-event) + jsdom |
+| Lint | ESLint (`eslint-config-next`) |
+
+## Project Structure
-User-friendly web application for StellarSettle featuring:
-
-- ๐ Seller dashboard for invoice management
-- ๐ผ Investor marketplace for browsing opportunities
-- ๐ Stellar wallet integration (Freighter, xBull)
-- ๐ Real-time analytics and reporting
-- ๐ฑ Responsive mobile-first design
-- ๐ Dark mode support
-
-## ๐๏ธ Architecture
```
app/
-โโโ (auth)/ # Authentication pages
-โโโ (dashboard)/ # Protected dashboard pages
-โ โโโ seller/ # Seller views
-โ โโโ investor/ # Investor views
-โโโ marketplace/ # Public marketplace
-โโโ api/ # API routes (if needed)
+โโโ page.tsx # Landing page โ top-investors leaderboard + recently-viewed invoices
+โโโ layout.tsx, error.tsx, not-found.tsx, globals.css
+โโโ (auth)/
+โ โโโ connect-wallet/ # Freighter connection step
+โ โโโ login/
+โ โโโ register/
+โโโ (dashboard)/
+โ โโโ seller/ # Seller dashboard
+โ โ โโโ edit/[id]/ # Edit a published invoice
+โ โ โโโ invoices/[id]/edit/
+โ โ โโโ publish/ # Publish flow + success page
+โ โโโ investor/ # Investor dashboard (portfolio)
+โ โโโ notifications/
+โโโ admin/
+โ โโโ invoices/ # Admin invoice queue
+โ โโโ review/ # Admin invoice review
+โโโ kyc/
+โ โโโ start/
+โ โโโ reapply/
+โ โโโ confirmed/
+โโโ keys/[keyId]/ # Creator key detail page
+โโโ marketplace/
+โ โโโ [id]/ # Invoice detail
+โโโ profile/
+โโโ api/ # (currently unused โ .gitkeep only; the app calls an external API via lib/api)
components/
-โโโ ui/ # Reusable UI components (shadcn)
-โโโ dashboard/ # Dashboard-specific components
-โโโ invoices/ # Invoice components
-โโโ wallet/ # Wallet connection components
+โโโ ui/ # shadcn/ui primitives: button, card, input, select, dialog(dropdown/popover), badge, skeleton, sonner, switch, textarea, separator, label
+โโโ layout/ # Navbar, NotificationBellBadge, GoToMarketplaceButton
+โโโ marketplace/ # invoice-card, filter-bar/FilterPanel, countdown-timer, recently-viewed, TopInvestorsLeaderboard
+โโโ invoices/ # PublishInvoiceForm, EditInvoiceForm, InvoiceDetail, InvestDialog/InvestmentModal, DocumentUpload/DocumentPreview, FundingProgressBar, InvoiceStatusBadge, SettlementReturnCard, ShareInvoiceButton, ErrorBoundary
+โโโ dashboard/ # SellerDashboard, InvestorPortfolio, PositionCard, PayoutHistoryTable, KycStatusBanner, KycSubmissionForm, NotificationList/Preferences, OnboardingChecklist, UserProfile, WalletActivityFeed, VestingProgressWidget, KeyTransferModal, HoldingActionsMenu
+โโโ keys/ # BuyKeyPanel, CreatorKeyDetail, CreatorRevenueSection, CreatorVestingSection, GovernanceTab, VoteModal, CreateProposalModal, SupplyCapSection/Settings, WhitelistManager, BurnKeyModal, DistributeDividendsPanel
+โโโ admin/ # AdminInvoiceReview(s), AdminSettlements, AuditLogViewer, TimelockProposalsPanel, TradingControlsPanel
+โโโ wallet/ # WalletChip
+โโโ providers.tsx # App-wide providers (React Query, theming, etc.)
+
+context/
+โโโ AuthContext.tsx # Wallet/session auth state
+
+hooks/ # One hook per data domain โ useAuth, useStellarWallet, useInvoices, useInvestments,
+ # usePortfolio, useSellerDashboard, useCreatorKeys, useCreatorRevenue, useVesting,
+ # useWhitelist, useTimelockProposals, useTradingPause, useWalletActivity,
+ # useNotifications, useNotificationPreferences, useLeaderboard, useRecentlyViewed,
+ # useCountdown, usePageTitle, usePageLoadPerformanceLog
lib/
-โโโ stellar/ # Stellar SDK utilities
-โโโ api/ # API client
-โโโ utils/ # Helper functions
-
-hooks/
-โโโ useStellar.ts # Stellar wallet hook
-โโโ useInvoices.ts # Invoice data hook
-โโโ useInvestments.ts # Investment data hook
+โโโ api/index.ts # Single API client module โ every network call + response/request type (see below)
+โโโ stellar/index.ts # connectWallet/getNetwork/getAddress/truncateAddress via Freighter
+โโโ auth.ts, format.ts, logger.ts, performance-logger.ts, portfolio.ts, recentlyViewed.ts, utils.ts
+โโโ validation/ # deadline.ts, face-value.ts, investment-amount.ts (Zod schemas)
```
-## ๐ Quick Start
+## Feature Areas
+
+### Authentication & Wallet
+
+- `(auth)/connect-wallet`, `(auth)/login`, `(auth)/register` handle onboarding.
+- `lib/stellar/index.ts` wraps `@stellar/freighter-api`: `connectWallet()`, `getNetwork()`, `getAddress()`, plus a `truncateAddress()` display helper.
+- `context/AuthContext.tsx` + `hooks/useAuth.ts` / `useStellarWallet.ts` hold the session/wallet state consumed across the app (e.g. `components/wallet/WalletChip.tsx` in the navbar).
+
+### KYC
+
+- `app/kyc/start`, `app/kyc/reapply`, `app/kyc/confirmed` implement the seller KYC flow.
+- `submitKyc()` and `fetchSellerKycStatus()` in `lib/api/index.ts`; status is one of the values in `SellerKycStatusValue`, surfaced via `KycStatusBanner`/`KycSubmissionForm`.
+
+### Invoice Marketplace (Sellers & Investors)
+
+- **Sellers**: `(dashboard)/seller` โ publish (`PublishInvoiceForm`, `publishInvoice()`), edit, and track invoices via `SellerDashboard`/`fetchSellerDashboard()`.
+- **Investors**: `/marketplace` browse + filter (`FilterPanel`, `filter-bar`), `/marketplace/[id]` detail + invest (`InvestDialog`/`InvestmentModal` โ `investInInvoice()`), `(dashboard)/investor` portfolio (`InvestorPortfolio`, `fetchPortfolio()`), payout history (`PayoutHistoryTable`, `fetchInvestorPayouts()`).
+- Invoices carry `status`: `"open" | "funded" | "settled" | "rejected" | "draft"`, a `yield_percentage`, and support position transfer between investors (`transferInvoicePosition()`).
+- Documents attach via `uploadDocumentToIpfs()` (`DocumentUpload`/`DocumentPreview`).
+- A leaderboard (`TopInvestorsLeaderboard`, `useLeaderboard`) and a recently-viewed list (`useRecentlyViewed`, backed by `lib/recentlyViewed.ts`) appear on the landing page.
+
+### Creator Keys
+
+A parallel tokenized system, per creator:
+
+- **Buying/burning**: `BuyKeyPanel` โ `buyCreatorKey()`; `BurnKeyModal` โ `burnCreatorKey()`; transfer via `KeyTransferModal` โ `transferCreatorKey()`.
+- **Supply**: `KeySupply`, `SupplyCapSection`/`SupplyCapSettings` โ `fetchKeySupply()`, `updateKeySupplyCap()`.
+- **Governance**: `GovernanceTab`, `CreateProposalModal`, `VoteModal` โ `fetchKeyProposals()`, `createGovernanceProposal()`, `castGovernanceVote()`.
+- **Vesting**: `VestingProgressWidget`, `CreatorVestingSection`, `useVesting` โ `fetchVestingSchedule()`, `claimVestedKeys()`.
+- **Whitelisting**: `WhitelistManager`, `useWhitelist` โ `fetchKeyWhitelistStatus()`, `fetchKeyWhitelist()`, `addWhitelistAddress()`, `removeWhitelistAddress()`, `updateWhitelistMode()`.
+- **Revenue & dividends**: `CreatorRevenueSection`, `useCreatorRevenue` โ `fetchCreatorRevenue()` (with `MonthlyRevenue` breakdowns); `DistributeDividendsPanel` โ `distributeDividend()`.
+- `app/keys/[keyId]` is the public creator-key detail page (`CreatorKeyDetail`, `fetchCreatorKeyDetail()`).
+
+### Admin Panel
+
+`app/admin` (invoice queue, review) plus components under `components/admin/`:
+
+- **Invoice review**: `AdminInvoiceReview(s)` โ `fetchAdminInvoices()`, `approveAdminInvoice()`, `rejectAdminInvoice()`.
+- **Settlements**: `AdminSettlements` โ `fetchSettlements()`, `proposeSettlement()`, `approveSettlement()`.
+- **Key trading controls**: `TradingControlsPanel`, `useTradingPause` โ `fetchAdminKeyControls()`, `proposeKeyPause()`, `approveKeyPause()` (trading status: `"active" | "pause_pending" | "paused"`).
+- **Timelock proposals**: `TimelockProposalsPanel`, `useTimelockProposals` โ `fetchTimelockProposals()`, `executeTimelockProposal()`, `cancelTimelockProposal()`.
+- **Audit log**: `AuditLogViewer` โ `fetchAuditLog()`.
+
+### Notifications & Activity
+
+- `NotificationList`, `NotificationPreferences`, `NotificationBellBadge`, `useNotifications`/`useNotificationPreferences` โ `fetchNotificationPreferences()`, `updateNotificationPreference()`. Notification events: `"new_invoice" | "funding_milestone" | "settlement"`; channels: `"email" | "in_app"`.
+- `WalletActivityFeed`, `useWalletActivity` โ `fetchWalletActivity()` (typed `WalletActivityEvent`/`WalletActivityType`).
+
+## API Layer
+
+`lib/api/index.ts` is the single module every hook/component calls into for network access โ it has no framework dependency of its own (plain `fetch`/`axios` + typed request/response interfaces) and is the first place to look when tracing a feature end-to-end. It centralizes: invoices, protocol status, notifications, IPFS document upload, portfolio, seller dashboard/KYC, admin invoice + settlement + key-control + timelock + audit endpoints, creator-key detail/governance/whitelist/supply/vesting/revenue, payouts, and wallet activity โ see the file directly for exact request/response shapes; every exported function and type is grep-able there in one place (`export async function` / `export interface`).
+
+## Getting Started
### Prerequisites
-- Node.js 18+
-- Stellar wallet browser extension (Freighter recommended)
+- Node.js (a version compatible with Next.js 15 / React 19 โ Node 18+ is the practical floor)
+- A Stellar wallet browser extension for local testing (Freighter)
### Installation
+
```bash
-# Install dependencies
npm install
-
-# Copy environment variables
cp .env.example .env.local
-
-# Edit environment variables
-nano .env.local
-
-# Start development server
+# edit .env.local with real values
npm run dev
-
-# Open http://localhost:3000
+# open http://localhost:3000
```
-### Install all shadcn/ui components (optional)
+`npm run dev` uses Next.js with Turbopack.
-The project uses [shadcn/ui](https://ui.shadcn.com) (New York style, Slate theme). A few base components are included. To add the full set (form, dialog, sheet, toast, etc.) run:
+## Environment Variables
-```bash
-# If you see "Lock compromised" or npm cache errors, run first:
-npm cache clean --force
+From `.env.example`:
-# Then install all shadcn components:
-npm run shadcn:add
-```
-
-### Environment Variables
```env
# API
NEXT_PUBLIC_API_URL=http://localhost:3000/api
@@ -103,114 +216,50 @@ NEXT_PUBLIC_ENABLE_ANALYTICS=true
NEXT_PUBLIC_ENABLE_NOTIFICATIONS=true
```
-## ๐จ Design System
-
-Built with:
-- **UI Components**: shadcn/ui + Radix UI
-- **Styling**: TailwindCSS
-- **Icons**: Lucide React
-- **Charts**: Recharts
-- **Forms**: React Hook Form + Zod validation
-- **Tables**: TanStack Table
-
-Color palette:
-```css
---primary: #0066CC (Stellar blue)
---secondary: #F8D12F (Stellar yellow)
---accent: #00B4D8
---background: #FFFFFF / #0A0A0A (dark mode)
-```
-
-## ๐ฑ Key Features
-
-### For Sellers
-- Upload invoices (PDF, drag-and-drop)
-- View invoice status & history
-- Track payments in real-time
-- Analytics dashboard
-- Export reports
-
-### For Investors
-- Browse marketplace with filters
-- View invoice risk scores
-- One-click investments
-- Portfolio tracking
-- ROI calculator
-
-### Shared
-- Stellar wallet connection
-- Multi-signature support
-- Transaction history
-- Notifications (email + in-app)
-- Mobile responsive
-
-## ๐งช Testing
-```bash
-# Run unit tests
-npm test
+## Available Scripts
-# Run E2E tests (Playwright)
-npm run test:e2e
+Exactly what's defined in `package.json` โ nothing more:
-# Run accessibility tests
-npm run test:a11y
+| Command | Description |
+|---|---|
+| `npm run dev` | Start the dev server (Turbopack) |
+| `npm run build` | Production build |
+| `npm start` | Serve the production build |
+| `npm run lint` | `next lint` |
+| `npm run type-check` | `tsc --noEmit` |
+| `npm test` | `vitest run` |
+| `npm run shadcn:add` | Installs the full shadcn/ui component set (form, dialog, sheet, toast, table, tabs, tooltip, etc.) beyond the base components already in `components/ui/` โ run `npm cache clean --force` first if you hit a "Lock compromised"/npm cache error |
-# Generate coverage
-npm run test:coverage
-```
-
-## ๐ Deployment
-
-### Vercel (Recommended)
-```bash
-# Install Vercel CLI
-npm i -g vercel
-
-# Deploy
-vercel --prod
-```
-
-### Docker
-```bash
-# Build image
-docker build -t stellarsettle-app .
-
-# Run container
-docker run -p 3000:3000 stellarsettle-app
-```
+There is no `test:e2e`, `test:a11y`, `test:coverage`, Docker, or Vercel-CLI script in this repo at present โ if you need those workflows, add them rather than assuming they exist.
-### Environment Specific
-- Development: `npm run dev`
-- Staging: `npm run build && npm start`
-- Production: Deploy to Vercel/Netlify
+## Testing
-## ๐ Security
+- **Runner**: Vitest 4, `jsdom` environment, configured in `vitest.config.ts` / `vitest.setup.ts`.
+- **Component testing**: `@testing-library/react` + `@testing-library/user-event` + `@testing-library/dom` + `@testing-library/jest-dom` matchers.
+- Tests live alongside the code they cover, in `__tests__/` directories: `app/__tests__`, `app/admin/invoices/__tests__`, `app/marketplace/__tests__`, `components/*/__tests__`, `hooks/__tests__`, `lib/__tests__`, `lib/validation/__tests__`, `context/__tests__`.
+- Run everything with `npm test`.
-- CSP headers configured
-- XSS protection via Next.js
-- CSRF tokens for sensitive operations
-- Wallet signature verification
-- Rate limiting on API routes
-- Secure cookie settings
+## Continuous Integration
-## ๐ Performance
+GitHub Actions workflows in `.github/workflows/`:
-- Lighthouse score: 95+
-- First Contentful Paint: <1.5s
-- Time to Interactive: <3.0s
-- Code splitting & lazy loading
-- Image optimization (next/image)
-- API response caching
+- `app-ci.yml` / `ci.yml` โ lint, type-check, test, build on PRs.
+- `pr-target-check.yml` โ enforces the branch-targeting rule below (PRs against `main` are closed automatically).
+## Contributing
-## ๐ค Contributing
+Full detail in [CONTRIBUTING.md](CONTRIBUTING.md); the essentials:
-See [CONTRIBUTING.md](../CONTRIBUTING.md)
+- **`dev` is the default/active branch.** `main` is production-only. Branch off `dev`, and target `dev` in your PR โ a PR opened against `main` is closed automatically.
+- Branch naming: `feature/โฆ`, `fix/โฆ`, `docs/โฆ`, `test/โฆ`, `refactor/โฆ`, `chore/โฆ`.
+- Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat(scope): โฆ`, `fix(scope): โฆ`).
+- Before opening a PR, run locally (see [DEVELOPMENT.md](DEVELOPMENT.md)): `npm run lint`, `npx tsc --noEmit`, `npm run build`, `npm test`.
+- PRs to `dev` need CI green + 1 approval; `dev` โ `main` release PRs need 2 approvals (maintainer-driven; contributors don't need to manage releases).
-## ๐ License
+## License
-MIT License - see [LICENSE](LICENSE) file for details
+No `LICENSE` file is currently present in this repository. Treat licensing as unspecified until the maintainers add one โ don't assume MIT (or any other license) from this document alone.
---
-Built with โค๏ธ on Stellar
+Built on Stellar.