Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 4.87 KB

README.md

File metadata and controls

83 lines (63 loc) · 4.87 KB

Infrastructure

We use terraform to set up 2 projects on GCP - staging and production.

Folder structure

Directory What goes inside of it
./infra/envs/ All environment definitions go here. What services are configured and how they depends on each other.
./infra/modules/ All reusable modules go here, e.g. google cloud run definitions.
./infra/services/ Here we have all of the service definitions

Infrastructure overview

C4Context
    title Infrastructure overview
    Person(user, "User")

    Boundary(internet, "Internet") {
        System(Web, "Web", "NextJS application")
        System(Gateway, "Graphql Gateway", "NestJS application")
    }

    Boundary(services, "Services") {
        System(Worker, "demo-worker", "NestJS application")
        System(User, "user-graphql", "NestJS application")
        System(Blog, "blog-graphql", "NestJS application")
        System(Todo, "todo-graphql", "NestJS application")
    }

    Boundary(db, "Storage") {
        SystemDb(Redis, "Managed Redis", "Memorystore instance")
        SystemDb(UserSql, "User database", "Cloud sql instance")
        SystemDb(BlogSql, "Blog database", "Cloud sql instance")
        SystemDb(TodoSql, "Todo database", "Cloud sql instance")
    }


    Rel(user, Web, "Visits", "HTTP")
    Rel(Web, Gateway, "Requestes data", "HTTP/Graphql")
    Rel(Gateway, User, "Requestes data", "HTTP/Graphql")
    Rel(Gateway, Blog, "Requestes data", "HTTP/Graphql")
    Rel(Gateway, Todo, "Requestes data", "HTTP/Graphql")

    BiRel(User, UserSql, "Read/write", "Prisma")
    BiRel(Blog, BlogSql, "Read/write", "Prisma")
    BiRel(Todo, TodoSql, "Read/write", "Prisma")

    Rel(User, Redis, "Read/write", "Bull MQ")
    Rel(Blog, Redis, "Read/write", "Bull MQ")
    Rel(Todo, Redis, "Read/write", "Bull MQ")
    BiRel(Worker, Redis, "Read/write", "Bull MQ")

    UpdateRelStyle(user, Web, $textColor="blue", $lineColor="black", $offsetX="-20", $offsetY="-40")
    UpdateRelStyle(Web, Gateway, $textColor="blue", $lineColor="black", $offsetX="-40", $offsetY="-40")

    UpdateRelStyle(Gateway, User, $textColor="blue", $lineColor="gold", $offsetX="-40", $offsetY="-40")
    UpdateRelStyle(Gateway, Blog, $textColor="blue", $lineColor="gold", $offsetX="-80", $offsetY="-40")
    UpdateRelStyle(Gateway, Todo, $textColor="blue", $lineColor="gold", $offsetX="-120", $offsetY="-40")

    UpdateRelStyle(User, UserSql, $textColor="blue", $lineColor="blue", $offsetX="-30", $offsetY="-60")
    UpdateRelStyle(Blog, BlogSql, $textColor="blue", $lineColor="blue", $offsetX="-30", $offsetY="-60")
    UpdateRelStyle(Todo, TodoSql, $textColor="blue", $lineColor="blue", $offsetX="-30", $offsetY="-60")


    UpdateElementStyle(UserSql, $bgColor="green")
    UpdateElementStyle(BlogSql, $bgColor="green")
    UpdateElementStyle(TodoSql, $bgColor="green")
    UpdateRelStyle(User, UserSql, $lineColor="green")
    UpdateRelStyle(Blog, BlogSql, $lineColor="green")
    UpdateRelStyle(Todo, TodoSql, $lineColor="green")

    UpdateElementStyle(Redis, $bgColor="orange")
    UpdateRelStyle(Worker, Redis, $lineColor="orange", $textColor="blue", $offsetX="-50")
    UpdateRelStyle(User, Redis, $lineColor="orange", $textColor="blue", $offsetX="-30")
    UpdateRelStyle(Blog, Redis, $lineColor="orange", $textColor="blue", $offsetX="0")
    UpdateRelStyle(Todo, Redis, $lineColor="orange", $textColor="blue", $offsetX="40")

    UpdateLayoutConfig($c4ShapeInRow="10", $c4BoundaryInRow="1")
Loading

Open editor