Skip to content

ajurasz/ascii-less-gallery

Repository files navigation

What

Ascii-less-gallery is a sample project combining AWS Lambda functions, Serverless framework and Kotlin language. It was inspired by serverless-photo-recognition github project. Intention was to try to setup project that use AWS Lambda functions with minimal effort - everything thanks to Serverless framework

Build codecov

Features

  • custom authorization leveraging redis for caching user access tokens - this reduce numbers of request (cost) to AWS DynamoDB
  • user login and registration
  • image upload and conversion to ascii
  • storing labeled images in ElasticSearch - labeling is done using AWS Rekognition service

Architecture

Architecture

Prerequisite

  1. Create ElasticSearch domain es-gallery
  2. Create Redis - due to not being able to call Redis from Lambda I decided to use redislabs free plan.
  3. One manual tweek is required to make it all work. Login to AWS Management Console and navigate to API Gateway service then on the left side select dev-ascii-less-gallery-service next Binary support and add files you want to be supporting like image/png

Installation

  1. Install and configure serverless framework (Instruction)
  2. Build project ./gradlew build
  3. Run sls deploy (I'm using dedicated account for serverless called sless and it is set in serverless.yml file). When deploy finish successfully all functions URLs will be printed in the console window.

Usage

  1. Register new user:
curl -X POST \
  https://xxxx/dev/register \
  -H 'content-type: application/json' \
  -d '{"email":"test@test.com", "password":"admin"}'
  1. Obtain user access token:
curl -X POST \
  https://xxxx/dev/login \
  -H 'authorization: Basic dGVzdEB0ZXN0LnBsOmFkbWlu'
  1. Upload image for recognition and conversion to ascii
curl -X POST \
  https://xxxx/dev/gallery \
  -H 'content-type: image/png' \
  -H 'token: eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0OTQ5NTA0NDgsImlzcyI6InRlc3RAdGVzdC5wbCJ9.Dj0itEWPE2PQ6WbeLgIWgHwslaVLWAgRlj-2scJ8Uk4'
  1. List all images
curl -X GET \
  https://xxxx/dev/gallery 
  1. User can delete his documents:
curl -X DELETE \
  https://xxxx/dev/gallery/def2c0d8-5d13-4603-83ef-79bf9e07944d \
  -H 'token: eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0OTQ5NTA0NDgsImlzcyI6InRlc3RAdGVzdC5wbCJ9.Dj0itEWPE2PQ6WbeLgIWgHwslaVLWAgRlj-2scJ8Uk4'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published