Skip to content

icodeBisola/chainVerse-backend

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

543 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


πŸš€ ChainVerse Backend (NestJS)

A scalable, modular, and production-grade backend system for ChainVerse Academy, built with NestJS and designed using clean architecture principles, domain separation, and enterprise-ready patterns.


πŸ“Œ Overview

This project represents a full architectural migration from Express.js to NestJS, aimed at transforming a flexible but loosely structured codebase into a highly maintainable, testable, and scalable system.

The backend is designed to support a modern learning platform with features such as:

  • User authentication & role management
  • Course creation and enrollment
  • Certification and achievements
  • Gamification systems
  • Financial aid workflows
  • Analytics and reporting
  • Notifications and communication systems

🎯 Why This Migration Matters

Moving to NestJS enables:

  • Clear modular boundaries β†’ easier to scale teams and features
  • Dependency Injection (DI) β†’ better testability and loose coupling
  • Consistent architecture β†’ predictable code organization
  • Built-in best practices β†’ guards, interceptors, pipes, etc.
  • Future microservice readiness

πŸ— Tech Stack

Layer Technology Purpose
Framework NestJS Backend architecture
Language TypeScript Type safety & maintainability
Authentication JWT (Access + Refresh Tokens) Secure user sessions
Validation class-validator / class-transformer DTO validation
ORM Prisma / TypeORM Database abstraction
Database PostgreSQL Relational data storage
Caching Redis (optional) Performance optimization
Documentation Swagger API exploration
Storage Local / S3-compatible File uploads

πŸ“ Project Architecture

The system follows a feature-based modular architecture, where each domain is isolated and self-contained.

src/
β”‚
β”œβ”€β”€ auth/                 # Authentication & JWT logic
β”œβ”€β”€ users/                # Core user management
β”œβ”€β”€ tutor-settings/       # Tutor-specific configurations
β”œβ”€β”€ student-settings/     # Student preferences
β”œβ”€β”€ admin-settings/       # Admin/moderator controls
β”œβ”€β”€ courses/              # Course creation & management
β”œβ”€β”€ reviews/              # Ratings & feedback
β”œβ”€β”€ leaderboard/          # Ranking system
β”œβ”€β”€ gamification/         # Points, badges, rewards
β”œβ”€β”€ certification/        # Certificates & verification
β”œβ”€β”€ financial-aid/        # Aid application system
β”œβ”€β”€ reports/              # Analytics & reporting
β”œβ”€β”€ notification/         # Email / in-app notifications
β”œβ”€β”€ organization/         # Institutional management
β”œβ”€β”€ subscription-plan/    # Plans & billing logic
β”œβ”€β”€ session/              # Session tracking
└── common/               # Shared utilities & helpers

πŸ“¦ Module Structure

Each module follows a consistent internal structure:

module/
β”œβ”€β”€ module.module.ts      # Module definition
β”œβ”€β”€ module.controller.ts  # Route handlers (thin layer)
β”œβ”€β”€ module.service.ts     # Business logic
β”œβ”€β”€ dto/                  # Data Transfer Objects (validation)
β”œβ”€β”€ entities/             # Database models / schemas
└── guards/               # Route protection logic

🧠 Architectural Principles

  • Separation of concerns (Controller vs Service vs Data)
  • Single Responsibility Principle
  • Domain-driven structure
  • Reusable shared utilities in common/

πŸ” Authentication & Authorization

The system uses JWT-based authentication with support for access and refresh tokens.

πŸ”‘ Authentication Flow

  1. User logs in β†’ receives:

    • Access Token (short-lived)
    • Refresh Token (long-lived)
  2. Access token is used for API requests

  3. Refresh token is used to issue new access tokens

πŸ›‘ Role-Based Access Control (RBAC)

Supported roles:

  • ADMIN
  • MODERATOR
  • TUTOR
  • STUDENT

πŸ”’ Guards

  • JwtAuthGuard β†’ validates authenticated users
  • RolesGuard β†’ enforces role-based permissions

