Skip to content

SkillTrade: Microservice-based platform for skill exchange & community. Built with Node.js, TypeScript, Next.js, Docker, K8s, NATS & Stripe.

Notifications You must be signed in to change notification settings

WhisperNet/SkillTrade

Repository files navigation

SkillTrade - Peer-to-Peer Skill Exchange Platform

image

SkillTrade is a comprehensive microservices-based platform that enables users to exchange skills and knowledge through structured learning sessions. The platform facilitates peer-to-peer learning where users can both teach their expertise and learn new skills from others in the community.

πŸ“‹ Table of Contents

πŸ—οΈ Project Architecture

Microservices Overview

SkillTrade follows a microservices architecture with 5 core services communicating through event-driven patterns:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  skilltrade-    β”‚    β”‚  skilltrade-    β”‚    β”‚  skilltrade-    β”‚
β”‚     client      β”‚    β”‚     auth        β”‚    β”‚   community     β”‚
β”‚   (Next.js)     β”‚    β”‚  (Node.js/TS)   β”‚    β”‚  (Node.js/TS)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   NATS Event    β”‚
                    β”‚     Streaming   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                       β”‚                       β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  skilltrade-    β”‚    β”‚  skilltrade-    β”‚    β”‚     shared      β”‚
β”‚  connection     β”‚    β”‚   payments      β”‚    β”‚   library       β”‚
β”‚  (Node.js/TS)   β”‚    β”‚  (Node.js/TS)   β”‚    β”‚  (TypeScript)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Infrastructure

  • Container Orchestration: Kubernetes with Skaffold for local development
  • Ingress Controller: NGINX for routing requests to appropriate services
  • Message Streaming: NATS Streaming Server for event-driven communication
  • Database: MongoDB (individual instances per service)
  • Development Workflow: Skaffold with hot-reload capabilities

πŸš€ Core Features

1. User Authentication & Profiles

  • User Registration/Login: Secure authentication with JWT tokens
  • Profile Management: Comprehensive user profiles with:
    • Personal information (name, email, profile picture)
    • Professional details (occupation: professional/student/freelancer/entrepreneur)
    • Availability schedule (days of the week)
    • Skills to teach and learn
    • Session statistics and premium status

2. Community & Social Features

  • Skill Exchange Posts: Users create posts advertising:
    • Skills they want to teach
    • Skills they want to learn
    • Availability windows
    • Personal introduction and background
  • Social Interactions:
    • Like posts from other users
    • Send connection requests
    • Browse and search community posts
    • Filter by skills, availability, and premium status

3. Connection & Session Management

  • Connection Workflow:
    • Send connection requests through posts
    • Accept/reject incoming requests
    • Automatic session creation upon acceptance
  • Session Features:
    • Bidirectional teaching (both users teach and learn)
    • Session scheduling and management
    • Session completion tracking
    • Mutual review system

4. Premium Learning Experience

  • Video Conferencing: Real-time video calls using Agora SDK
  • Interactive Whiteboard: Collaborative whiteboard for visual learning
  • Real-time Chat: HTTP-based chat system during sessions

5. Payment Processing

  • Stripe Integration: Secure payment processing for premium features
  • Premium Subscriptions: Enhanced features for paying users
  • Payment Event Handling: Automatic premium status updates

6. Review & Rating System

  • Mutual Reviews: Both participants can review each other
  • Rating Analytics: Visual charts showing user performance
  • Teaching Statistics: Track sessions taught and overall ratings

πŸ› οΈ Technology Stack

Frontend (skilltrade-client)

  • Framework: Next.js 15.3.3 with React 19
  • Styling: Tailwind CSS with custom animations
  • UI Components:
    • Radix UI primitives for accessibility
    • Custom component library with shadcn/ui
    • Lucide React icons
  • Forms: React Hook Form with Zod validation
  • Charts: Recharts for analytics visualization
  • Video/Audio: Agora RTC SDK for real-time communication
  • Whiteboard: @netless/fastboard for collaborative drawing
  • Payments: Stripe SDK for payment processing

