Provide an HTTP API that takes a string input and returns if that string is a pangram. (Use the language and methods you feel best, but be prepared to defend them).
In order to run the following API on your machine you must have the following installed and configured on your machine.
A sentence which uses every letter of a given alphabet at least once.
Run Tests
make test
Run API
docker-compose up
Run integration tests
make integration
Make a call against the pangram endpoint
# Successful
curl -i -XPOST -d '{"text": "The quick brown fox jumps over the lazy dog!"}' http://localhost:8080/tests/pangram
# Unsuccessful
curl -i -XPOST -d '{"text": "is this a pangram?"}' http://localhost:8080/tests/pangram
# Error
curl -i -XPOST -d '{"text": "is this a pangram? What about this one?"}' http://localhost:8080/tests/pangram
There's also a postman collection you can import and use to make these calls if
you don't like curl ๐
Version the API
Add logging!
Add Metrics
Other endpoints to test various things (i.e. palindromes, anagrams, prime numbers)
Other languages OR Define your own alphabet (with customizable normalization)
Character count
Add other methods (ie. GET Generates a pangram and returns it)
If customer requirments dictate - evaluate using a language processing library (or writing one) for more complex normalization/transformation
Use multistage docker build for smaller docker image
Use an assertion library (if it's becomes necessary)
Add clean shutdown
I feel that I should mention that I was not going for a REST-ful API here. This also does not follow any JSON-RPC specification either. It is a custom "rpc style" HTTP API. If I were to flesh this out into a service I would want to follow some conventions to offload the cognitive burden of "inventing" our own architecture and expectations around requests and responses.
To avoid yagni - I refrained from making too many "well it would be cool if we could to this" while leaving the service extensible with some minor refactoring.
I included more comments than I would normally in the code to assist quick readability. I believe the code should be clear and easy to reason about (tests help).
I was having fun with some automation so I added things like automated dockerhub builds, circleci w/ status badge, and newman integration tests via postman cli.
Turns out there are a ton of edge cases and language processing is hard. I'd be interested in looking into some "C"lever ways of handling/normalizing input for different languages/keyboars/character sets etc. Seems like there are probably libraries out there that handle these kinds of things more elegantly than my quickly thrown together helpers ๐
I thought this was a nice little project for a coding excercise. The
requirements provided were just enough for me to implement this in a number
of different ways and I think It provides a great platform for discussion. In
the real world centralizing such a simple service like this might be a little
strange as IsPangram could exist in a library that our client consumes -
For example, it would be reasonable to offload this work to a browser.
Content type
Image
Digest
Size
298 MB
Last updated
over 7 years ago
docker pull tantona/cleardata