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/
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.
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.
- 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
- Client
- 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
- Install git
https://git-scm.com/downloads
- Install Python 3.6 or greater with python3-venv
https://www.python.org/downloads/
apt install -y git python3 python3-venv
brew install python3 git
choco install python3 git
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
source venv/bin/activate
pymake # or make
source venv/bin/activate
pymake test # or make test
source venv/bin/activate
pymake help # or make help