Backend Services (Node.js/TypeScript)

  • Runtime: Node.js with TypeScript
  • Framework: Express.js for REST APIs
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT tokens with cookie sessions
  • Validation: Express-validator for request validation
  • Testing: Jest with MongoDB Memory Server
  • Development: ts-node-dev for hot reloading

Shared Library (@cse-350/shared-library)

  • Common Types: TypeScript interfaces and types
  • Event Definitions: NATS event schemas and handlers
  • Middleware: Authentication, validation, and error handling
  • Error Classes: Standardized error responses

Infrastructure & DevOps

  • Containerization: Docker for all services
  • Orchestration: Kubernetes with custom manifests
  • Development: Skaffold for local development workflow
  • Message Broker: NATS Streaming Server
  • Ingress: NGINX Ingress Controller
  • Domain: skilltrade.dev (local development)

πŸ”„ Service Communication

Event-Driven Architecture

Services communicate asynchronously through NATS Streaming with these key events:

  1. Payment Events:

    PaymentCreated β†’ Updates user premium status across services
  2. Connection Events:

    ConnectionRequested β†’ Notifies connection service
    ConnectionAccepted β†’ Creates session and updates user stats
    ConnectionRejected β†’ Cleans up connection requests
    ConnectionCancelled β†’ Handles cancellation logic
  3. Review Events:

    ReviewCreated β†’ Updates user ratings and session completion
  4. Post Events:

    PostDeleted β†’ Cleanup across dependent services

API Gateway Pattern

