How skill-exchange-2025/skill-exchange-back works
Project type and purpose
• This is a backend service written in TypeScript using the NestJS framework. Its purpose is to power a “Skill Exchange” marketplace: handling user authentication/authorization, user/profile management, course/lesson listings and payments, real‑time messaging, and file uploads.
High‑level architectural overview
• Monolithic NestJS application, structured into feature modules.
• Exposes HTTP/REST endpoints for all resource operations.
• Exposes WebSocket gateway for real‑time messaging.
• Persists data in MongoDB via Mongoose schemas.
• Integrates with external services: Stripe (payments), Google Meet (video lessons), OTP service, local file storage.
Main components
A. Clients
• Web/Mobile frontends (HTTP REST & WebSocket)
B. NestJS App (Docker container)
1. AuthModule
• Controllers: /auth, /permission‑groups
• Services: AuthService, PermissionGroupsService
• Guards & Decorators: JWT auth, role & permission checks
• Schemas: OTP, PermissionGroup
2. UsersModule
• Controllers: /users
• Services: UsersService
• Schemas: User, UserSkill, DesiredSkill
3. ProfileModule
• Controllers: /profile
• Services: ProfileService
• Schemas: Profile
4. MarketplaceModule
• Controllers: /marketplace, /lessons, /payment, /stripe-webhook, /webhook
• Services: MarketplaceService, LessonsService, PaymentService, NotificationService, GoogleMeetService
• Schemas: Listing, Lesson, Review, Transaction, Payment, Wallet
5. MessagingModule
• Controller/Gateway: MessagingController, MessagingGateway
• Service: MessagingService
• Schemas: Channel, Message
6. FileUploadModule
• Handles file uploads (multipart) and persists files under /uploads
7. Core
• app.controller, app.service, app.module, main.ts
• Global middleware or interceptors (if any)
C. Infrastructure
• MongoDB (Docker‑compose service)
• Local filesystem (uploads volume)
• External APIs:
– Stripe (payment processing, webhooks)
– Google Meet (lesson video conferencing)
– OTP provider (SMS/email)
D. CI/CD & Deployment
• GitHub Actions (.github/workflows/deploy.yml)
• Dockerfile & docker‑compose.yml (build & orchestrate NestJS + MongoDB)
• Test harness: Jest (unit & e2e), custom test-scripts for API smoke tests
Key relationships & data flows
• Client → HTTP REST → NestJS Controllers → Services → MongoDB
• Client → WebSocket → MessagingGateway → MessagingService → MongoDB
• AuthController issues JWT tokens, other modules use JWT guard for auth
• MarketplaceService calls Stripe API for payments and webhooks
• LessonsService calls GoogleMeetService for meeting links
• FileUploadModule writes to local /uploads folder (mounted volume)
• CI/CD runs on push: builds Docker image, runs tests, deploys
Architectural patterns & principles
• Modularization: feature modules encapsulate domain logic
• Controller‑Service‑Repository (via Mongoose) pattern
• Dependency Injection (Nest core)
• Guard‐Decorator pattern for auth, roles, permissions
• Single container monolith, easily split into microservices later if needed