A RESTful API service that analyzes strings and stores their computed properties including length, palindrome detection, unique character count, word count, SHA-256 hash, and character frequency mapping.
- ✅ Create and analyze strings with automatic property computation
- ✅ Retrieve specific strings by value
- ✅ Filter strings using multiple query parameters
- ✅ Natural language query support
- ✅ Delete strings from the system
- ✅ SHA-256 hash-based unique identification
- ✅ Comprehensive error handling
- Runtime: Node.js (v18+)
- Framework: Express.js
- Storage: In-memory (Map data structure)
- Deployment: Railway / Heroku / AWS
POST /strings
Content-Type: application/json
{
  "value": "string to analyze"
}Response (201 Created):
{
  "id": "sha256_hash_value",
  "value": "string to analyze",
  "properties": {
    "length": 17,
    "is_palindrome": false,
    "unique_characters": 12,
    "word_count": 3,
    "sha256_hash": "abc123...",
    "character_frequency_map": {
      "s": 2,
      "t": 3,
      "r": 2
    }
  },
  "created_at": "2025-08-27T10:00:00Z"
}GET /strings/{string_value}GET /strings?is_palindrome=true&min_length=5&max_length=20&word_count=2&contains_character=aQuery Parameters:
- is_palindrome: boolean (true/false)
- min_length: integer
- max_length: integer
- word_count: integer
- contains_character: single character
GET /strings/filter-by-natural-language?query=all%20single%20word%20palindromic%20stringsExample Queries:
- "all single word palindromic strings"
- "strings longer than 10 characters"
- "palindromic strings that contain the first vowel"
- "strings containing the letter z"
DELETE /strings/{string_value}- Node.js (v18 or higher)
- npm or yarn
- Clone the repository
git clone https://github.com/Olu433/string-analyzer-api 
cd string-analyzer-api - Install dependencies
npm install- Run the server
# Development mode with auto-reload
npm run dev
# Production mode
npm startThe server will start on http://localhost:3000 by default.
Create a .env file (optional):
PORT=3000Create a string:
curl -X POST http://localhost:3000/strings \
  -H "Content-Type: application/json" \
  -d '{"value": "racecar"}'Get a string:
curl http://localhost:3000/strings/racecarGet all strings with filters:
curl "http://localhost:3000/strings?is_palindrome=true&word_count=1"Natural language query:
curl "http://localhost:3000/strings/filter-by-natural-language?query=all%20single%20word%20palindromic%20strings"Delete a string:
curl -X DELETE http://localhost:3000/strings/racecar- Import the API endpoints into Postman
- Set the base URL to http://localhost:3000
- Test each endpoint with sample data
- 
Create a Railway account at railway.app 
- 
Install Railway CLI: 
npm install -g @railway/cli- Login and deploy:
railway login
railway init
railway up- Get your deployment URL:
railway domain- 
Create a Heroku account at heroku.com 
- 
Install Heroku CLI and login: 
heroku login- Create and deploy:
heroku create your-app-name
git push heroku mainstring-analyzer-api/
├── server.js           # Main application file
├── package.json        # Dependencies and scripts
├── .gitignore         # Git ignore rules
└── README.md          # This file
The API returns appropriate HTTP status codes:
- 200 OK: Successful GET request
- 201 Created: Successful POST request
- 204 No Content: Successful DELETE request
- 400 Bad Request: Invalid request parameters
- 404 Not Found: Resource not found
- 409 Conflict: Resource already exists
- 422 Unprocessable Entity: Invalid data type
- express: Web framework for Node.js
- cors: Enable CORS for cross-origin requests
- crypto: Built-in Node.js module for SHA-256 hashing
For development with auto-reload:
npm run dev- This implementation uses in-memory storage. Data will be lost on server restart.
- For production, consider using a database (PostgreSQL, MongoDB, etc.)
- The API supports URL-encoded string values in GET/DELETE requests
- Natural language parsing supports common patterns but may need extension for complex queries
Awe Caleb
MIT