NGINX Ingress routes requests based on path patterns:

  • /api/users/* β†’ Authentication Service (Port 3000)
  • /api/community/* β†’ Community Service (Port 3000)
  • /api/payment/* β†’ Payments Service (Port 3000)
  • /api/connections/* β†’ Connection Service (Port 3000)
  • /* β†’ Client Application (Port 3000)

πŸ—„οΈ Data Models

User Model (Authentication Service)

interface User {
  email: string
  password: string (hashed)
  profilePicture: string
  fullName: string
  description: string
  occupation: "professional" | "student" | "freelancer" | "entrepreneur" | "other"
  availability: Array<DayOfWeek>
  gender: "male" | "female" | "other"
  sessionsTaught: number
  isPremium: boolean
}

Post Model (Community Service)

interface Post {
  authorId: string
  authorName: string
  authorProfilePicture: string
  isPremium: boolean
  title: string
  content: string
  availability: Array<DayOfWeek>
  likes: string[]
  connections: string[]
  connectionAccepted: string[]
  toTeach: string[]
  toLearn: string[]
}

Session Model (Connection Service)

interface Session {
  sessionTakerOneId: string
  sessionTakerTwoId: string
  sessionTakerOneName: string
  sessionTakerTwoName: string
  sessionTakerOneProfilePicture: string
  sessionTakerTwoProfilePicture: string
  isEnded: boolean
  isReviewedByTakerOne: boolean
  isReviewedByTakerTwo: boolean
  toTeach: string[]
  toLearn: string[]
  sessionTakerOneTeaching: number
  sessionTakerTwoTeaching: number
  nextSessionBeginsAt: Date
}

Payment Model (Payments Service)

interface Payment {
  userId: string
  stripeId: string
  // Additional payment-related fields
}

🚦 Getting Started

πŸš€ How to Run Locally

Prerequisites

Before running SkillTrade locally, ensure you have the following installed:

  • Docker Desktop:Windows & MacOS (with Kubernetes enabled) OR

  • Docker:Linux (with minikube installed).

  • kubectl - Kubernetes command-line tool

  • Skaffold - For development workflow automation

  • Node.js (v16 or higher)

  • npm or yarn

Local Development Setup

1. Clone the Repository

git clone https://github.com/Rezaul-2020331029/SkillTrade.git

cd SkillTrade

2. Enable Kubernetes in Docker Desktop

  • Open Docker Desktop
  • Go to Settings β†’ Kubernetes
  • Check "Enable Kubernetes"
  • Click "Apply & Restart"

3. Install Skaffold

# For macOS
brew install skaffold

# For Linux
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
sudo install skaffold /usr/local/bin/

# For Windows
choco install skaffold

4. Setup Ingress Controller (NGINX)

# For Minikube users
minikube addons enable ingress

# For other users
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml

5. Configure Local Domain

Add the following to your /etc/hosts file (or C:\Windows\System32\drivers\etc\hosts on Windows):

#For Docker Dekstop
127.0.0.1 skilltrade.dev

For minikube we first need to find the minikube IP and add it to the config file by:

minikube ip

6. Set Environment Variables

Create the required Kubernetes secrets:

# JWT Secret
kubectl create secret generic jwt-secret --from-literal=JWT_KEY=your_jwt_secret_key

# Stripe Secret (for payments)
kubectl create secret generic stripe-secret --from-literal=STRIPE_KEY=your_stripe_secret_key

7. Start the Development Environment

# Run all microservices with hot reload
skaffold dev

This will:

  • Build all Docker images
  • Deploy all microservices to Kubernetes
  • Set up port forwarding
  • Enable hot reload for development

πŸ“± Access the Application

Once everything is running:

πŸ› οΈ Development Commands

Individual Service Development

# Run specific service locally (outside Kubernetes)
cd skilltrade-auth
npm install
npm run dev

# Run tests
npm test

# Build shared library
cd shared
npm run build
npm publish  # If you have publish permissions

Kubernetes Management

# View all pods
kubectl get pods

# View services
kubectl get services

# View logs for a specific service
kubectl logs -f deployment/skilltrade-auth-depl

# Delete all resources
kubectl delete -f infra/k8s/

Database Access

Each microservice has its own MongoDB instance:

# Port forward to access databases
kubectl port-forward service/skilltrade-auth-mongodb-srv 27017:27017
kubectl port-forward service/skilltrade-community-mongodb-srv 27018:27017
kubectl port-forward service/skilltrade-connection-mongodb-srv 27019:27017
kubectl port-forward service/skilltrade-payments-mongodb-srv 27020:27017

πŸ› Troubleshooting

Common Issues:

  1. Ingress not working: Ensure NGINX ingress controller is installed and running. Sometimes the NGNIX deployment can take upto 5mins to be ready
  2. Services not starting: Check if all secrets are created properly
  3. Database connection issues: Verify MongoDB services are running
  4. Hot reload not working: Restart skaffold with skaffold dev --no-prune=false --cache-artifacts=false
  5. Unable to access the site in the browser :The browser may prevent accessing the site as the SSL certificate is a mock. To bypass this click on the browser window and type thisisunsafe
  6. Unable to deploy the application with skaffold: Make sure minikube is running by minikube start --driver=docker if you're using minikube instaed of docker dekstop

Useful Debug Commands:

# Check ingress
kubectl get ingress

# Describe problematic pods
kubectl describe pod <pod-name>

# Check events
kubectl get events --sort-by=.metadata.creationTimestamp

πŸ§ͺ Testing

Each service includes comprehensive test suites:

# Run all tests across services
npm run test:all

# Run tests for specific service
cd skilltrade-auth
npm test

# Run tests in watch mode
npm test -- --watch

Tests include:

  • Unit tests for business logic
  • Integration tests for API endpoints
  • MongoDB Memory Server for database testing
  • Supertest for HTTP testing

πŸ”’ Security Features

  • Authentication: JWT-based stateless authentication
  • Authorization: Route-level protection with middleware
  • Password Security: bcrypt hashing with salt rounds
  • Input Validation: Express-validator for request sanitization
  • CORS: Configured for secure cross-origin requests
  • Environment Isolation: Containerized services with network policies

πŸ“ˆ Scalability Considerations

  • Horizontal Scaling: Each service can be scaled independently
  • Database Separation: Each service has its own MongoDB instance
  • Event-driven Design: Loose coupling enables independent deployments
  • Caching Strategy: Ready for Redis integration for session management
  • Load Balancing: NGINX ingress provides load balancing capabilities

πŸ“ž Support

If you need help or have questions, please open an issue or contact us at ridowan.cse@gmail.com.

About

SkillTrade: Microservice-based platform for skill exchange & community. Built with Node.js, TypeScript, Next.js, Docker, K8s, NATS & Stripe.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages