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
30 changes: 30 additions & 0 deletions shiksha-website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# shiksha-website

This folder contains the full **Shiksha Co-Pilot** web application, including:

- **Frontend**: Angular-based user interface (`shiksha-frontend/` folder)
- **Backend**: Node.js/Express APIs (`shiksha-backend/` folder)
- **ARM Deployment Template**: Infrastructure as Code for Azure deployment (`shiksha-arm-template/` folder)

## Structure

```
shiksha-website/
├── shiksha-frontend/ # Angular frontend application
├── shiksha-backend/ # Node.js backend API server
├── shiksha-arm-template/ # Azure ARM deployment templates
└── README.md # This overview file
```

## Getting Started

Each folder has its own README with setup and running instructions:

- See `shiksha-frontend/README.md` for frontend setup
- See `shiksha-backend/README.md` for backend setup

## Prerequisites

- Angular CLI (frontend)
- Node.js, npm, MongoDB (backend)
- Azure account (for ARM deployment)
15 changes: 15 additions & 0 deletions shiksha-website/shiksha-arm-template/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachines_shikshana_production_name": {
"value": null
},
"disks_shikshana_production_OsDisk_1_8dbe5095835347e2abc249e683f0f8ac_externalid": {
"value": null
},
"networkInterfaces_shikshana_production246_z1_externalid": {
"value": null
}
}
}
111 changes: 111 additions & 0 deletions shiksha-website/shiksha-arm-template/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachines_shikshana_production_name": {
"defaultValue": "shikshana-production",
"type": "String"
},
"disks_shikshana_production_OsDisk_1_8dbe5095835347e2abc249e683f0f8ac_externalid": {
"defaultValue": "/subscriptions/3d015b01-4da7-481a-a0d9-60448622bf7d/resourceGroups/SHIKSHANA-RG/providers/Microsoft.Compute/disks/shikshana-production_OsDisk_1_8dbe5095835347e2abc249e683f0f8ac",
"type": "String"
},
"networkInterfaces_shikshana_production246_z1_externalid": {
"defaultValue": "/subscriptions/3d015b01-4da7-481a-a0d9-60448622bf7d/resourceGroups/Shikshana-RG/providers/Microsoft.Network/networkInterfaces/shikshana-production246_z1",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2024-11-01",
"name": "[parameters('virtualMachines_shikshana_production_name')]",
"location": "centralindia",
"tags": {
"env": "prod"
},
"zones": [
"1"
],
"identity": {
"type": "SystemAssigned"
},
"properties": {
"hardwareProfile": {
"vmSize": "Standard_B4ms"
},
"additionalCapabilities": {
"hibernationEnabled": false
},
"storageProfile": {
"imageReference": {
"publisher": "canonical",
"offer": "ubuntu-24_04-lts",
"sku": "server",
"version": "latest"
},
"osDisk": {
"osType": "Linux",
"name": "[concat(parameters('virtualMachines_shikshana_production_name'), '_OsDisk_1_8dbe5095835347e2abc249e683f0f8ac')]",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS",
"id": "[parameters('disks_shikshana_production_OsDisk_1_8dbe5095835347e2abc249e683f0f8ac_externalid')]"
},
"deleteOption": "Delete",
"diskSizeGB": 30
},
"dataDisks": [],
"diskControllerType": "SCSI"
},
"osProfile": {
"computerName": "[parameters('virtualMachines_shikshana_production_name')]",
"adminUsername": "azureuser",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "/home/azureuser/.ssh/authorized_keys",
"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDGN5/JiAPjI4ipml4nQRnnCX+tHkKtjPKAZ2pwq/issC4YuNZqGetZxw+1Qvj5ZKJkK7n3w4d3phyYal35/iuaY4rTuj7d8IQBcFnv8LtwfxIp1FFGyY5WatUASYyAMfSuPaxZiNlwJUfr5QBwDwpajnlrasjgUTMq6BZ51iieN+6vqLhdHSteR8y2vt2E0yLEcl1YKafSE0cjzP5C/mBeesGYgVKFB/IhzOl753y6Tyxl1WU31paHb6VFzCTgQ8X/7YlfSjcG5YYZJQsf/V4LyrgTJ9Q9fDCQWsPyteZMfIac5rkFx7RXGL0WJ2/cZcenelsj3FhqlYEhmyxgUH+e+zEQQbRbcRT95RvcfjTl4Y0nA+3crhgR569yvmsG1AJu2tTZYwobpLRzGr8xZIIR7F32SkjcPdXHdLngFPO7bD3l5xPNWJRbRPto7axfllDkddLWzbWkLrs+2bQpWXhFQ303/uQ1NnPHSBZ4egNRux16e77h2VsRgvTeZu46HYE= generated-by-azure"
}
]
},
"provisionVMAgent": true,
"patchSettings": {
"patchMode": "ImageDefault",
"assessmentMode": "ImageDefault"
}
},
"secrets": [],
"allowExtensionOperations": true,
"requireGuestProvisionSignal": true
},
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": true,
"vTpmEnabled": true
},
"securityType": "TrustedLaunch"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[parameters('networkInterfaces_shikshana_production246_z1_externalid')]",
"properties": {
"deleteOption": "Delete"
}
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
}
}
}
]
}
6 changes: 6 additions & 0 deletions shiksha-website/shiksha-backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ E2E_STORAGE_SECRET_KEY=your-storage-secret-key
E2E_STORAGE_URL=https://your-storage-url
E2E_STORAGE_BUCKET=your-storage-bucket-name

# Azure Storage
AZURE_STORAGE_CONTAINER_NAME=your-azure-storage-container-name
AZURE_STORAGE_ACCOUNT_NAME=your-azure-storage-account-name

# PIN secret
PIN_SECRET_KEY=your-pin-secret-key

Expand All @@ -29,6 +33,8 @@ VARIFORM_SMS_URL=your-sms-url
LLM_API_BASE_URL=your-llm-api-base-url
LLM_CHECKLIST_URL=your-checklist-url
LLM_EMBEDDING_URL=your-embedding-url
LLM_DURABLE_URL=your-durable-url
LLM_WORKFLOW_URL=your-workflow-url

# Application settings
SIMILARITY_THRESHOLD=0.98
Expand Down
131 changes: 122 additions & 9 deletions shiksha-website/shiksha-backend/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,131 @@
## SHIKSHANA BACKEND
# Shiksha Co-Pilot Backend

_The Node.js (Express + MongoDB) backend for the **Shiksha Co-Pilot** — a generative AI assistant that helps teachers with lesson planning, classroom activities, and transforming classroom experiences._

---

## Overview

This backend powers the [Shiksha Co-Pilot Angular Frontend] and acts as the bridge to the **Co-Pilot LLM APIs** developed by Microsoft Research India.

It handles:

- API endpoints consumed by the frontend
- User authentication and authorization
- Data aggregation and processing
- Communication with Co-Pilot LLM APIs
- MongoDB-based data storage and retrieval

---

## Project Structure

```
shiksha-backend/
├── aggregation/ # Logic to aggregate and process data
├── config/ # App and MongoDB configuration
├── controllers/ # Route controllers (handle business logic)
├── dao/ # Data Access Objects (MongoDB queries, abstractions)
├── helper/ # Utility functions and helper logic
├── managers/ # Business logic layer (orchestrates services and DAOs)
├── middlewares/ # Express middlewares (auth, logging, error handling)
├── migrations/ # MongoDB migration scripts
├── models/ # Mongoose models and schemas
├── public/ # Public static files
├── routes/ # API route definitions and route handlers
├── services/ # Integration with external services
├── uploads/ # File upload directory
├── validations/ # Payload validators
├── worker/ # Background workers
├── .env.example # Example environment variable configuration
├── .gitignore # Files and directories to ignore in Git
├── README.md # Project documentation
├── app.js # Express app initialization
├── package-lock.json # Auto-generated dependency lock file
├── package.json # Project metadata, scripts, dependencies
```
---

## Prerequisites

Ensure the following are installed on your system:

- [Node.js](https://nodejs.org/) (v18 or higher)
- [npm](https://www.npmjs.com/)
- [MongoDB](https://www.mongodb.com/) (local or cloud instance)

---

## Installation

This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).
Clone the repository and install dependencies:

```bash
cd shiksha-backend
npm install
```

---

### Environment Setup

Create a `.env` file in the root directory and populate it with the variables from .env.example, replacing the values with your own.

Before installing, [download and install Node.js](https://nodejs.org/en/download/).
Node.js 16.20.0
---

Installation steps -
### Running the Server

To start the development server with **auto-reloading**, use:

```bash
nodemon app.js
```
npm i
npm i -g nodemon
npm run start-dev

> **This uses [nodemon](https://www.npmjs.com/package/nodemon) for hot-reloading.**
> If you don't have it installed globally, run:

```bash
npm install -g nodemon
```

By default, the server runs at:
[http://localhost:8000]


## API Endpoints

The backend exposes several endpoints for interacting with the Shiksha Co-Pilot assistant. Below is an example of one such endpoint.

### POST `/api/chat/message`

Sends a user message to the Co-Pilot AI assistant and returns a generated response.

---

### **Example Usage**

**Request:**

```bash
curl -X POST http://localhost:8000/api/chat/message \
-H "Content-Type: application/json" \
-H "authorization: Bearer <your_jwt_token>" \
-d '{"message": "Give me 5 mcqs on solar system"}'
```

**Request Body:**

```json
{
"message": "Give me 5 mcqs on solar system"
}
```

**Response:**

```json
{
"message": "Response from copilot",
"data": "Here are five multiple-choice questions (MCQs) on the solar system suitable for middle school students:..."
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,30 @@ class ChapterAggregation {
}
}
},
{
$addFields: {
learning_outcomes: {
$cond: {
if: { $eq: [{ $size: "$learningOutcomes" }, 0] },
then: {
$reduce: {
input: "$topicsLearningOutcomes",
initialValue: [],
in: { $concatArrays: ["$$value", "$$this.learningOutcomes"] }
}
},
else: "$learningOutcomes"
}
}
}
},
{
$project:
{
_id: 0,
title: "$topics",
index_path: "$indexPath",
learning_outcomes: "$learningOutcomes"
learning_outcomes: 1
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ class MasterLessonAggregation {
}
}

async getLessonOutcomes(chapterId, filters = {}) {
async getLessonOutcomes(chapterId,templateIds, filters = {}) {
try {
let pipeline = [
{
$match: { chapterId: new ObjectId(chapterId), ...filters , isRegenerated : false },
$match: {
chapterId: new ObjectId(chapterId),
templateId: { $in: templateIds.map(id => new ObjectId(id)) },
...filters ,
isRegenerated : false
},
},

{
Expand Down Expand Up @@ -103,6 +108,17 @@ class MasterLessonAggregation {
{
$unwind: "$subjects",
},
{
$lookup: {
from: "lessonplantemplates",
localField: "templateId",
foreignField: "_id",
as: "template",
},
},
{
$unwind: "$template",
},
{
$addFields: {
videos: {
Expand Down
Loading
Loading