Skip to content

dorianneto/url-shortener

Repository files navigation

URL Shortner

Simple project architectured and designed to put into practice some of the concepts I've been lately studying, such as:

  • Clean Architecture
  • Go
  • Kubernetes

This is not a commercial project, it's for study purposes only

Running it

  1. $ go install
  2. $ docker compose up -d

API

Check this file for more details about the endpoints.

Note: you can install this extension in VSCode to test the endpoints.

Deploy

Coming soon...

Architecture

src
├── controller
│   └── redirect
│       └── input
├── database
│   ├── couchbase
│   ├── firestore
│   └── output
│       └── document
├── job
│   └── jobtest
├── model
├── queue
│   └── asynq
├── repository
└── validator

Architecture Layers

  • Infrastructure
    • Controller
    • Database
    • Queue
  • Application
    • Job
    • Repository
    • Validator
  • Domain
    • Model

Dependency Rule

Based on the princple, an inner layer should never rely on an outer layer so that circular dependencies are avoided as well as let the code more testable.

For instance, the jobs do not mention anything from the database clients.

Adapters

Interface Adapters are used in order to let the use cases and entities communicate with external services without coupling them.

Database

The clients for each supported database are designed with adapters and they are built based on a common interface called DocumentInterface.

The following databases are supported:

  • Firestore
  • Couchbase

In case you want to switch the database used by the application, all you have to do is to call the proper adapter in the main file:

database := couchbase.NewCouchbaseAdapter()
database := firestore.NewFirestoreAdapter()