I built an insurance management system so users can be able to define risk types, risk types and appropriate fields for the risk they want to insure
The API was created using Django Rest Framework, and the frontend was made with Vuejs, this project was hosted on AWS lambda using zappa
The database was made using MySQL to create a dynamic data model, the data base has five tables field_types, risk_types, fields, risks and fields_by_risk. So users can define both the risks types for their risks and also the field types for the corresponding fields in the database.
- https://github.com/idanwekhai/Product-Development-Hiring-Project/blob/master/docs/Model%20Diagram.JPG
- https://github.com/idanwekhai/Product-Development-Hiring-Project/blob/master/docs/my_project_subsystem.png
- The API was built using the community best practices and TDD oriented, with that, the API was fully tested. The API was created using the framework Django 2.1.2 and python 3.6.
- The frontend was built using the modern javascript framework Vuejs, HTML5, CSS3 / Sass.
- The app has three pages, one to make all CRUD API requests for Risk Types, one create the risks and their fields , and finally the main page, that get all risk fields and show them in a appropriate way.(Not Finsished)
- All form submissions were handled properly**(My Mega Bonus)**
Here are a few frontend screens:
- https://github.com/idanwekhai/Product-Development-Hiring-Project/blob/master/docs/screenshots/screenshot1.JPG
- https://github.com/idanwekhai/Product-Development-Hiring-Project/blob/master/docs/screenshots/screenshot2.JPG
- The App was deployed on AWS lambda using zappa
-
Clone this project;
$ git clone https://github.com/idanwekhai/Product-Development-Hiring-Project.git
-
populate the database with fixtures
$ cd backend $ pip install -r requirements.txt $ python manage.py syncdata
-
start the backend dev server
$ python manage.py runserver
-
start the frontend dev server
$ cd frontend $ yarn serve
-
Access
http://localhost:8080
to open the frontend orhttp://localhost:8000/api/v1
to open the API documentation.-
First create an account in AWS lambda
-
Goto IAM role in AWS dashboard
-
Nagivate to Users.
-
Click on the Security credentials tab, and go down to Access Key, note down the
access_key_id
.secret_access_key
is only visible when you are creating new user, so you need to note down both the access_key_id and secre_access_key at the time of user creation only. To generate a new access_key, click on thecreate access key
button,. -
Create a folder called
.aws
at the root level of the project$ mkdir .aws
-
Now, create a file called credentials and store the aws_access_key_id and aws_secret_access_key. The other specifics like default_region can also be stored. Firstly, to get the access credentials, do the following
###~/.aws/credentials [default] aws_access_key_id=[...] aws_secret_access_key=[...]
-
install zappa
$ pip install zappa
-
initialize zappa
$ zappa init
It will output something like this,
███████╗ █████╗ ██████╗ ██████╗ █████╗ ╚══███╔╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗ ███╔╝ ███████║██████╔╝██████╔╝███████║ ███╔╝ ██╔══██║██╔═══╝ ██╔═══╝ ██╔══██║ ███████╗██║ ██║██║ ██║ ██║ ██║ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ Welcome to Zappa! Zappa is a system for running server-less Python web applications on AWS Lambda and AWS API Gateway. This `init` command will help you create and configure your new Zappa deployment. Let's get started! Your Zappa configuration can support multiple production stages, like 'dev', 'staging', and 'production'. What do you want to call this environment (default 'dev'):
-
lastly
$ zappa deploy dev
make a database on AWS RDS and change the database settings in
settings.py
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'name of database', 'USER': 'user of database', 'PASSWORD': 'password for database', 'HOST': 'host name for database', 'PORT': '3306' } }
finally make another s3 bucket to server the static files and update
settings.py
again, add the required keys and bucket name........... # Add AWS_QUERYSTRING_AUTH = False # The AWS region to connect to. AWS_REGION = "region" # The AWS access key to use. AWS_ACCESS_KEY_ID = "key" # The AWS secret access key to use. AWS_SECRET_ACCESS_KEY = "key" AWS_STORAGE_BUCKET_NAME = "name of bucket" DEFAULT_FILE_STORAGE = STATICFILES_STORAGE = "django_s3_storage.storage.StaticS3Storage" AWS_S3_BUCKET_NAME_STATIC = AWS_STORAGE_BUCKET_NAME AWS_LOCATION = 'static' # These next two lines will serve the static files directly # from the s3 bucket AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME #STATIC_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN STATIC_URL = 'http://{!s}.s3.amazonaws.com/'.format(AWS_STORAGE_BUCKET_NAME) STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'staticfiles/'), ) STATIC_ROOT = os.path.join(BASE_DIR, 'static')
For questions or compliments, send me an email: [email protected]
-