πŸ“¦ Core Features Breakdown

πŸ‘€ Account & Identity

  • Multi-role authentication (Admin, Tutor, Student)
  • Profile management per role
  • Secure session handling

πŸ“š Course System

  • Course creation & categorization
  • Advanced filtering & search
  • Reviews, ratings, and feedback
  • Course analytics & reporting

πŸ† Gamification Engine

  • Points accumulation system
  • Leaderboards (ranking users)
  • Achievement badges
  • NFT-based rewards (extensible)

πŸŽ“ Certification System

  • Certificate generation
  • Download & verification
  • Social sharing capabilities
  • Controlled name-change request flow

πŸ’° Financial Aid

  • Student application workflow
  • Admin review system
  • Approval/rejection lifecycle

πŸ“Š Reporting & Analytics

  • Tutor performance insights
  • Student progress tracking
  • Course-level analytics

πŸ›Ž Platform Systems

  • Notifications (email/in-app ready)
  • FAQ & legal pages
  • Contact & messaging system
  • Organization management
  • Subscription plans
  • Abuse reporting & moderation

πŸ›  Installation & Setup

# Clone repository
git clone https://github.com/your-username/chainverse-backend.git

# Enter project directory
cd chainverse-backend

# Install dependencies
npm install

βš™οΈ Environment Configuration

Create a .env file in the root directory:

PORT=3000

DATABASE_URL=postgresql://user:password@localhost:5432/chainverse

JWT_SECRET=your_access_secret
JWT_REFRESH_SECRET=your_refresh_secret

πŸ’‘ Tip: Use strong secrets and never commit .env to version control.


▢️ Running the Application

# Development (watch mode)
npm run start:dev

# Build for production
npm run build

# Run production server
npm run start:prod

πŸ“„ API Documentation (Swagger)

After starting the server:

http://localhost:3000/api

This provides:

  • Interactive API testing
  • Request/response schemas
  • Authentication support

πŸ§ͺ Testing Strategy

# Unit tests
npm run test

# End-to-end tests
npm run test:e2e

βœ… Testing Philosophy

  • Services should be unit tested
  • Critical flows should have e2e coverage
  • Mock external dependencies where needed

🧩 Migration Philosophy

This migration was not just a rewriteβ€”it was a system redesign focused on:

  • Long-term maintainability
  • Predictable development patterns
  • Improved onboarding for new developers
  • Scalability toward microservices

πŸ“Œ Development Guidelines

To maintain consistency across the codebase:

  • βœ… Keep controllers thin (no business logic)
  • βœ… Place logic inside services
  • βœ… Use DTOs for all inputs
  • βœ… Validate all external data
  • βœ… Protect routes with guards
  • βœ… Document endpoints with Swagger decorators
  • βœ… Follow SOLID principles

πŸš€ Future Roadmap

Planned enhancements include:

  • Microservices architecture (gRPC / Redis / RMQ)
  • Real-time features (WebSockets)
  • Blockchain/NFT integrations
  • Payment gateway integration
  • CI/CD pipelines
  • Docker & container orchestration

🀝 Contributing

We welcome contributions! Follow these steps:

  1. Fork the repository
  2. Create a feature branch (feat/your-feature)
  3. Follow coding and architectural standards
  4. Add validation and documentation
  5. Submit a Pull Request

πŸ“Œ Contribution Requirements

  • Must follow NestJS best practices
  • Must include DTO validation
  • Must include Swagger docs
  • Must pass all tests

πŸ“œ License

MIT License


About

ChainVerse Academy is a decentralized Web3 education platform built on the Stellar blockchain. It offers crypto-based payments, NFT certifications, and DAO governance, allowing students to learn about multiple blockchain ecosystems, earn rewards, and own their learning assets through secure, low-cost transactions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 85.4%
  • PHP 11.3%
  • JavaScript 3.0%
  • Dockerfile 0.3%