A lightweight Node.js REST API that analyzes strings, detects palindromes, computes hashes, counts characters, and even supports natural language filters.
This project was built as part of the HNG Internship 13 — Backend Stage 1 Task.
- Analyze and store string data in memory
- Detect palindromes, compute SHA-256 hashes
- Count characters, words, and unique letters
- Filter strings via query parameters
- Interpret natural language filters like:
- “all single word palindromic strings”
- “strings longer than 10 characters”
- “strings containing the letter z”
- Node.js (v18+)
- Express.js
- In-memory store (Map)
- CORS + JSON middleware
nlp-string-analyzer/
│
├── src/
│ ├── app.js # Express app setup
│ ├── routes/
│ │ └── string.js # Routes for /strings endpoints
│ ├── services/
│ │ └── analyzer.js # Core string analysis functions
│ ├── storage/
│ │ └── memory-store.js # In-memory store implementation
│ └── utils/
│ └── nlp-parser.js # Natural language filter parser
│
├── server.js # Entry point
└── package.jsongit clone https://github.com/Trayshmhirk/nlp-string-analyzer.git
cd nlp-string-analyzer
npm installnpm startServer will run at:
http://localhost:3000Analyze and save a new string.
{
"value": "racecar"
}{
"id": "e00f9ef5...",
"value": "racecar",
"properties": {
"length": 7,
"is_palindrome": true,
"unique_characters": 4,
"word_count": 1,
"sha256_hash": "e00f9ef5...",
"character_frequency_map": { "r": 2, "a": 2, "c": 2, "e": 1 }
},
"created_at": "2025-10-21T10:12:48.844Z"
}Retrieve a single analyzed string by value.
Example:
GET /strings/racecar
{
"id": "...",
"value": "racecar",
"properties": { "length": 7, "is_palindrome": true, ... }
}List all stored strings. Supports query filters.
| Param | Type | Example | Description |
|---|---|---|---|
is_palindrome |
boolean | true | Filter by palindrome |
min_length |
number | 5 | Minimum length |
max_length |
number | 10 | Maximum length |
word_count |
number | 1 | Exact word count |
contains_character |
string | a | Must contain this letter |
Interpret and apply filters from plain English.
Examples:
| Query | Meaning |
|---|---|
all single word palindromic strings |
Palindromes with one word |
strings longer than 5 characters |
Strings with length ≥ 6 |
strings containing the letter y |
Strings containing "y" |
Example Request:
GET /strings/filter-by-natural-language?query=all%20single%20word%20palindromic%20strings{
"data": [...],
"count": 2,
"interpreted_query": {
"original": "all single word palindromic strings",
"parsed_filters": {
"word_count": 1,
"is_palindrome": true
}
}
}Delete a stored string by its value.
Example:
DELETE /strings/hello%20world
{ "message": "String deleted" }- Push your repo to GitHub
- Go to Railway → “Deploy from GitHub”
- Select this repo
- Railway will detect it’s a Node app automatically
- Add the start command in
package.jsonif needed:
"scripts": {
"start": "node server.js"
}- After deployment, your API will be live at:
https://<your-app-name>.up.railway.app- HNG Internship 13 — Backend Stage 1
- GitHub: @Trayshmhirk
- Email: harlex.mikkey@gmail.com