HsnVahedi / engineerx-backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EngineerX Backend Microservices

Report bug · Request feature

Table of contents

Introduction to EngineerX Project

EngineerX is an open source web application designed for engineers and specialists. It lets them share their ideas, create tutorials, represent themselves, employ other specialists and ...

Currently, The project is at it's first steps and includes a simple but awesome Content Management System (CMS) that lets content providers to create and manage blog posts.

Key features of the project:

  • It's cloud native and can easily get deployed on popular cloud providers like (AWS, Azure and ...)
  • It benefits from microservices architectural best practices. It uses technologies like docker and kubernetes to provide a horizontally scalable infrastructure with high availability.
  • It includes a wide range of popular development frameworks and libraries like: django, reactjs, nextjs, wagtail and ...
  • It benefits from TDD best practices and uses unittest, jest, react-testing-library and cypress for different kinds of tests.
  • It uses Jenkins declarative pipeline syntax to implement CI/CD pipelines. (Pipeline as code)
  • Developers are able to write different kinds of tests and run them in a parallelized and non-blocking manner. In other words, testing environment is also elastic and scalable.
  • It uses Terraform to provision the required cloud infrastructure so it's really easy to deploy the whole project and destroy it whenever it's not needed any more. (Infrastructure as code)
  • It's built on top of wagtail. Wagtail enables django developers to have a professional headless CMS which can be customized for many types of businesses.

Backend Microservices

This repository contains the project's backend microservices. The most important microservice is a django project located here, which is created by wagtail.

Wagtail has many built-in features including Elastic Search integration. To see all of wagtail's built-in features, check this out.

Here is our blog's PostPage which inherits wagtail's Page:

class PostPage(Page):
    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    sections = StreamField(SectionsBlock())
    tags = ClusterTaggableManager(through=TaggedPost, blank=True)

    api_fields = [
        APIField('image', serializer=ImageRenditionField('min-1500x200')),
        APIField('image_16x9', serializer=ImageRenditionField('fill-1600x900-c70', source='image')),
        APIField('sections'),
        APIField('tags'),
        APIField('owner_info'),
    ]

    content_panels = Page.content_panels + [
        ImageChooserPanel('image'),
        StreamFieldPanel('sections'),
        FieldPanel('tags')
    ]
    ...

The page model has a few fields:

  • sections: Contains page's content. Check Wagtail's StreamField Documentation to know more about it's amazing features.
  • api_fields: These read-only fields are required to expose page's information through REST api.
  • content_panels: These panels are used by wagtail to create an appropriate django form for creating/editing the page.

Run Development Environment

1. Clone this repository:

git clone https://github.com/HsnVahedi/engineerx-backend

2. Build the docker image:

cd engineerx-backend/engineerx
docker build . -t engineerx-backend-django:latest

3. Run the docker container and publish it's port:

docker run -it -p 8000:8000 engineerx-backend-django:latest bash

4. Create development database:

python manage.py makemigrations && python manage.py migrate

5. Initialize the database with randomly generated objects:

mkdir media && mv -vn downloads/ media/downloads/
python manage.py initdb

6. Create an admin user:

python manage.py createsuperuser

7. Start the development server:

python manage.py runserver 0.0.0.0:8000

Now you can see the project is running on 127.0.0.1:8000/. Now go to 127.0.0.1:8000/admin and login if required.

Run Production Environment

1. Clone this repository:

git clone https://github.com/HsnVahedi/engineerx-backend

2. Pull the required docker images:

cd engineerx-backend
docker-compose pull

3. Start the production server:

docker-compose up

4. Now open another terminal and execute this python manage.py initdb in the django container:

docker-compose exec backend python manage.py initdb

5. Create an admin user:

docker-compose exec backend python manage.py createsuperuser

Now you can see the project is running on 127.0.0.1:8000/. Now go to 127.0.0.1:8000/admin and login if required.

EngineerX code repositories

EngineerX project consists of several code bases:

About


Languages

Language:Python 73.0%Language:HTML 13.2%Language:Shell 7.6%Language:CSS 4.0%Language:Dockerfile 2.3%