Replace
teachlink/backendin the badge URLs above with your actualorg/reposlug once the repository is on GitHub.
TeachLink is a decentralized platform built to enable technocrats to share, analyze, and monetize knowledge, skills, and ideas. This repository contains the backend API built with NestJS, TypeORM, and powered by Starknet and PostgreSQL, serving as the core of the TeachLink ecosystem.
This is the NestJS backend powering TeachLink β offering APIs, authentication, user management, notifications, and knowledge monetization features.
Every pull request and every push to main / develop runs an automated pipeline defined in .github/workflows/ci.yml.
| Stage | Tool | Fails on |
|---|---|---|
| Install | npm ci |
Dependency resolution error |
| Lint | ESLint | Any warning or error (--max-warnings 0) |
| Format | Prettier | Any file that would be reformatted |
| Type Check | tsc --noEmit |
Any TypeScript error |
| Build | NestJS CLI | Compilation failure |
| Unit Tests | Jest + ts-jest | Test failure or coverage below 70 % |
| E2E Tests | Jest + Supertest | Test failure (uses real Postgres + Redis) |
# Lint (auto-fix)
npm run lint
# Lint (CI-strict, no auto-fix)
npm run lint:ci
# Format check (no rewrite)
npm run format:check
# TypeScript type check only
npm run typecheck
# Unit tests with coverage report
npm run test:ci
# E2E tests (requires Postgres + Redis running locally)
npm run test:e2eConfigured in jest.config.js. The pipeline fails if any global metric falls below:
| Metric | Threshold |
|---|---|
| Statements | 70 % |
| Branches | 70 % |
| Functions | 70 % |
| Lines | 70 % |
Coverage HTML report is uploaded as a GitHub Actions artifact (coverage-report) on every run.
Both main and develop are protected. Direct pushes are disabled for everyone including admins.
| Rule | main |
develop |
|---|---|---|
| Required PR approvals | 2 (incl. code owner) | 1 |
| Dismiss stale reviews on new commit | β | β |
| Required status check | CI Passed |
CI Passed |
| Branch must be up to date | β | β |
| All conversations resolved | β | β |
| Squash merge only | β | β |
| Force push | β | β |
| Branch deletion | β | β |
Rules are defined in code in .github/workflows/branch-protection.yml and can be re-applied to any new repository by running the Bootstrap Branch Protection workflow manually from the Actions tab.
For the full contribution and review policy, see CONTRIBUTING.md.
src/
βββ modules/
β βββ auth/ # JWT, Google OAuth, Refresh tokens
β βββ users/ # Profile, roles, preferences
β βββ knowledge/ # Courses, content, categories
β βββ consulting/ # 1:1 sessions, scheduling, payments
β βββ messaging/ # Real-time chat, discussions
β βββ notifications/ # In-app/email alerts
β βββ analytics/ # Insights, course tracking
β βββ web3/ # Wallet connection, token gating
β βββ file-upload/ # Cloudinary upload, avatar, files
βββ config/ # TypeORM, validation, ENV configs
βββ common/ # DTOs, guards, interceptors, pipes
βββ main.ts # Entry point
TeachLink Backend provides secure and scalable APIs to power features such as:
- π§Ύ Post creation, editing, and markdown parsing
- π§ Topic discovery and categorization
- π₯ User account management with wallet login
- πΈ On-chain tipping and transaction logging
- ποΈ Gamified reputation and contribution tracking
- π Real-time notifications via WebSockets
- π Analytics and activity insights
- π§Ύ DAO integration for content moderation and governance
| Layer | Technology |
|---|---|
| Framework | NestJS |
| Database | PostgreSQL + TypeORM |
| Blockchain | Starknet + Starknet.js |
| Realtime | WebSockets (Gateway) |
| Queues/Async | BullMQ + Redis (optional) |
| File Uploads | Cloudinary |
| Config Mgmt | @nestjs/config |
| Testing | Jest + Supertest |
| Auth | JWT + Wallet Sign-In |
| Deployment | Docker, Railway, or Fly.io |
| File Upload | Cloudinary |
| Documentation | Swagger |
- Node.js 18+
- PostgreSQL
- Redis
- Docker (optional)
- Set up
.env - Run
npm i - Start:
npm run start:devor Docker Compose - Swagger:
http://localhost:3000/api
- Fork the repo and clone locally.
- Set up your environment using
.env.example - Use conventional commits.
- Run tests locally before PR.
- Open a PR with title like:
β¨ Add: Tutor Booking API
- Linked issue (
Closes #issue_number) - Clear title and description
- Screenshots (if UI)
- Tests (if backend)
/src /auth β Wallet-based login, JWT, refresh tokens /posts β CRUD for markdown posts /topics β Topic entities and filtering /users β Profiles, roles, reputation /tipping β On-chain tipping integrations /notifications β Real-time alerts (email, WebSocket) /analytics β Activity tracking & metrics /dao β Governance logic for post moderation /common β DTOs, decorators, interceptors, guards
yaml Copy Edit
- Clone the repository
git clone https://github.com/teachlink/backend.git
cd backend
Install dependencies
bash
Copy
Edit
npm install
Create .env file
env
Copy
Edit
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=yourpassword
DB_NAME=teachlink
JWT_SECRET=your_jwt_secret
JWT_EXPIRATION=3600
CLOUDINARY_API_KEY=your_key
CLOUDINARY_API_SECRET=your_secret
CLOUDINARY_CLOUD_NAME=your_name
Run PostgreSQL locally or connect to remote DB
Start the development server
bash
Copy
Edit
npm run start:dev
Database Migration (if applicable)
bash
Copy
Edit
npm run typeorm migration:run
π Key Development Milestones
β
PostgreSQL + TypeORM setup
β
JWT-based auth with Starknet wallet login
β
Post CRUD with markdown support
β
Topic categorization + filtering
β
Tipping logic integration
β
Real-time notifications setup
π§ Governance API for moderation
π§ Contribution analytics and scoring
π API Modules
Module Description
Auth Module Wallet login, JWT, refresh tokens
Post Module Markdown post management
User Module Profile management and reputation
Topic Module Knowledge categories & filtering
Tip Module Send/receive tips on-chain
Notif Module In-app + external notifications
DAO Module Voting and governance decisions
File Module Upload and serve media via Cloudinary
β
Contribution Guidelines
Fork the repo and create a feature branch
All PRs must link to a GitHub Issue (Close #5)
Follow NestJS best practices and clean code principles
Include unit tests for services/controllers
Join our Telegram Group for support
π§ͺ Testing
Run unit and integration tests:
bash
Copy
Edit
npm run test
π License
MIT Β© 2025 TeachLink DAO