This is a serverless application that uses AWS Lambda, S3, and Textract to scan a receipt image and extract the text from it. The extracted text is then stored in MySQL database.
Even though deployment uses SAM CLI, the build process is managed by CMake. So you first build the project using CMake which generates deployment template and artifacts and then deploy the project using SAM CLI.
mkdir out
cd out
<path-to-aws-toolchain-file>
with the path to the toolchain file.
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=<path-to-aws-toolchain-file>
cmake --build .
<stage>
with the stage you want to deploy to. Provide cognito user pool arn to connect API gateway to cognito.
./deploy <stage> --parameter-overrides CognitoUserPool=<cognito-user-pool-arn>
database
directory in MySQL database.Claude Instant 1.2
model./receipt-scan/<stage>/db-connection-string
and value as connection string to MySQL database.App Integration
.Cognito domain
. This is the domain you will use to authenticate with the API.App clients
and find the Client id
of receipt-scan-<stage>-user-pool-client
. This is the default user pool client created by the project.https://<cognito-domain>/login?response_type=code&client_id=<client-id>&redirect_uri=<your-redirect-uri>
. Replace <cognito-domain>
, <client-id>
and code
in the url.https://<cognito-domain>/oauth2/token
with x-www-form-urlencoded
body providing values grant_type=authorization_code
, client_id=<client-id>
, code=<code>
and redirect_uri=<redirect-uri>
. Replace <client-id>
, <code>
and access_token
.access_token
in the Authorization
header (without Bearer
).Please note, that all endpoints except POST /user
will return 400
if user was not initialized with POST /user
endpoint.
POST /user
- Init a new user. Only id is taken from access_token
. No body required. Returns 200
if successful. Noop if user already exists.GET /user
- Get user id. Returns 200
with user id. Returns 404
if user was not initialized with POST
endpoint.DELETE /user
- Delete user. By deleting user, all user's receipts, categories and budgets are deleted. Also all user's files are deleted from S3 bucket. And finally, user is deleted from Cognito User Pool. Returns 200
if successful. Endpoint is idempotent, so calling multiple times will return 200
every time.GET /budgets
- Get all budgets. Returns 200
with list of budgets.PUT /budgets
- Add a new budget or update an existing one. Returns 200
if successful. Returns 409
if optimistic concurrency error occurs on trying to update a budget.GET /budgets/changes?from=<changes-from>
- Get all budget changes from given timestamp. Returns 200
with list of budget changes.GET /categories
- Get all categories. Returns 200
with list of categories.PUT /categories
- Add a new category or update an existing one. Returns 200
if successful. Returns 409
if optimistic concurrency error occurs on trying to update a category.DELETE /categories/{id}
- Delete a category by id. Returns 200
if successful. Returns 404
if category was not found.GET /categories/changes?from=<changes-from>
- Get all category changes from given timestamp. Returns 200
with list of category changes.GET /receipts/years/{year}/months/{month}
- Get all receipts for given year and month. Returns 200
with list of receipts.PUT /receipts
- Add a new receipt or update an existing one. This endpoint permits to modify manually receipt information, or even add a totally manually inserted receipt. Returns 200
if successful. Returns 409
if optimistic concurrency error occurs on trying to update a receipt.DELETE /receipts/{id}
- Delete a receipt by id. Returns 200
if successful. Returns 404
if receipt was not found.GET /receipts/{id}/image
- Get a pre-signed url to obtain the receipt image. Returns 200
with url. Returns 404
if receipt was not found.PUT /receipts/{id}/image
- Upload a receipt image. This endpoint is used to start receipt image scan asynchronously. When scanning is done, the receipt state will pass to done
and new version of receipt will be generated. Returns 200
if successful. Returns 404
if receipt was not found.GET /receipts/changes?from=<changes-from>
- Get all receipt changes from given timestamp. Returns 200
with list of receipt changes.