Skip to content

A small service for uploading proposed message formulations, and suggesting alternative versions.

License

Notifications You must be signed in to change notification settings

almayor/correct-me

Repository files navigation

correct-me

Logo

correct-me is a prototype backend API designed for collaborating improvement of message phrasing. It allows users to upload message formulations, suggest alternatives, and choose the best version. Each message is also checked for spelling errors using a service like Yandex Speller, with errors displayed for review.

API Use Cases:

  • Sign up and authenticate: Secure access to the service.
  • Submit a new phrase: Users can submit phrases for review.
  • View and filter phrases: Users can view unresolved phrases or those they authored.
  • Submit a new alternative: Users can suggest alternative versions for others' phrases.
  • View and filter alternatives: Users can view alternatives and filter them by phrase, author or date of submission.
  • Mark best alternative: Authors can select the best alternative phrase to resolve a submission.
  • Automatic spell-check: Each phrase and alternative are automatically checked for spelling errors, with a list of errors provided.

Technologies Used:

  1. Haskell
  2. Servant
  3. Postgres (hasql)
  4. wreq / http-conduit
  5. Swagger UI

The API is protected by BasicAuth or JWT. To access them, you need to register by issuing a POST request to /api/users. See API Documentation or see the section below for details.

Running the application

You can run the application either with stack or using docker-compose. The API can be accessed at localhost:8080 or at whatever host/port is specified in config.toml.

Build manually

  1. Ensure you have Stack installed and a Postgres database running.
  2. Clone the repository:
    git clone https://github.com/almayor/correct-me.git
    cd correct-me
  3. Add the credentials needed to access the Postgres database to the config.toml file.
  4. Build and run the application:
    stack build
    stack run

Use Docker Compose

  1. Ensure you have Docker and Docker Compose installed.
  2. Clone the repository:
    git clone https://github.com/almayor/correct-me.git
    cd correct-me
  3. Build and run the Docker containers:
    docker-compose up

Testing the application

I am using hspec for testing. You can run the tests as follows:

docker-compose run --entrypoint stack app test
Example output

CI/CD

Github Actions have been set up to continuously

  1. test the project
  2. re-build the Docker image and push it to Docker Hub
  3. update the API Documentation

API Documentation

  • Servant Docs: The API documentation generated by Servant can be accessed at /docs. The Markdown file can also be accessed here.
  • Swagger UI: The Swagger UI for the API can be accessed at /swagger-ui.

TO-DO

  • Build a front-end client for the API
  • Add more tests
  • List alternative responses and exceptions in Swagger and Servant.Docs
  • Use pagination with servant-pagination
  • Use Redis to cache requests
  • Implement rate limiting to prevent abuse
  • Add monitoring and alerting for the application
  • Slim down Docker image by leveraging two-stage builds

About

A small service for uploading proposed message formulations, and suggesting alternative versions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published