Giter Club home page Giter Club logo

photo-server's Introduction

Photography Ecommerce Shop

This repository contains the backend for my personal photography website / store.

The GraphQL server, written in Golang, supports:

  1. Uploading new images. The metadata (name, id, price) is stored in AWS DynamoDB and the files themselves are stored in AWS S3 buckets.
  2. Deleting images by ID.

These two features are mainly for the store owner to manage which images they want to make available for sale on the store.

Next, the server also supports:

  1. Retrieving a single image by ID.
  2. Retrieving all images.

These endpoints are consumed by the UI to display the images in the shop.

And lastly, there is also an endpoint for:

  1. Creating a Stripe checkout session. This is also only used by the UI to create a new Stripe checkout session to start the checkout process once the customer has decided to pay.

The schemas for the endpoints, queries, and mutations can be found in graph/schema.graphqls.

The resolvers for all queries and mutations are implemented in graph/schema.resolvers.go.

The server, hosted on Heroku, exposes one GraphQL endpoint at https://protected-bastion-36826.herokuapp.com/query. You can also visit https://protected-bastion-36826.herokuapp.com/ to use the GraphQL playground. Since the project is on the free tier of Heroku, the first request may take up to 30 seconds to complete.

Example Requests

Adding new image to shop:

curl https://protected-bastion-36826.herokuapp.com/query \
  -F operations='{ "query": "mutation ($input: NewImage!) { uploadImage(input: $input) { _id, name, price }}", "variables": { "input": {"name": "test.jpg", "price": 1, "file": null } } }' \
  -F map='{ "0": ["variables.input.file"] }' \
  -F 0=@./testimages/test.jpg

Deleting image by ID (using the GraphQL playground):

mutation deleteImage($id: String!) {
  deleteAuthor(id: $id) {
     _id
     name
  }
}

Creating a new Stripe checkout session using product(image) ID:

mutation createCheckoutSession {
    createCheckoutSession(photoID: "7018c40f-ad75-4d23-b1a8-33eb051f8e1f")
}

Query for single image by ID:

query {
  image(_id: "7018c40f-ad75-4d23-b1a8-33eb051f8e1f") {
    _id
    price	
    name
    thumbnail_url
    fullsize_url
  }
}

Shop

To checkout out the shop, go to photo.davidxliu.com. The code can be viewed here. This is the homepage of the portfolio. In the header, select shop. This will display all the Lightroom Presets (.xmp files) with a sample photo edited using that Preset which are currently available to purchase for download. Clicking the prompt to buy a Preset will ask the server to start a new Stripe checkout session and redirect you to the checkout page. Sadly, a "cart" feature hasn't been implemented yet, so only one Preset can be purchased at a time. The shop is still in test mode, so you can try the following credit card to get a successful purchase:

Card #: 4242 4242 4242 4242.

The name, address, and cvv can be anything and the expiry date must be any future date.

After the payment is processed, you will be redirected to the success page, from which you can download your Lightroom Preset :) This download url is a pre-signed URL to access the object from its S3 bucket, so it is only available for a few minutes after the payment is completed.

photo-server's People

Contributors

xngln avatar

Watchers

 avatar

Forkers

connormai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.