Skip to content

Microservices and Microfrontends with 100% Pure Python and Domain Driven Design. Serverless Bottle.py for your stateless processes and a Preact client UI packaged as WebComponents using transcrypt.

License

sdaves/microthings

Repository files navigation

microthings

Microservices and Microfrontends with 100% Pure Python and Domain Driven Design. Serverless Bottle.py for your stateless processes and a Preact client UI packaged as WebComponents using transcrypt. https://microthings.netlify.com/

Badges

Status: Netlify Status

Deploy to Netlify

Simple Microfrontend (Client)

from mything.microfrontends.core import IHtml, IComponent, IFrontend

class HelloFrontend(IFrontend):    
    def __init__(self, html: IHtml, component: IComponent):
        self._html = html
        component.mount('mything-hello', ['name'], self)

    def view(self, props={'name':'Guest'}):
        return self._html.h('span', {}, 'Hello {0}!'.format(props['name']))

Transcrypt compiles this to hello.js and it can be included as a js module in the browser or nodejs.

Simple Microservice (Front Controller)

class Hello:
    def __init__(self, app):
        app.route('/hello')(self.hello)
        
    def hello(self):
        return 'Hello!'

if __name__ == '__main__':
    import bottle
    app = bottle.Bottle()
    Hello(app)
    app.run()

This microservice depends on only 1 external file to run: bottle.py. You can copy that file too when deploying, or just pip install bottle to install the latest.

Layered Architecture

Layered

  • Infrastructure layer
    • Client
      • Preact UI packaged as WebComponents using transcrypt
      • Mobile and Web Offline access using service workers
      • Runs on user devices
      • Calls remote REST stateless processes
      • Contains dependencies on specific infrastructure or packages
    • Front controller ( process in 12 factor app )
      • Bottle.py stateless processes as wsgi microservices
      • NARWAL REST with JWT secured auth
      • Runs on servers / serverless
      • Implements application service interfaces with IoC container
      • Creates api instance from IoC container and calls api services
      • Calls remote REST stateless processes
      • Contains dependencies on specific infrastructure or packages
  • Application layer
    • Emit IO with application service interfaces
    • Accepts builtin datatypes to api services
    • Creates model types / serializes / calls domain services
    • Decouples domain from infrastructure layer
    • Contains zero dependencies on specific infrastructure or packages
    • Zero Domain Business Logic
    • Mostly I/O Services
    • Use Case Backing Services
    • API
  • Domain layer
    • All Ubiquitus Language
    • Accepts only domain model types to domain services
    • Emit IO with repository interfaces
    • Some I/O Services and Some Pure
    • Use Case Business Logic
    • Contains zero dependencies on specific infrastructure or packages
    • Service
    • Repository
  • Model layer
    • No IO, pure Entities and Value Objects
    • Contains zero dependencies on specific infrastructure or packages
    • Model

Setup Requirements

  • Install git https://git-scm.com/downloads
  • Install Python 3.6 or greater with python3-venv https://www.python.org/downloads/

Setup on Linux

apt install -y git python3 python3-venv

Setup on Mac

brew install python3 git

Setup on Windows10

choco install python3 git

Setup development tools (using bash on all platforms)

git clone https://github.com/sdaves/microthings
cd microthings
python3 -m venv venv
source venv/bin/activate
pip install py-make
pymake setup # or make setup

Build

source venv/bin/activate
pymake # or make

Test

source venv/bin/activate
pymake test # or make test

Help

source venv/bin/activate
pymake help # or make help

About

Microservices and Microfrontends with 100% Pure Python and Domain Driven Design. Serverless Bottle.py for your stateless processes and a Preact client UI packaged as WebComponents using transcrypt.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages