The MIC stack genesis!
PROTON is a high-level Python framework that facilitates rapid server-side development with clean & pragmatic design. Thanks for checking it out!
- PROTON aims at easing server-side development for all Python enthusiasts.
- With PROTON, as a developer you issue one command; one command, to spin up auto generated code with pragmatic separation of Model, Controller and Interface (Hence the name, MIC stack)!
- One command to setup a production ready server side stack with managed DB connections (PROTON ships with postgresql), managed caching (PROTON ships with redis), managed JWT authenticated routes, descriptive logging, managed monitoring (Prometheus & Grafana) and auto-generated openAPI specs.
- PROTON also ships with
signup
andlogin
routes to on-board & login users onto platform. - All of this, containerised!
- Install docker on your development machine.
- Clone PROTON to your desired location
git clone https://github.com/PruthviKumarBK/PROTON.git
- Change directory to PROTON
cd ~/PROTON/
./cproton.sh -U yes
PROTON will ask your input for few key environment variables.- Wait for the platform to bootstrap; once done, visit
http://localhost:3000
. - Congratulations. you've got your server-side setup!
- PROTON comes with out-of-box support for
Signup
andLogin
. - Use
/signup
route to sign up users to platform. - Did you want to use
sqlite
instead of postgres for a quick POC? No worries, just change thedb_flavour
in POST payload to 'sqlite' and you're taken care of! - PROTON also ships with support for edge conditions on these
signup
andlogin
routes. For example - What happens if someone tries to signup with same email / username? - Use '/login' route to login after successful signup.
- Did you observe the
token
post successful login? That one command to setup the platform has prepared JWT Token Authentication! Reckon that is pretty cool! - And, if you did not already expect, PROTON ships with login validation. Of course!
- Did you say "What about monitoring & dashboards". Good! coz, PROTON ships with native support leveraging the mighty prometheus and beautiful grafana.
- Once you've initialized the platform, visit
localhost:3000/proton-prom
in your favourite web browser and you'll have mighty prometheus welcoming you. - Did you want to see some beautiful dashboards alongside monitoring? Visit
localhost:3000/proton-grafana
in your favourite browser and login with default credentials: - PROTON ships with 2 beast of dashboards by default.
We all know about classic MVC don't we. What happens when we substitute the 'V' in 'MVC' with an 'I' <Application Program Interface> ? - We get a MIC stack! PROTON is a platform that facilitates rapid API development (the MIC stack) backed by auto-generated code and good object-oriented programming principles.
Why do we need this despite many zillion frameworks?
- Do you enjoy writing; rather, re-writing same boiler plate code everytime you wanted to generate a new API using the framework of your choice?
- Do you enjoy managing database connectivity and dealing with connectivity issues everytime you touch codebase?
- Do you enjoy learning from an expert that your server side needs performance tuning and miss cache?
- Do you enjoy not having an organized logging mechanism in your server-side code?
- Do you enjoy not having authentication mandated for your server-side codebase?
- Do you enjoy being stressed about converting your codebase to be container ready?
- Do you enjoy being paranoid about steep learning curve associated with Kubernetes?
I've been coding for a living since the last 10 years and for each question above, ** I answer NO even in my dreams**. Do you agree? Did you want a framework that rather managed all these for you so you could worry only about building interesting software rather worry about these classic elements?
I hear screaming YES!
PROTON is your answer! One command, all your above problems sorted and managed for you! With PROTON, you're a step closer to be that unicorn or 10x developer or whatever else you call that!
Working on a quick prototype to impress or thinking of production deployments - do check out PROTON.
Now that you are interested, see how you get PROTON to work for you:
-
Generate new API (you can do all CRUD ops on that API) by issuing one command
./cproton.sh -n myNewApi
- what you see above is an API endpoint auto-generated for the MIC name you provided.
- a
get
route,post
route andconcurrency
route. Each demonstrating that same functionality as in their names, respectively. - GET call:
- POST call:
- And, if you wanted to target sqlite, just change
db_flavour
of your POSTJSON
payload to 'sqlite'. - GET call involving Concurrency / Multi-threading
-
- Notice how first call took about 1 second (if not for multi-threading, this takes about 5 seconds) and subsequent calls took only 25~35ms. This is because of cache supporting all subsequent calls.
-
Your next question should be, how to generate new API's to my heart's content?
-
Find
controller
for your respective MIC where you want new method and just define a new function encapsulating your business logic- Look into lines 230-270. This is where you define your new methods.
- Line 275 is where you include your new method.
- Did you notice how the query parameter is passed into your SQL? That is SQL Injection Safe by the way!
-
Done coding? You have now tell PROTON to include your method and generate API route. Do that by issuing this command:
./cproton.sh -s yes
-
Time to check your shiny new route!
- Notice how the route considers
id
as a query parameter and results comply to this query parameter. - Results from this route also automatically get the best of PROTON in terms of cache support, logging etc.,
- Notice how the route considers
-
Did you want to safe destroy a MIC and leave everything else untouched? Use PROTON's safe destruction mechanism
- Notice how
login
andsignup
routes remain unaffected. Similarly, if there were other MIC stacks and you destroyed one of them, all others remain as is; unaffected. - Always destroy using PROTON's safe destruction mechanism. If otherwise, you will disturb the platform in its sensitive nerves which brings the house down. Also, by using safe destruction, all associated code attached to that respective MIC and cache entries will be pragmatically cleaned.
- Notice how
-
Stuck on a problem? Want to debug?
-
Also, PROTON ships with ability to automagically generate OpenAPI specs!
- 100% test coverage and auto-generated test cases for every new API generated using PROTON stack.
- Auto-generated HELM charts and one click deploy onto GCP's GKE & AWS' EKS.
- Pipelines to transfer form and to datawarehouse to database. Support for GCP's bigQuery and AWS's RedShift in progress.
- Auto generated Swagger UI from PROTON generated openAPI specs.
For any feedback or issues write to Pruthvi @ [email protected]. Ensure to have a valid subject line, detailed message with appropriate stack trace to expect prompt/quick response.
- 1.0.0 - PROTON GA,
- Anything less than 1.0.0 - PROTON on-prem & PROTON alpha.
BSD 3-Clause License
Copyright (c) 2018, Pruthvi Kumar All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.