-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
D-BOY edited this page Mar 27, 2025
·
1 revision
This document outlines the architecture of the Programming Task Generator application.
The Programming Task Generator is built using a Node.js Express backend with a simple HTML/CSS/JavaScript frontend. It uses OpenAI's GPT-4 API for generating programming tasks and Mermaid.js for creating visualizations.
+------------------+ +------------------+ +------------------+
| | | | | |
| Web Interface |<------>| Express Server |<------>| OpenAI API |
| | | | | |
+------------------+ +------------------+ +------------------+
|
|
v
+------------------+
| |
| Puppeteer |
| (PDF Gen) |
| |
+------------------+
The frontend consists of HTML, CSS, and JavaScript files:
- index.html: Main interface with form elements
- styles.css: Styling for the UI
- script.js: Client-side logic for handling user interactions and form submissions
The backend is built with Express.js:
- app.js: Main server file that handles routing, middleware, and API calls
- uploads/: Directory for temporarily storing uploaded PDF files
- OpenAI API: Used for generating task content and visualizations
- Mermaid.js: Library for rendering diagrams in the PDF
- Puppeteer: Headless browser for converting HTML to PDF
- User Input: User selects task types, languages, and other options via the web interface
- Form Submission: The form data is sent to the server via a POST request
- Task Generation: The server calls the OpenAI API to generate task content
- Visualization Generation: The server calls the OpenAI API again to generate visualization code
- HTML Generation: The server generates an HTML file with the task content and Mermaid.js code
- PDF Creation: Puppeteer renders the HTML and converts it to a PDF
- File Delivery: The PDF is sent back to the client for download
programming-task-generator/
├── app.js # Main server file
├── package.json # Node.js dependencies
├── .env # Environment variables
├── uploads/ # Temporary storage for uploaded files
├── public/ # Static files
│ ├── index.html # Main HTML file
│ ├── styles.css # CSS styles
│ └── script.js # Client-side JavaScript
└── docs/ # Documentation
├── API.md # API documentation
├── ARCHITECTURE.md # This file
└── CONTRIBUTING.md # Contribution guidelines
- Backend: Node.js, Express.js
- Frontend: HTML5, CSS3, JavaScript
- APIs: OpenAI API
- Libraries: Puppeteer, Mermaid.js, pdf-parse, multer
- Development: dotenv for environment variables
sequenceDiagram
participant User
participant Frontend
participant Server
participant OpenAI
participant Puppeteer
User->>Frontend: Select options and submit form
Frontend->>Server: POST /generate
Server->>OpenAI: Request task generation
OpenAI->>Server: Return generated task
Server->>OpenAI: Request visualizations
OpenAI->>Server: Return visualization code
Server->>Server: Generate HTML file
Server->>Puppeteer: Render HTML to PDF
Puppeteer->>Server: Return PDF file
Server->>Frontend: Send PDF file
Frontend->>User: Download PDF