Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ Thank you for your interest in contributing to NotifyChain! This document provid

**Start here instead (recommended):** [`CONTRIBUTOR_DEVELOPMENT_WORKFLOW_GUIDE.md`](CONTRIBUTOR_DEVELOPMENT_WORKFLOW_GUIDE.md)

## Documentation conventions

Use these names consistently in docs and PRs:

| Concept | Standard form |
|---------|----------------|
| Product name (prose/titles) | **NotifyChain** |
| GitHub repository / clone directory | **Notify-Chain** (`Core-Foundry/Notify-Chain`) |
| Off-chain service | **Listener** (`listener/`) |
| React + Vite UI | **Dashboard** (`dashboard/`) |
| Legacy analytics app | **Frontend** (`frontend/`) |
| On-chain code | **Smart contracts** (`contract/`, `Documents/Task Bounty/`) |

Canonical setup path: workflow guide → [`LOCAL_DEVELOPMENT.md`](LOCAL_DEVELOPMENT.md) (quick) → [`CONTRIBUTOR_SETUP.md`](CONTRIBUTOR_SETUP.md) (detailed).

## Code of Conduct

- Be respectful and inclusive
Expand Down
40 changes: 20 additions & 20 deletions CONTRIBUTOR_ARCHITECTURE_DEEP_DIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ NotifyChain is split into three decoupled components, separated by network and t
└────────────────────────────────────────────────────────────────────────┘
```

1. **Smart Contracts (On-Chain)**: Written in Rust for the Soroban smart contract platform. They run in a WebAssembly (WASM) sandbox, mutate ledger state, and emit structured events. Located in [contract/contracts/hello-world](file:///workspaces/Notify-Chain/contract/contracts/hello-world) and [Documents/Task Bounty](file:///workspaces/Notify-Chain/Documents/Task%20Bounty).
2. **Listener Service (Off-Chain Engine)**: Written in Node.js and TypeScript. It polls the Stellar RPC, parses, deduplicates, and stores events in SQLite, and dispatches real-time alerts. Located in [listener](file:///workspaces/Notify-Chain/listener).
3. **React Dashboard (Frontend)**: A standard Vite + React SPA that consumes the REST API exposed by the listener service to display events and schedule performance statistics. Located in [dashboard](file:///workspaces/Notify-Chain/dashboard).
1. **Smart Contracts (On-Chain)**: Written in Rust for the Soroban smart contract platform. They run in a WebAssembly (WASM) sandbox, mutate ledger state, and emit structured events. Located in [contract/contracts/hello-world](contract/contracts/hello-world) and [Documents/Task Bounty](Documents/Task%20Bounty).
2. **Listener Service (Off-Chain Engine)**: Written in Node.js and TypeScript. It polls the Stellar RPC, parses, deduplicates, and stores events in SQLite, and dispatches real-time alerts. Located in [listener](listener).
3. **React Dashboard (Frontend)**: A standard Vite + React SPA that consumes the REST API exposed by the listener service to display events and schedule performance statistics. Located in [dashboard](dashboard).

---

Expand All @@ -63,14 +63,14 @@ NotifyChain is split into three decoupled components, separated by network and t
NotifyChain supports two smart contract interaction patterns with different design structures:

### 2.1 Struct Event Pattern (AutoShare)
Implemented in [base/events.rs](file:///workspaces/Notify-Chain/contract/contracts/hello-world/src/base/events.rs). The contract defines dedicated struct types decorated with `#[contractevent]`. Each event carries standard routing topics:
Implemented in [base/events.rs](contract/contracts/hello-world/src/base/events.rs). The contract defines dedicated struct types decorated with `#[contractevent]`. Each event carries standard routing topics:
- **`NotificationCategory`**: A 4-variant enum mapping events to functional domains (`Group`, `Admin`, `Financial`, `Notification`).
- **`NotificationPriority`**: A 4-variant enum detailing severity (`Low`, `Medium`, `High`, `Critical`).

These are appended as the last two indexed topics to ensure backward compatibility for simpler indexers.

### 2.2 Subject-Action Event Pattern (TaskBounty)
Implemented in [src/events.rs](file:///workspaces/Notify-Chain/Documents/Task%20Bounty/src/events.rs). The contract does not use routing metadata structures. Instead, it emits events as tuples of short symbols matching the `(Subject, Action)` schema:
Implemented in [src/events.rs](Documents/Task%20Bounty/src/events.rs). The contract does not use routing metadata structures. Instead, it emits events as tuples of short symbols matching the `(Subject, Action)` schema:
- E.g., `(symbol_short!("task"), symbol_short!("created"))` or `(symbol_short!("sub"), symbol_short!("approved"))`.
- Payload arguments (like task ID, amount, and creator) are passed as tuples in the event data field.

Expand Down Expand Up @@ -116,15 +116,15 @@ sequenceDiagram
```

### 3.1 Step-by-Step Processing Pipeline:
1. **Polling**: The [EventSubscriber](file:///workspaces/Notify-Chain/listener/src/services/event-subscriber.ts) wakes up at configured intervals (default: 30 seconds) and invokes `getEvents` on the Stellar RPC using the last persisted ledger sequence.
2. **Persistent Deduplication**: The [EventDeduplicationService](file:///workspaces/Notify-Chain/listener/src/services/event-deduplication-service.ts) checks each incoming event. It references the `processed_events` SQLite table to see if the event ID has already been indexed.
1. **Polling**: The [EventSubscriber](listener/src/services/event-subscriber.ts) wakes up at configured intervals (default: 30 seconds) and invokes `getEvents` on the Stellar RPC using the last persisted ledger sequence.
2. **Persistent Deduplication**: The [EventDeduplicationService](listener/src/services/event-deduplication-service.ts) checks each incoming event. It references the `processed_events` SQLite table to see if the event ID has already been indexed.
3. **Reorg Handling**:
- If the RPC returns an event with a ledger number *lower* than the last processed ledger cursor, the system flags a blockchain reorganization.
- It sets `is_reorg_duplicate = true` on the event.
- The event is stored in SQLite for integrity, but the pipeline **skips sending Discord alerts or notifications** to prevent duplicate spam.
4. **In-Memory Cache (LRU)**: A secondary fast-path `NotificationDeduplicator` stores the last 60 seconds of event hashes in memory to prevent database roundtrips for duplicate frames.
5. **Persistence**: The event is formatted and saved to the `events` table. The `polling_cursors` table is updated with the new ledger index.
6. **Dispatch**: The [NotificationDispatcher](file:///workspaces/Notify-Chain/listener/src/services/notification-dispatcher.ts) formats the event and pushes it to active channels (e.g. Discord webhook).
6. **Dispatch**: The [NotificationDispatcher](listener/src/services/notification-dispatcher.ts) formats the event and pushes it to active channels (e.g. Discord webhook).

---

Expand Down Expand Up @@ -206,19 +206,19 @@ Because SQLite executes writes sequentially and locks the database, only one wor
Here are the critical paths and files that implement the core functionality of NotifyChain:

### 5.1 Smart Contracts
- [contract/contracts/hello-world/src/lib.rs](file:///workspaces/Notify-Chain/contract/contracts/hello-world/src/lib.rs): Entry point for the AutoShare contract. Declares the functions and maps calls to the logic module.
- [autoshare_logic.rs](file:///workspaces/Notify-Chain/contract/contracts/hello-world/src/autoshare_logic.rs): Core business logic for AutoShare groups, members, subscriptions, withdrawals, and scheduled notification parameters.
- [base/events.rs](file:///workspaces/Notify-Chain/contract/contracts/hello-world/src/base/events.rs): Structure definitions for category-priority routed events.
- [Documents/Task Bounty/src/lib.rs](file:///workspaces/Notify-Chain/Documents/Task%20Bounty/src/lib.rs): Entry point for the TaskBounty contract.
- [Documents/Task Bounty/src/events.rs](file:///workspaces/Notify-Chain/Documents/Task%20Bounty/src/events.rs): Emits the unstructured subject-action events for tasks, submissions, and disputes.
- [contract/contracts/hello-world/src/lib.rs](contract/contracts/hello-world/src/lib.rs): Entry point for the AutoShare contract. Declares the functions and maps calls to the logic module.
- [autoshare_logic.rs](contract/contracts/hello-world/src/autoshare_logic.rs): Core business logic for AutoShare groups, members, subscriptions, withdrawals, and scheduled notification parameters.
- [base/events.rs](contract/contracts/hello-world/src/base/events.rs): Structure definitions for category-priority routed events.
- [Documents/Task Bounty/src/lib.rs](Documents/Task%20Bounty/src/lib.rs): Entry point for the TaskBounty contract.
- [Documents/Task Bounty/src/events.rs](Documents/Task%20Bounty/src/events.rs): Emits the unstructured subject-action events for tasks, submissions, and disputes.

### 5.2 Off-Chain Listener Service
- [listener/src/index.ts](file:///workspaces/Notify-Chain/listener/src/index.ts): Initializer script. Bootstraps the HTTP API server, SQLite store, subscriber, and scheduler loops.
- [listener/src/services/event-subscriber.ts](file:///workspaces/Notify-Chain/listener/src/services/event-subscriber.ts): Polls Stellar RPC logs and drives the ingestion loop.
- [listener/src/services/event-deduplication-service.ts](file:///workspaces/Notify-Chain/listener/src/services/event-deduplication-service.ts): SQLite-backed deduplication layer; houses reorg-detection safeguards.
- [listener/src/services/notification-scheduler.ts](file:///workspaces/Notify-Chain/listener/src/services/notification-scheduler.ts): Periodically queries SQLite for due scheduled notifications, acquires locks, dispatches alerts, and performs recovery.
- [listener/src/store/](file:///workspaces/Notify-Chain/listener/src/store/): Holds the repositories (`EventRepository`, `ScheduleRepository`) managing queries to SQLite.
- [listener/src/index.ts](listener/src/index.ts): Initializer script. Bootstraps the HTTP API server, SQLite store, subscriber, and scheduler loops.
- [listener/src/services/event-subscriber.ts](listener/src/services/event-subscriber.ts): Polls Stellar RPC logs and drives the ingestion loop.
- [listener/src/services/event-deduplication-service.ts](listener/src/services/event-deduplication-service.ts): SQLite-backed deduplication layer; houses reorg-detection safeguards.
- [listener/src/services/notification-scheduler.ts](listener/src/services/notification-scheduler.ts): Periodically queries SQLite for due scheduled notifications, acquires locks, dispatches alerts, and performs recovery.
- [listener/src/store/](listener/src/store/): Holds the repositories (`EventRepository`, `ScheduleRepository`) managing queries to SQLite.

### 5.3 Frontend Dashboard
- [dashboard/src/pages/](file:///workspaces/Notify-Chain/dashboard/src/pages/): Contains top-level dashboard pages: `Events` (real-time stream), `Schedules` (notification queue stats), and `Stats` (overview charts).
- [dashboard/src/hooks/](file:///workspaces/Notify-Chain/dashboard/src/hooks/): React hooks for fetching event feeds, managing poll intervals, and querying status counts from the listener.
- [dashboard/src/pages/](dashboard/src/pages/): Contains top-level dashboard pages: `Events` (real-time stream), `Schedules` (notification queue stats), and `Stats` (overview charts).
- [dashboard/src/hooks/](dashboard/src/hooks/): React hooks for fetching event feeds, managing poll intervals, and querying status counts from the listener.
2 changes: 1 addition & 1 deletion CONTRIBUTOR_DEVELOPMENT_WORKFLOW_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A single, end-to-end workflow for local setup, branching, testing, and submittin
- Rust (stable) with WebAssembly target:
- `rustup target add wasm32-unknown-unknown`
- Stellar CLI:
- `cargo install stellar-cli`
- `cargo install --locked stellar-cli --features opt`
- Node.js:
- Listener uses **Node 20**
- Dashboard uses **Node 18**
Expand Down
16 changes: 6 additions & 10 deletions CONTRIBUTOR_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ This guide walks you through setting up a local development environment for
NotifyChain. By the end, you will have the listener service, the dashboard,
the frontend analytics app, and the smart contracts building and running on
your machine.
This guide walks you through setting up a local development environment for NotifyChain. By the end, you will have the listener service, the dashboard, and the smart contracts building and running on your machine.

For the canonical contribution workflow, start with
[`CONTRIBUTOR_DEVELOPMENT_WORKFLOW_GUIDE.md`](CONTRIBUTOR_DEVELOPMENT_WORKFLOW_GUIDE.md).
For a shorter setup path, see [`LOCAL_DEVELOPMENT.md`](LOCAL_DEVELOPMENT.md).

---

Expand All @@ -24,11 +27,6 @@ This guide walks you through setting up a local development environment for Noti
9. [Running Tests](#9-running-tests)
10. [VS Code Setup (Recommended)](#10-vs-code-setup-recommended)
11. [Troubleshooting & FAQ](#11-troubleshooting--faq)
5. [Smart Contracts Setup](#5-smart-contracts-setup)
6. [Environment Variables Reference](#6-environment-variables-reference)
7. [Running Tests](#7-running-tests)
8. [VS Code Setup (Recommended)](#8-vs-code-setup-recommended)
9. [Troubleshooting & FAQ](#9-troubleshooting--faq)

---

Expand All @@ -40,7 +38,7 @@ This guide walks you through setting up a local development environment for Noti
|----------------|-----------------|-----------------------------------------|--------------------|
| Rust | stable | [rustup.rs](https://rustup.rs) | Smart contracts |
| `wasm32-unknown-unknown` | — | `rustup target add wasm32-unknown-unknown` | Soroban contracts |
| Stellar CLI | latest | `cargo install stellar-cli` | Contract build/deploy |
| Stellar CLI | latest | `cargo install --locked stellar-cli --features opt` | Contract build/deploy |
| Node.js | **18** (dashboard), **20** (listener) | [nodejs.org](https://nodejs.org) or `nvm` | Listener, Dashboard |
| npm | comes with Node | — | Package management |
| Git | — | Your package manager or [git-scm.com](https://git-scm.com) | Version control |
Expand Down Expand Up @@ -94,7 +92,6 @@ rustc --version && cargo --version && stellar --version
## 2. Clone the Repository

```bash
git clone https://github.com/CollinsC1O/Notify-Chain.git
git clone https://github.com/Core-Foundry/Notify-Chain.git
cd Notify-Chain
```
Expand All @@ -104,7 +101,6 @@ If you plan to contribute, fork the repository first, then clone your fork:
```bash
git clone https://github.com/YOUR-USERNAME/Notify-Chain.git
cd Notify-Chain
git remote add upstream https://github.com/CollinsC1O/Notify-Chain.git
git remote add upstream https://github.com/Core-Foundry/Notify-Chain.git
```

Expand Down Expand Up @@ -786,7 +782,7 @@ cd frontend && npm install

### Still Stuck?

1. Search [open issues](https://github.com/CollinsC1O/Notify-Chain/issues) — your problem may already be reported.
1. Search [open issues](https://github.com/Core-Foundry/Notify-Chain/issues) — your problem may already be reported.
1. Search [open issues](https://github.com/Core-Foundry/Notify-Chain/issues) — your problem may already be reported.
2. Read the detailed [Troubleshooting Guide](TROUBLESHOOTING.md).
3. Open a new issue with:
Expand Down
12 changes: 6 additions & 6 deletions CREATE_PR_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You now have a complete, working notification template preview feature ready to

1. **Go to your fork on GitHub:**
```
https://github.com/coderolisa/Notify-Chain
https://github.com/Core-Foundry/Notify-Chain
```

2. **You should see a yellow banner** saying:
Expand Down Expand Up @@ -122,7 +122,7 @@ gh pr create \

Click this link (replace YOUR_USERNAME):
```
https://github.com/coderolisa/Notify-Chain/pull/new/feature/notification-template-preview
https://github.com/Core-Foundry/Notify-Chain/pull/new/feature/notification-template-preview
```

## 📝 PR Checklist
Expand Down Expand Up @@ -279,15 +279,15 @@ If you encounter any issues:

### Branch Info
```
Repository: https://github.com/coderolisa/Notify-Chain
Repository: https://github.com/Core-Foundry/Notify-Chain
Branch: feature/notification-template-preview
Status: ✅ Ready for PR
```

### Key URLs
- Your Fork: `https://github.com/coderolisa/Notify-Chain`
- Create PR: `https://github.com/coderolisa/Notify-Chain/pull/new/feature/notification-template-preview`
- Branch: `https://github.com/coderolisa/Notify-Chain/tree/feature/notification-template-preview`
- Your Fork: `https://github.com/Core-Foundry/Notify-Chain`
- Create PR: `https://github.com/Core-Foundry/Notify-Chain/pull/new/feature/notification-template-preview`
- Branch: `https://github.com/Core-Foundry/Notify-Chain/tree/feature/notification-template-preview`

## ✨ You're All Set!

Expand Down
12 changes: 6 additions & 6 deletions DEPLOYMENT_PLAYBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ These variables are commonly exported during CLI deployment scripting:
- `DISPUTE_RESOLVER_ADDRESS`: The designated address authorized to resolve disputed tasks in `TaskBounty`.

### 2.2 Off-Chain Listener Configuration (`listener/.env`)
Once the contracts are deployed, their IDs must be registered in the listener's environment config [listener/.env.example](file:///workspaces/Notify-Chain/listener/.env.example):
Once the contracts are deployed, their IDs must be registered in the listener's environment config [listener/.env.example](listener/.env.example):
- `STELLAR_NETWORK`: Set to `testnet` or `public` (mainnet).
- `STELLAR_RPC_URL`: The Stellar RPC endpoint URL (e.g., `https://soroban-testnet.stellar.org:443`).
- `CONTRACT_ADDRESSES`: A JSON array specifying the contract addresses and events to subscribe to.
Expand All @@ -93,7 +93,7 @@ Once the contracts are deployed, their IDs must be registered in the listener's
```

### 2.3 Frontend Dashboard Configuration (`dashboard/.env`)
Provide the frontend dashboard [dashboard/.env.example](file:///workspaces/Notify-Chain/dashboard/.env.example) with details to query the listener:
Provide the frontend dashboard [dashboard/.env.example](dashboard/.env.example) with details to query the listener:
- `VITE_EVENTS_API_URL`: HTTP URL of the listener event feed (e.g., `http://localhost:8787/api/events`).
- `VITE_STELLAR_NETWORK`: Network context (`TESTNET` or `PUBLIC`).

Expand All @@ -102,8 +102,8 @@ Provide the frontend dashboard [dashboard/.env.example](file:///workspaces/Notif
## 3. Step-by-Step Deployment Examples

NotifyChain contains two primary smart contracts that must be compiled and deployed:
1. `AutoShare` - Subscription and group management contract located in [contract/contracts/hello-world](file:///workspaces/Notify-Chain/contract/contracts/hello-world).
2. `TaskBounty` - Decentralized task and reward board contract located in [Documents/Task Bounty](file:///workspaces/Notify-Chain/Documents/Task%20Bounty).
1. `AutoShare` - Subscription and group management contract located in [contract/contracts/hello-world](contract/contracts/hello-world).
2. `TaskBounty` - Decentralized task and reward board contract located in [Documents/Task Bounty](Documents/Task%20Bounty).

---

Expand Down Expand Up @@ -142,7 +142,7 @@ export AUTOSHARE_CONTRACT_ID=<returned-contract-id>
```

#### Step A.4: Initialize the Contract
The `AutoShare` contract requires initializing the administrator identity before it can accept groups and payments. Call the [initialize_admin](file:///workspaces/Notify-Chain/contract/contracts/hello-world/src/lib.rs#L38) function:
The `AutoShare` contract requires initializing the administrator identity before it can accept groups and payments. Call the [initialize_admin](contract/contracts/hello-world/src/lib.rs#L38) function:
```bash
stellar contract invoke \
--id $AUTOSHARE_CONTRACT_ID \
Expand Down Expand Up @@ -186,7 +186,7 @@ export TASKBOUNTY_CONTRACT_ID=<returned-contract-id>
```

#### Step B.4: Initialize the Contract
The `TaskBounty` contract requires setting up the admin address and a dispute resolver. Call the [initialize](file:///workspaces/Notify-Chain/Documents/Task%20Bounty/src/lib.rs#L38) function:
The `TaskBounty` contract requires setting up the admin address and a dispute resolver. Call the [initialize](Documents/Task%20Bounty/src/lib.rs#L38) function:
```bash
stellar contract invoke \
--id $TASKBOUNTY_CONTRACT_ID \
Expand Down
Loading
Loading