Skip to content

alireza01100011/Arash-Blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arash Blog

Content management system with Flask


My goal in this project is just to have fun and learn new things, that's why I think it needs extensive optimizations. I hope that my time will help me and I can optimize this project and solve its various problems, I will be very happy if you take a look at the codes and make them better, thank you, friend.

[note: Basic optimizations in the database section, especially website information, must be done]

Images of the software environment:

HomePage



Posts-Page Post-Page

Profile-Page AdminPanel-Page



Description and purpose of this project


English :

This project is a blog with common features and obvious and hidden weaknesses!

The goal of this project is to create a medium-sized project with Flask, and at this stage, without security developments,
 it is not ready to be used in a high-risk production environment.
(Here I mean high-risk areas where hackers are constantly trying to hack your service)

But yes, it can be used for normal environments!

I am trying to create a regular update cycle to continuously make the code better and safer!

I would be happy if you look at the codes and help me! thanks a lot


Persian:

این پروژه یک وبلاگ با امکانات رایج و نقطه ضعف هایی اشکار و پنهان است !

هدف این پروژه پیدا سازی یک پروزه متوسط با فلسک بوده و در این مرحله بدون توسعه هایی امنیتی آمادگی استفاده در محیط پروداکشن پر خطر رو را نداره 
(در اینجا منظور من از پر خطر حوضه هایی است که هکر ها مدام قصد هک کردن سرویس شما رو دارن )

اما برای محیط های معمولی بله میشه استفاده کرد !

من دارم سیع میکنم یک سیکل اپدیت منظم ایجاد کنم تا به صورت مستمر کدهارو بهتر و امن تر کنم !

خوشحال میشم شما هم به کدها نگاهی کنید و به من کمک کنید! خیلی ممنونم 



Technical


Technologies used in this WebApplication (docker-compose) :



Database Models


Note : 
  ORM (flask-sqlalchemy) is used to communicate with the database.
  In the version (0.9), I adapted the codes related to the database with MySQL,
    before that I used to develop the project with SQLlite.

I tried my best to use the relationships in the database optimally, but I believe there are better solutions!
I would be happy if you have any comments...





Tables (SITE, INDEXPAGE)


Tables (SITE) and (INDEXPAGE) are used for website settings. I know this method is like a joke,
 but I will soon replace it with another method and these tables will be deleted!

Databse-SettingSite

Tables (The rest of the tables)

The rest of the tables are essential tables

File address: './Docts/DataBaseModel.drawio'

Databse

Simple execution model in Docker

In this image, I tried to simplify the Docker Compose file for modern development.

It is quite obvious that you can create a more complex structure with multiple instances of a container and
 make the application scalable, as I have tried to make this possible.

An example of my effort:
 creating a common space for storing application files (user and media profiles) see all examples and web server (nginx)
   "because these files are handled by nginx to optimize traffic"

File address: './Docts/SimpleDocker.drawio'

Dacker

Use and setup

Common steps :

  • Download the latest version of the software Click here
  • CD To Directory, './Application'
  • Copy .env.example to .env
  • Configure the .env file
    • "Almost all settings are in this file"

Docker-Compose (recommendation):

note : The engineering settings in Docker Compose are in this direction : ./Application/Docker/nginx.conf.template

  • $docker-compose up -d

  • Database migration:

    • Creating tables in the database :
    • $ docker exec {Application_Name} bash -c "python3 manage.py create-db"
    • Create the first admin user :
    • $ docker exec {Application_Name} bash -c "python3 manage.py create-admin {FullName} {Email} {PassWord}"

    note : Application_Name = container-id or ($APP_CONTAINER_NAME in to .env)


Without Docker:

  • Start a MySQL

  • Start a Redis

  • Start a Nginx

  • Configure the .env file

  • Database migration:

    • Creating tables in the database :
    • $python3 manage.py create-db
    • Create the first admin user :
    • $python3 manage.py create-admin {FullName} {Email} {PassWord}
  • Run the project with (gunicorn).

    • $gunicorn -b '{IP}:{PORT}' app:app
  • Configure your service nginx : The goal is a reverse proxy to our (gunicorn) and other settings.

  • Restart service Nginx


⚠️ My recommendation is to use Docker-Compose to run !


In the future, the documentation will be more and more detailed ....