Skip to content

rinafcode/teachLink_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

328 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 TeachLink Backend

CI Coverage Branch Protection PRs Welcome

Replace teachlink/backend in the badge URLs above with your actual org/repo slug 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.


πŸ” CI / Testing

Every pull request and every push to main / develop runs an automated pipeline defined in .github/workflows/ci.yml.

Pipeline stages

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)

Running checks locally

# 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:e2e

Coverage thresholds

Configured 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.


πŸ”’ Branch Protection

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.


πŸ“ Project Structure

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

πŸ”§ Project Overview

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

πŸ“Š Architecture

βš™οΈ Tech Stack

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

πŸš€ Deployment

Prerequisites

  • Node.js 18+
  • PostgreSQL
  • Redis
  • Docker (optional)

Steps

  1. Set up .env
  2. Run npm i
  3. Start: npm run start:dev or Docker Compose
  4. Swagger: http://localhost:3000/api

🀝 Contribution

🀝 Contributing to TeachLink

πŸ›  Development Workflow

  1. Fork the repo and clone locally.
  2. Set up your environment using .env.example
  3. Use conventional commits.
  4. Run tests locally before PR.
  5. Open a PR with title like: ✨ Add: Tutor Booking API

πŸ§ͺ PR Must Include:

  • Linked issue (Closes #issue_number)
  • Clear title and description
  • Screenshots (if UI)
  • Tests (if backend)

πŸ“¬ Join the Community

πŸ“ Folder Structure

/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


πŸ›  Setup Instructions

  1. 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

About

Backend: Teachlink is a platform for technocrat where knowlege, skills, ideas, and information that can bring about development and improvement can be shared, dissected, you can also earn from it.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors