A REST API for analyzing Project Gutenberg e-books with LLM-powered text analysis, built with Node.js and Clean Architecture.
-
Runtime: Node.js
-
Framework: Express
-
Database: MongoDB (Mongoose ODM)
-
Language: TypeScript
-
Testing: Jest
-
Logging: Winston
-
Deployment: Render
-
LLM Integration: [Groq]
-
Architecture: Clean Architecture
git clone [https://github.com/yourusername/project-gutenberg-api.git](https://github.com/yourusername/project-gutenberg-api.git)cd project-gutenberg-apinpm installIf you wish you can use the docker-composer file that is already set in the project
docker-compose up -d❗ You will need to configure the DB connection string on .env file
npm run devCreate a .env file using the .env.example template. Replace placeholders with actual values:
PORT=8000
NODE_ENV=dev
LOG_LEVEL=info
# Database settings
DB_URI=
DB_USER=
DB_PASS=
# CORS allowed origins
ALLOWED_ORIGINS=*
#URLS
GUTENBERG_BASE_URL=https://www.gutenberg.org
DEV_API_URL=http://localhost:8000
PROD_API_URL=
#AUTH
JWT_SECRET=
GROQ_KEY=https://gutenberg-api-uwq7.onrender.com/api-docshttps://gutenberg-api-uwq7.onrender.com/auth
{
"email": "user@example.com",
"password": "yourPassword123"
}-
Success Response
Status Code:
201 Created
{
"success": true,
"message": "User authenticated successfully",
"data": "JWT_TOKEN",
"statusCode": 201
}https://gutenberg-api-uwq7.onrender.com/users
{
"username": "JohnDoe",
"email": "johndoe@example.com",
"password": "securePassword123"
}-
Success Response
Status Code:
201 Created
{
"success": true,
"message": "User created successfully",
"data": {
"id": "user_id",
"token": "JWT_TOKEN"
},
"statusCode": 201
}-
Success Response
Status Code:
200 OK
{
"success": true,
"message": "User found",
"data": {
"id": "user_id",
"username": "JohnDoe",
"email": "johndoe@example.com",
"isActive": true
},
"statusCode": 200
}-
Success Response
Status Code:
200 OK
{
"success": true,
"message": "User found",
"data": {
"id": "user_id",
"username": "JohnDoe",
"email": "johndoe@example.com",
"isActive": true
},
"statusCode": 200
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}{
"username": "JohnDoeUpdated",
"email": "johnupdated@example.com",
"password": "newSecurePass123"
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}https://gutenberg-api-uwq7.onrender.com/books
{
"gutenbergId": "12345",
"title": "Pride and Prejudice",
"author": "Jane Austen",
"coverPictureUrl": "https://example.com/cover.jpg",
"metadata": {
"published": "1813",
"downloads": 50000,
"language": "English",
"category": "Fiction",
"rights": "Public Domain"
},
"content": "Full book content here..."
}-
Success Response
Status Code:
201 Created
{
"success": true,
"message": "Book created successfully",
"data": "65a3bde50fbb9c4a1d23f0d9",
"statusCode": 201
}-
Success Response
Status Code:
200 OK
{
"message": "Book found",
"data": {
"id": "65a3bde50fbb9c4a1d23f0d9",
"gutenbergId": "12345",
"title": "Pride and Prejudice",
"author": "Jane Austen",
"coverPictureUrl": "https://example.com/cover.jpg",
"metadata": {
"published": "1813",
"downloads": 50000,
"language": "English",
"category": "Fiction",
"rights": "Public Domain"
},
"content": "Full book content here..."
}
}-
Success Response
Status Code:
200 OK
{
"success": true,
"message": "User found",
"data": {
"id": "user_id",
"username": "JohnDoe",
"email": "johndoe@example.com",
"isActive": true
},
"statusCode": 200
}-
Success Response
Status Code:
200 OK
{
"message": "Books found",
"data": [
{
"id": "65a3bde50fbb9c4a1d23f0d9",
"gutenbergId": "12345",
"title": "Pride and Prejudice",
"author": "Jane Austen",
"coverPictureUrl": "https://example.com/cover.jpg",
"metadata": {
"published": "1813",
"downloads": 50000,
"language": "English",
"category": "Fiction",
"rights": "Public Domain"
}
}
]
}-
Success Response
Status Code:
200 OK
{
"message": "Books found",
"data": [
{
"id": "65a3bde50fbb9c4a1d23f0d9",
"gutenbergId": "12345",
"title": "Pride and Prejudice",
"author": "Jane Austen",
"coverPictureUrl": "https://example.com/cover.jpg",
"metadata": {
"published": "1813",
"downloads": 50000,
"language": "English",
"category": "Fiction",
"rights": "Public Domain"
}
}
]
}{
"content": "Updated book content..."
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}{
"metadata": {
"published": "1813",
"downloads": 55000,
"language": "English",
"category": "Fiction",
"rights": "Public Domain"
}
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}-
Success Response
Status Code:
204 No Content
{
"success": true,
"message": "",
"data": null,
"statusCode": 204
}https://gutenberg-api-uwq7.onrender.com/gutenberg
-
Success Response
Status Code:
201 Created
{
"success": true,
"message": "Book saved successfully",
"data": "65a3bde50fbb9c4a1d23f0d9"
"statusCode": 201
}https://gutenberg-api-uwq7.onrender.com/llm
{
"id": "1342",
"action": "SUMMARY"
}-
Success Response
Status Code:
200 Ok
{
"success": true,
"message": "Groq response received",
"data": "This book is a classic novel that explores themes of love and social status..."
"statusCode": 201
}Deployed on Render with MongoDB Atlas. Environment variables configured via Render dashboard:
# Server settings
PORT=8000
NODE_ENV=dev
LOG_LEVEL=info
# Database settings
DB_URI=
DB_USER=
DB_PASS=
# CORS allowed origins
ALLOWED_ORIGINS=*
#URLS
GUTENBERG_BASE_URL=https://www.gutenberg.org
DEV_API_URL=http://localhost:8000
PROD_API_URL=
#AUTH
JWT_SECRET=
GROQ_KEY=Run unit tests with Jest:
npm test-
Clean architecture layers:
-
application/: Business logic -
domain/: Entities and interfaces -
infrastructure/: Database/LLM integrations -
adapter/: Express routes
-
-
Migrated MongoDB from local Docker to Atlas for scalability
-
Winston logger with production-grade configurations
-
JWT authentication for secure endpoints