/DocxEnhancer

A powerful AI-driven tool to enhance .docx MCQ documents. Automatically extract questions, add accurate answers, explanations, and references. Allows manual edits, prompt generation, and file downloads. Built with Next.js, Node.js, OpenAI API, and Express.

Primary LanguageTypeScript

πŸ“„ DocxEnhancer

DocxEnhancer is an AI-powered web application that allows users to upload .docx files formatted with MCQs and receive a richly enhanced version of the document. It intelligently adds answers, explanations, and references using the OpenAI Assistant API β€” helping educators, students, and content creators save time and effort.


✨ Features

  • Upload .docx files with:

    Question:
    [MCQ options]
    Explanation:
    
  • Automatically enriches the document by adding:

    • βœ… Correct Answer
    • πŸ’‘ Enhanced Explanation
    • πŸ”— Reference (optional)
  • Edit generated explanations or transform content into AI prompts

  • Download the enhanced .docx file

  • Powered by OpenAI's Assistant API

  • Real-time processing with Next.js, Express, and Node.js


πŸš€ Tech Stack

Frontend Backend AI/Processing
Next.js Express.js OpenAI Assistant API
React Node.js Mommuth (docx parsing)
Tailwind CSS Multer (upload) Custom Enhancement Logic

πŸ“‚ Folder Structure

/DocxEnhancer
β”œβ”€β”€ backend
β”‚    β”œβ”€β”€ config
β”‚    β”‚    β””── mongoose.connection.js
β”‚    β”œβ”€β”€ models
β”‚    β”‚    β””── document.model.js
β”‚    β”œβ”€β”€ package.json
β”‚    β”œβ”€β”€ package-lock.json
β”‚    β”œβ”€β”€ routes
β”‚    β”‚    β””── document.route.js
β”‚    β”œβ”€β”€ schemas
β”‚    β”‚    β”œβ”€β”€ document.schema.js
β”‚    β”‚    β””── question.schema.js
β”‚    β”œβ”€β”€ server.js
β”‚    β””── utils
β”‚        └── parseQuestion.js
└── frontend
    β”œβ”€β”€ app
    β”‚   β”œβ”€β”€ batch
    β”‚   β”‚   └── [id]
    β”‚   β”‚    β””── page.tsx
    β”‚   β”œβ”€β”€ globals.css
    β”‚   β”œβ”€β”€ layout.tsx
    β”‚   β”œβ”€β”€ page.tsx
    β”‚   └── prompt
    β”‚        └── page.tsx
    β”œβ”€β”€ components
    β”‚   β”œβ”€β”€ app-sidebar.tsx
    β”‚   β”œβ”€β”€ improve-dialog.tsx
    β”‚   β”œβ”€β”€ theme-provider.tsx
    β”‚   β”œβ”€β”€ ui
    β”‚   β”‚   └── [... dozens of ui components ...]
    β”‚   └── upload-dialog.tsx
    β”œβ”€β”€ components.json
    β”œβ”€β”€ hooks
    β”‚   β”œβ”€β”€ use-mobile.tsx
    β”‚   └── use-toast.ts
    β”œβ”€β”€ lib
    β”‚   └── utils.ts
    β”œβ”€β”€ next.config.mjs
    β”œβ”€β”€ next-env.d.ts
    β”œβ”€β”€ package.json
    β”œβ”€β”€ pnpm-lock.yaml
    β”œβ”€β”€ postcss.config.mjs
    β”œβ”€β”€ public
    β”œβ”€β”€ tailwind.config.ts
    └── tsconfig.json

Things which you have to know when using openai API

🧠 1. What is Assistant ?

Definition

An assistant is a custom versoin of ChatGPT that you've configured for a specific task. Think of it like a tailored chatbot or agent that has its own:

  • Instructions (behavior/personality/goals).
  • Tools (like code interpreter, retrival, or your own APIs).
  • Files (optional context).
  • Model (GPT-4, GPT-3.5, etc).

Once you create an Assistant, it gets a persistent ID - you reuse that assistant anytime you want that behavior.

🧡 2. What is a Thread ?

Definition

A Thread is a conversation between a user and an assistant. It stores:

  • All messages (user + assistant)
  • All runs (calls to GPT to generate response)

πŸ” Why you need Threads

Each user can have multiple sessions, and Threads help you:

  • Separate conversations
  • Resume them later
  • Keep context over time

πŸš€ 3. What is Run ?

Definition

A Run is an event that triggers the Assistant to process the messages in a Thread and respond.

It's like saying: "Hey assistant, process this conversation and reply."

🧭 Internally, a Run does

  • Checks the Assistant's settings
  • Reads the current Thread
  • Calls the model (like GPT-4)
  • Sends back the Assistant's reply

πŸ’¬ 4. What are Messages ?

Definition

Messages are the individual chat messages in a Thread.

  • A message has a role: either user or assistant
  • A message has content: the text (or files, in advanced cases)

🧱 Messages Stack

Let’s say you want to chat with the assistant about JavaScript:

  1. You add a message: "Explain closures in JavaScript"
  2. You start a run -> assistant reads all messages
  3. It replies with an explanation -> new assistant message is added

βš™οΈ Setup Instructions

  1. Clone the repo:
git clone https://github.com/ExploitEngineer/DocxEnhancer.git
cd DocxEnhancer
  1. Install dependencies:
# For backend
cd backend
npm install

# For frontend
cd ../frontend
npm install
  1. Create .env file in /backend with:
OPENAI_API_KEY=your_openai_api_key
PORT=5000
  1. Run the app:
# Run backend
cd backend
npm run dev

# Run frontend
cd ../frontend
npm run dev

Visit http://localhost:3000 to get started!


πŸš€ Example .docx Format

Question:
Which protocol does HTTPS use?
A. FTP
B. SSH
C. TLS
D. TCP

Explanation:
Used for secure communication.

The output will add:

  • Answer: C. TLS
  • Explanation: HTTPS uses TLS (Transport Layer Security) to encrypt communications between web clients and servers.
  • Reference: Wikipedia - HTTPS

πŸ“— License

MIT License. Free for personal and commercial use.


✈️ Contribution

Pull requests, issues, and discussions are welcome! Let’s improve AI-enhanced education tools together.


πŸ“’ Contact

Made with ❀️ by ExploitEngineer