Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/assessment-service/1_about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
sidebar_position: 1
---

# About

The Assessment Service is a robust, scalable NestJS microservice designed for managing the entire lifecycle of tests and assessments. It supports dynamic rule-based tests, subjective questions, and features an enterprise-grade plugin architecture.

Built with NestJS, the service offers a high-performance, modular architecture that supports multi-tenancy, allowing different organizations and tenants to manage their assessments in isolation.

Key capabilities of the Assessment service include:
- **Comprehensive Test Management**: Create, update, and manage exams with diverse structures, sections, and various question types (MCQ, Multiple Answer, Subjective, Essay, etc.).
- **Dynamic Rule-Based Tests**: Dynamic question selection based on customizable rules and criteria, facilitating varied and adaptive assessments.
- **Enterprise Plugin Architecture**: Features Joomla-like triggers for extensible functionality out-of-the-box, supporting both fast internal plugins and webhook-based external services for advanced integration.
- **Robust Scoring & Review Systems**: Automated and manual scoring utilizing varied grading strategies, alongside comprehensive manual rubric-supported review systems for subjective submissions.
- **Data Isolation**: Ensures secure and isolated data for multiple tenants and organizations.
30 changes: 30 additions & 0 deletions docs/assessment-service/2_features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sidebar_position: 2
---

# Features

### Core Assessment Features
- ✅ **Test Management** - Create, update, and manage tests with various types.
- ✅ **Question Types** - Support for MCQ, Multiple Answer, True/False, Fill-in-Blank, Matching, Subjective, and Essay.
- ✅ **Rule-Based Tests** - Dynamic question selection based on predefined rules and criteria (Category, Difficulty, Type, Marks).
- ✅ **Test Sections** - Organize tests into logical, ordered sections.
- ✅ **Attempt Management** - Track user attempts comprehensively with detailed analytics and attempt status checks.
- ✅ **Review System** - Manual review logic for subjective and essay questions with configurable rubric support.
- ✅ **Scoring & Grading** - Automatic and manual scoring with flexible grading strategies (`first_attempt`, `last_attempt`, `average`, `highest`).

### Enterprise Features
- ✅ **Multi-tenancy** - Complete tenant and organization data isolation enforced across all endpoints.
- ✅ **Plugin System** - Powerful event-driven architecture using Joomla-like triggers for extensible functionality.
- ✅ **Database Migrations** - Custom version-controlled schema management system handling migrations, dependencies, and rollbacks.
- ✅ **Caching** - Built-in Redis-based caching to enhance retrieval performance.
- ✅ **API Documentation** - Comprehensive Swagger/OpenAPI documentation.
- ✅ **Health Checks** - Built-in service health and structural monitoring.
- ✅ **Rate Limiting** - Integrated endpoint throttling and DDoS protection (e.g., 100 requests per minute).

### Plugin Architecture Highlights
The plugin system supports progressive adoption of decoupled architectures:
- ✅ **Internal Plugins** - Fast, in-process event handling for standard functionality.
- ✅ **External Services** - Webhook-based external integrations for a distributed ecosystem.
- ✅ **Hybrid Approach** - Simultaneous use of both systems for transitioning scalability.
- ✅ **Event-Driven** - Loose coupling through standardized events (`test.created`, `attempt.submitted`, `user.registered`, etc.).
71 changes: 71 additions & 0 deletions docs/assessment-service/3_getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
sidebar_position: 3
---

# Getting Started

Follow these instructions to set up and run the Assessment microservice locally.

### Prerequisites

Before you begin, ensure you have the following installed:

- **Node.js**: v16 or higher
- **PostgreSQL**: v12 or higher
- **Redis**: v6 or higher
- **Docker**: (Optional, for containerized setup)

### Local Setup

1. **Clone the repository**

```sh
git clone https://github.com/tekdi/shiksha-assessment-service.git
```

2. **Navigate to the application directory**:
```bash
cd shiksha-assessment-service
```

3. **Environment Configuration**:
Copy the example environment file and update the variables:

```bash
cp env.example .env
```

_Edit `.env` with your local database and redis credentials._

4. **Install Dependencies**:

```bash
npm install
```

5. **Start the Application**:

```bash
# Development mode with hot-reload
npm run start:dev

# Production build
npm run build
npm run start:prod
```

### Docker Setup

For a quick setup using Docker Compose:

1. **Build and start all services**:

```bash
docker-compose up --build -d
```

This will start the Assessment service, PostgreSQL, and Redis in containers.

2. **Verify the installation**:
The service should be accessible at `http://localhost:3000` (or the port specified in your `.env`).
Access the Swagger documentation at `http://localhost:3000/api-docs`.
27 changes: 27 additions & 0 deletions docs/assessment-service/4_tech-stack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
sidebar_position: 4
---

# Tech Stack

The Assessment service is built using a modern, scalable technology stack designed for reliability, performance, and modularity.

### Backend Framework
- **NestJS**: A progressive Node.js framework for building efficient and scalable server-side applications.
- **TypeScript**: Used throughout the project for static typing, robust interfaces, and enhanced developer productivity.

### Database & Storage
- **PostgreSQL**: The primary relational database for storing tests, questions, user attempts, and reviews.
- **TypeORM**: Object-Relational Mapper (ORM) used for database interactions and rigorous migration management.
- **Redis**: Used for high-performance caching of tests and robust attempt tracking.

### Security & Validations
- **Class-Validator**: Integrated with NestJS DTOs for strict input validation before business logic processing.
- **Multi-tenancy Headers**: Strict enforcement of `tenantId` and `organisationId` validation at controller levels.

### Documentation & API
- **Swagger/OpenAPI**: Automated interactive API documentation integrated closely with NestJS.

### DevOps & Infrastructure
- **Docker**: Containerization for consistent development and deployment environments.
- **Docker Compose**: Orchestration for local multi-service environments (app, database, cache).
38 changes: 38 additions & 0 deletions docs/assessment-service/5_architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
sidebar_position: 5
---

# Architecture

The Assessment service follows a clean, modular architecture provided by NestJS, emphasizing separation of concerns, scalability, and plugin extensibility.

### Module Overview

The application is structured into several core modules:

- **Test Module**: Manages test definitions, constraints, and test-level lifecycle (draft to publish).
- **Question Module**: Handles versatile question type schemas, mappings, and criteria.
- **Attempt Module**: Central component responsible for user progress tracking, attempting test evaluation logic, and score grading.
- **Review Module**: Segregated module orchestrating manual rubric-based evaluations for subjective interactions.
- **Plugin Module**: Pluggable extension handling internal and external event-driven behaviors.

### High-Level Flow

```mermaid
graph TD
User((User)) --> API[API Gateway / NestJS App]
API --> Validators[DTO Validators]
Validators --> Controllers[Controllers]
Controllers --> Services[Services]
Services --> EventEmitter[Plugin Triggers]
Services --> Entities[TypeORM Entities]
Entities --> DB[(PostgreSQL)]
Services --> Cache[Redis Cache]
```

### Key Architectural Patterns
1. **Repository Pattern**: Abstracting PostgreSQL interactions through TypeORM repositories to cleanly decouple query logic.
2. **Loosely Coupled Plugin System**: Incorporating internal in-process event handlers and external webhooks (Phase 2) to offload logic without touching core operations.
3. **Multi-tenancy Implicit Control**: Mandated header extraction intercepts, meaning tenants are never cross-polluted in data retrieval scenarios.
4. **Exception Filters**: Centralized HTTP error handling, catching `VALIDATION_ERROR`, `CONFLICT`, and parsing DB exceptions into user-friendly standardized responses.
5. **DTOs (Data Transfer Objects)**: Strictly defining diverse input schemas for varying question formats and answer payloads.
Loading