go-api-multitenant

command module
v0.0.0-...-a8c180d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2023 License: MIT Imports: 4 Imported by: 0

README

CRUD Golang API Multitenancy MongoDB Fiber

Requirements
  • Go installed in the system
  • A running instance of postgres db
  • Update the .env file with the postgres path, db and credentials

Run the following command:

go run main.go
Technologies used
  • Fiber
  • MongoDB
App Flow
  1. App creates Server.
  2. Server create Middeware and routes.
  3. Server receive request.
  4. Middleware find or create tenant dependencies (Service, Repository, Database).
  5. Middleware attach tenant dependecies at the request.
  6. Controller get tenant dependecies.
  7. Controller use Service dependency.
  8. Service use Repository dependency.
  9. Repository use Database repository.
  10. Database use tenant database.

UML diagrams

Components
graph LR
Serv(Server)  --> 
M(Middlewares) -->
DI(Dependencies) -->
C(Controllers) --> 
Svc(Services) --> 
R(Repository) -->
D(Database)
Sequence
sequenceDiagram
Server ->> Middleware: 
Middleware ->> Dependencies: 
Dependencies -->> Dependencies: 
Note right of Dependencies: Find or Create <br/> a tenant dependecies <br/> only if configured
Dependencies ->> Middleware: 
Middleware ->> Controller: 
Controller ->> Service: 
Service ->> Repository: 
Repository ->> Database: 
How Use

Configure the configurations.json file to connect to differents database per tenant.

Use the request.http to know how send request to api.

The data field can contains any schema of JSON, the api save and get without problems.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
src

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL