Skip to content

igaurav-dev/educasm-backend

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Donate us Support us Follow us on Twitter

AI Learning Platform API

A NestJS-based backend service that provides AI-powered learning content and interactive questions.

Setup Instructions

Prerequisites

  • Node.js (v16 or higher)
  • npm (v7 or higher)
  • A valid OpenAI API key
  • A valid Gemini API key

Environment Variables

Create a .env file in the root directory with the following variables:

OPENAI_API_KEY=your_openai_api_key
GEMINI_API_KEY=your_gemini_api_key
GEMINI_ENGINE=your_gemini_engine
PORT=3000

Installation

# Install dependencies
npm install

# Start development server
npm run start:dev

# Start production server
npm run start:prod

API Documentation

1. Generate Playground Question

Generate an age-appropriate question based on specified topics and difficulty level.

Endpoint: POST /api/v1/ai/playground

Request Body:

{
    "topics": "JavaScript",
    "level": 2,
    "age": 25
}

Response:

{
    "text": "In modern JavaScript frameworks like React and Vue.js, how is 'undefined' increasingly being handled to prevent common errors related to missing data in components?",
    "options": [
        "Through the use of optional chaining and nullish coalescing operators for safer property access.",
        "By globally replacing all 'undefined' values with a default placeholder value using a build-time script.",
        "By throwing exceptions when 'undefined' values are encountered to force explicit handling.",
        "By automatically converting 'undefined' values to empty strings during component rendering."
    ],
    "correctAnswer": 0,
    "explanation": {
        "correct": "Optional chaining and nullish coalescing allow safer access to nested properties, preventing errors.",
        "key_point": "Safer property access."
    },
    "difficulty": 2,
    "topic": "JavaScript",
    "subtopic": "Undefined Handling",
    "questionType": "Conceptual",
    "ageGroup": "25"
}

2. Explore Content

Generate exploratory content with related topics and follow-up questions.

Endpoint: POST /api/v1/ai/explore

Request Body:

{
    "query": "What is the Internet?",
    "age": 25
}

Response:

{
    "text": "The Internet is basically a massive network connecting billions of devices globally...",
    "topics": [
        {
            "topic": "TCP/IP protocol",
            "type": "prerequisite",
            "reason": "Communication basis"
        },
        // ... more topics
    ],
    "questions": [
        {
            "question": "How does the Internet physically exist under the ocean floor?",
            "type": "curiosity",
            "context": "Physicality"
        },
        // ... more questions
    ]
}

Rate Limiting

The API implements the following rate limits per IP address:

  • 15 requests per minute
  • 250 requests per hour
  • 500 requests per day

Error Handling

The API returns standard HTTP status codes:

  • 200: Success
  • 400: Bad Request
  • 429: Too Many Requests
  • 500: Internal Server Error

License

This project is licensed under the MIT License - see the LICENSE file for details.

Description

Nest framework TypeScript starter repository.

Project setup

$ npm install

Compile and run the project

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Run tests

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Deployment

When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.

If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:

$ npm install -g mau
$ mau deploy

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

Resources

Check out a few resources that may come in handy when working with NestJS:

  • Visit the NestJS Documentation to learn more about the framework.
  • For questions and support, please visit our Discord channel.
  • To dive deeper and get more hands-on experience, check out our official video courses.
  • Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
  • Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
  • Need help with your project (part-time to full-time)? Check out our official enterprise support.
  • To stay in the loop and get updates, follow us on X and LinkedIn.
  • Looking for a job, or have a job to offer? Check out our official Jobs board.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors