Certainly! Below is a basic example of documentation for your project. Please customize it further based on the specific features, endpoints, and details of your application.
Puppeteer ChatGPT Summary Generator is a web application designed to simplify the process of generating text summaries from web pages. It leverages Puppeteer for web scraping and ChatGPT for natural language processing, providing users with an efficient and user-friendly way to extract and summarize information from websites.
- Overview
- Getting Started
- API Endpoints
- Web Scraping with Puppeteer
- ChatGPT Summary Generation
- Middleware
- Models
- Configuration Files
- Contributing
- License
- Contact
The Puppeteer ChatGPT Summary Generator allows users to register, log in, and generate text summaries from web pages. The application integrates web scraping using Puppeteer for extracting information and ChatGPT for summarizing the content. Token-based authentication, MongoDB for user data storage, and Redis for token management are key components of this application.
-
Clone the repository.
git clone https://github.com/your-username/your-repository.git cd your-repository
-
Install dependencies.
npm install
-
Configure your MongoDB connection in
db.ts
and your Redis connection inredis.ts
. -
Start the application.
npm start
-
Access the application at http://localhost:3000.
Endpoint: /user/register
Method: POST
Description: Register a new user.
Request:
{
"username": "example_user",
"email": "user@example.com",
"password": "securepassword"
}
Response:
{
"user": {
"username": "example_user",
"email": "user@example.com"
}
}
Endpoint: /user/login
Method: POST
Description: Log in an existing user.
Request: Use this for Test
{
"email": "test@example.com",
"password": "test"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsIn..."
}
Endpoint: /user/logout
Method: GET
Description: Log out the current user.
Response:
Please login again
Endpoint: /user/generateSummary
Method: POST
Description: Generate a summary from a given URL.
Request:
{
"url": "https://example.com"
}
Response:
{
"summary": "A concise summary of the web page content."
}
The application uses Puppeteer to scrape text content from web pages. The puppeteerHelper.ts
file provides the necessary functions for web scraping. Customize the code in this file based on the structure of the target web page.
Text summaries are generated using the ChatGPT API. The chatGPTHelper.ts
file contains the functions responsible for interacting with the ChatGPT API. Ensure to replace the YOUR_CHATGPT_API_KEY
variable with your actual API key.
Middleware: checkBlacklist
Description: Checks if the user's authentication token is blacklisted.
File: user.ts
Description: Defines the structure of the user data stored in MongoDB.
interface User {
username: string;
email: string;
password: string;
}
Middleware: rateLimiter.ts
Description: Implements rate limiting to prevent abuse of the API by limiting the number of requests from a single IP address within a specific time window.
// middleware/rateLimiter.ts
import { RateLimit } from 'express-rate-limit';
const limiter = RateLimit({
windowMs: 1 * 60 * 1000, // 1 minute
max: 15, // Limit each IP to 15 requests per `window` (here, per 1 minute).
headers: true, // Enable headers for request limiting information
});
export default limiter;
## Configuration Files
### MongoDB Configuration
**File:** `db.ts`
**Description:** Configures the connection to MongoDB.
### Redis Configuration
**File:** `redis.ts`
**Description:** Configures the connection to Redis.
## Contributing
If you want to contribute to the project, please follow the guidelines in the [Contributing.md](CONTRIBUTING.md) file.
## License
This project is licensed under the [MIT License](LICENSE).
## Contact
For any inquiries or support, please contact:
- Email: avinashmohandev@gmail.com
Feel free to customize this documentation to match the specifics of your project.