Giter Site home page Giter Site logo

city-tags-api's Introduction

City Tags API

Introduction

API to be able to consume tags on cities, for example if the humidity is "moderate" or "humid" or if the city is "small" or "big". Built with Go (Chi), Pulumi, AWS and Supabase.

Architecture

Architecture diagram

A DNS record with an SSL certificate is used to be able to set up a connection through HTTPS. An Application Load Balancer (ALB) is registered as a target of this registry. The ALB redirects traffic to the ECS Service where the Go API is deployed. The ECS Service makes use of SSM Parameter Store for environment variables and of ECR to store the different container images of the API. Finally, the API queries the database, in this case Supabase, where the serverless Postgres database is.

The API follows the OpenAPI standard and has the documentation hosted on "/v0/swagger/" and it also has authentication through JWT.

You can test a simple call on the development environment with:

curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjaXR5LXRhZ3MtYXBpLmRldi5zaXR5ZXguY29tIiwiaWF0IjoxNzIwNzA3NjMxLCJleHAiOjcyNzQ2NzI0MzEsImF1ZCI6IiIsInN1YiI6ImFub255bW91c191c2VyIn0.Mu37OetnJFUvEf-kRtnMl6Yv4wvvAm2qpAcNrbr8UGY" https://dev.city-tags-api.sityex.com/v0/cities?limit=5

Requirements

  • You must own an AWS account and have an Access Key to be able to authenticate.
  • Go v1.22.1
  • Tools:
    • psql==14.12
    • goose==3.20.0
    • air==1.52.1
    • swag==1.16.3
    • pre-commit==3.7.1
    • bumpversion==1.0.1

Testing

Unit tests

The unit tests developed in this repo test business logic only, testing that had external dependencies is done in the integration tests. To run the unit tests you can run the following command:

make unit-tests

These tests are executed everytime a commit is created as part of the pre-commit workflow and also in the PR checks before merging.

Integration tests

These tests have been developed to test all the functionality that interacts with the database. A test environment is set up with Docker Compose with the following containers:

  • city-tags-api: API developed with Go.
  • psql: postgres database that will simulate the Supabase database.
  • integration-tests: container where the integration tests will run. Before running the tests in runs the goose migrations and initializes the database with test data.
Architecture diagram

To run the integration tests you can run the following command:

make integration-tests

These tests are executed everytime a commit is created as part of the pre-commit workflow and also in the PR checks before merging.

city-tags-api's People

Contributors

ajaen4 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.