An open API service indexing awesome lists of open source software.

https://github.com/paihari/vending-machine-golang-graphql

Account Vending Machine. Creates Child Accounts, IAM Users, Tag, Policies, Stores the state in DB
https://github.com/paihari/vending-machine-golang-graphql

account db-design graphql iam oci pgsql policies tags

Last synced: 7 days ago
JSON representation

Account Vending Machine. Creates Child Accounts, IAM Users, Tag, Policies, Stores the state in DB

Awesome Lists containing this project

README

          

# ๐Ÿงƒ Vending Machine POC โ€” Go + GraphQL

A proof-of-concept (POC) microservice that models a vending machine backend using **Golang**, **GraphQL**, and **PostgreSQL**. This application is cloud-ready and includes modules to simulate multi-cloud scenarios (AWS, OCI).

---

## ๐Ÿš€ Overview

This project allows users to query and mutate vending machine inventory and simulate user interactions via a GraphQL API. It's useful as a base for learning GraphQL server-side development in Go, infrastructure integration (OCI/AWS), and database schema management.

---

## ๐Ÿงฑ Tech Stack

- **GoLang** โ€“ Backend language
- **GraphQL** โ€“ API query language (via gqlgen)
- **PostgreSQL** โ€“ Relational database
- **Docker** โ€“ Containerized deployment
- **Fly.io** โ€“ (Optional) For deployment
- **AWS / OCI modules** โ€“ For cloud resource emulation

---

## ๐Ÿ“ Folder Structure

```
vending-machine-golang-graphql/
โ”œโ”€โ”€ awscompose/ # AWS simulation logic
โ”œโ”€โ”€ base/ # DB helper and init logic
โ”œโ”€โ”€ ocicompose/ # OCI simulation logic
โ”œโ”€โ”€ graph/
โ”‚ โ”œโ”€โ”€ schema.graphqls # GraphQL schema
โ”‚ โ”œโ”€โ”€ resolver.go # Root resolver
โ”‚ โ””โ”€โ”€ model/ # Auto-generated models
โ”œโ”€โ”€ documentation/ # Setup guides & images
โ”œโ”€โ”€ Dockerfile # Docker build script
โ”œโ”€โ”€ server.go # Main Go entrypoint
โ””โ”€โ”€ docker-compose.yml # Orchestration
```

---

## ๐Ÿ›  Setup Guide

### ๐Ÿ“ฆ Dependencies

- Go 1.18+
- PostgreSQL
- gqlgen (`go install github.com/99designs/gqlgen@latest`)

### ๐Ÿงช Local Dev Setup

```bash
git clone https://github.com/your-org/vending-machine-golang-graphql.git
cd vending-machine-golang-graphql
go run ./server.go
```

Open your browser at: [http://localhost:8080](http://localhost:8080)
GraphQL Playground will be available.

![GraphQL Playground](./documentation/images/sample-playground.png)

---

## โš™๏ธ Presetup (Cloud + DB)

- ๐Ÿ“˜ [Cloud Setup](./documentation/CLOUD-SETUP.md)
- ๐Ÿ—ƒ๏ธ [DB Setup](./documentation/DB-SETUP.md)

---

## ๐Ÿ’ป Sample Queries

### Query Example

```graphql
query {
items {
id
name
price
}
}
```

### Mutation Example

```graphql
mutation {
addItem(input: {
name: "Coca-Cola",
price: 1.5
}) {
id
name
}
}
```

More examples in:
- `sample-scripts-query.gql`
- `sample-scripts-mutations.gql`

---

## โœ๏ธ Author

Built with Simplificare