Giter Site home page Giter Site logo

bansicloud / proton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 1x-eng/proton

0.0 1.0 0.0 99.69 MB

High-level python framework that facilitates rapid server-side development with clean & pragmatic design!

License: BSD 3-Clause "New" or "Revised" License

Dockerfile 0.97% Python 85.09% Shell 13.94%

proton's Introduction

PROTON Logo

PROTON

PROTON_build

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 and login routes to on-board & login users onto platform.
  • All of this, containerised!

Getting Started

PROTON init platform instructions

Features

  • PROTON comes with out-of-box support for Signup and Login.
  • Use /signup route to sign up users to platform. PROTON_postgres_signup
  • Did you want to use sqlite instead of postgres for a quick POC? No worries, just change the db_flavour in POST payload to 'sqlite' and you're taken care of!
  • PROTON also ships with support for edge conditions on these signup and login routes. For example - What happens if someone tries to signup with same email / username? PROTON_postgres_signup_validation
  • Use '/login' route to login after successful signup. PROTON_postgres_login
  • 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! PROTON_postgres_login_validation_invalid_username PROTON_postgres_login_validation_invalid_password
  • Did you say "What about monitoring & dashboards". Good! coz, PROTON ships with native support leveraging the mighty prometheus and beautiful grafana. PROTON_Prom_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. Proton_Prometheus
  • Did you want to see some beautiful dashboards alongside monitoring? Visit localhost:3000/proton-grafana in your favourite browser and login with default credentials:
    • username: admin
    • password: admin
    • You'll be prompted to change and choose your own strong password on first login. Proton_Grafana_1 Proton_Grafana_2
  • PROTON ships with 2 beast of dashboards by default.
    • Proton Monitor as the name suggests, delivers insights by monitoring PROTON stack. PROTON_Grafana_Monitor
    • Proton Stack - Holistic Monitor is another beautiful; at the same time very insightful dashboard that delivers insights around all containers that constitute PROTON. PROTON_Grafana_Cadvisor

The MIC stack - What, why & how?

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 PROTON_new_mic

    • what you see above is an API endpoint auto-generated for the MIC name you provided.
    • a get route, post route and concurrency route. Each demonstrating that same functionality as in their names, respectively.
    • GET call:
    • PROTON_get_call
    • POST call:
    • PROTON_post_call
    • And, if you wanted to target sqlite, just change db_flavour of your POST JSON payload to 'sqlite'.
    • PROTON_sqlite_post
    • GET call involving Concurrency / Multi-threading
    • PROTON_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 PROTON_new_custom_method

    • 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 PROTON_cproton_update

  • Time to check your shiny new route! PROTON_new_method_route PROTON_new_method_api_response

    • 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.,
  • Did you want to safe destroy a MIC and leave everything else untouched? Use PROTON's safe destruction mechanism PROTON_safe_destruction PROTON_post_safe_destroy

    • Notice how login and signup 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.
  • Stuck on a problem? Want to debug?

    • Did you want to view logs collectively? Go to ./PROTON/trace directory. PROTON_logs
    • Note that you can also view real time logs on the container level by issuing this command - docker logs -f proton
  • Also, PROTON ships with ability to automagically generate OpenAPI specs! PROTON_swagger_json PROTON_swagger_yaml

Features in active development:

  • 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.

Support

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.

Tags

  • 1.0.0 - PROTON GA,
  • Anything less than 1.0.0 - PROTON on-prem & PROTON alpha.

License

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.

proton's People

Contributors

1x-eng avatar poojapruthvi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.