A minimalist Express.js backend for analyzing, storing, filtering, and deleting strings.
It supports palindrome detection, word counting, and natural language filtering using simple heuristics.
Everything is stored in a local JSON file — no database setup required.
- Create and analyze strings with rich metadata
- Retrieve single or multiple string entries
- Filter with structured or natural language queries
- Delete stored strings
- Persistent local JSON storage
- Color-coded logs for visibility
string-analyzer-api/
│
├── controllers/
│ └── controller.js # All route logic (create, read, filter, delete)
│
├── routes/
│ └── routes.js # API routes mapped to controller methods
│
├── utils/
│ └── logger.js # Logging utilities
│
├── stringsStore.json # Local JSON storage
│
├── server.js # Express app entry point
├── package.json
└── README.md
git clone https://github.com/yourusername/string-analyzer-api.git
cd string-analyzer-apinpm install express cors body-parsernpm startnpm run dev🧩 API Endpoints
POST /strings
Request Body
{
"value": "man of stones"
}Success Response – 201 Created
{
"id": "fcfc1723-1326-4d2f-8278-b4161af13775",
"value": "man of stones",
"properties": {
"length": 13,
"is_palindrome": false,
"unique_characters": 9,
"word_count": 3,
"sha256_hash": "dce77f0279534f7699f89da44f164faf770e10925c265960f2ec499d63a0dfb2",
"character_frequency_map": {
"m": 1,
"a": 1,
"n": 2,
"o": 2,
"f": 1,
"s": 2,
"t": 1,
"e": 1
}
},
"createdAt": "2025-10-21T10:22:43.918Z"
}Error Responses:
- 400 Bad Request – Missing or invalid body field
- 409 Conflict – String already exists
GET /strings
Success Response – 200 OK
{
"data": [ /* all stored strings */ ],
"count": 3
}GET /strings/:value
Example:
GET /strings/man%20of%20stonesSuccess Response:
{
"id": "fcfc1723-1326-4d2f-8278-b4161af13775",
"value": "man of stones",
"properties": {
"length": 13,
"is_palindrome": false,
"unique_characters": 9,
"word_count": 3
},
"createdAt": "2025-10-21T10:22:43.918Z"
}Error Response:
- 404 Not Found – String does not exist in the system
GET /strings?is_palindrome=true&min_length=5&max_length=15
Supported Query Parameters:
| Parameter | Type | Description |
|---|---|---|
| is_palindrome | boolean | Filter palindromic strings |
| min_length | number | Minimum string length |
| max_length | number | Maximum string length |
| word_count | number | Exact word count |
| contains_character | string | Must include a given character |
Example Response:
{
"data": [ { "value": "racecar", "properties": { "is_palindrome": true } } ],
"count": 1,
"filters_applied": {
"is_palindrome": "true",
"min_length": "5",
"max_length": "15"
}
}GET /strings/filter-by-natural-language?query=<your query>
Success Response – 200 OK
{
"data": [ /* filtered results */ ],
"count": 1,
"interpreted_query": {
"original": "all single word palindromic strings",
"parsed_filters": {
"is_palindrome": true,
"word_count": 1
}
}
}Error Responses:
- 400 Bad Request – Unable to parse natural language query
- 422 Unprocessable Entity – Conflicting filters
- 404 Not Found – No matching string entries
DELETE /strings/:value
Example:
DELETE /strings/man%20of%20stonesSuccess Response – 204 No Content
- (Empty response body)
Error Responses:
- 404 Not Found – String does not exist
- 400 Bad Request – Missing or invalid parameter