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]
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:
این پروژه یک وبلاگ با امکانات رایج و نقطه ضعف هایی اشکار و پنهان است !
هدف این پروژه پیدا سازی یک پروزه متوسط با فلسک بوده و در این مرحله بدون توسعه هایی امنیتی آمادگی استفاده در محیط پروداکشن پر خطر رو را نداره
(در اینجا منظور من از پر خطر حوضه هایی است که هکر ها مدام قصد هک کردن سرویس شما رو دارن )
اما برای محیط های معمولی بله میشه استفاده کرد !
من دارم سیع میکنم یک سیکل اپدیت منظم ایجاد کنم تا به صورت مستمر کدهارو بهتر و امن تر کنم !
خوشحال میشم شما هم به کدها نگاهی کنید و به من کمک کنید! خیلی ممنونم
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) 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 Databse-SettingSite](https://private-user-images.githubusercontent.com/95130614/309919851-d4114cad-8a6e-4c89-a32f-c7fb810b5f86.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NTM1MTQsIm5iZiI6MTczODk1MzIxNCwicGF0aCI6Ii85NTEzMDYxNC8zMDk5MTk4NTEtZDQxMTRjYWQtOGE2ZS00Yzg5LWEzMmYtYzdmYjgxMGI1Zjg2LmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxODMzMzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mZTQyOGJjMmI4MTdkNWJmZjRjYThjM2IxMDE2MzBlOWI2MWQ1YjkwMTI0ZTRmNjlmYWQ0Nzc4OTdjOTlkMmI0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.UrFaLgty9HJpVFCFToDuyKmQPt7JKpHgRMRb0oM2ceA)
The rest of the tables are essential tables
File address: './Docts/DataBaseModel.drawio'
![Databse Databse](https://private-user-images.githubusercontent.com/95130614/309919841-4c8427d5-8aae-48be-b3cf-a4f9cd21567f.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NTM1MTQsIm5iZiI6MTczODk1MzIxNCwicGF0aCI6Ii85NTEzMDYxNC8zMDk5MTk4NDEtNGM4NDI3ZDUtOGFhZS00OGJlLWIzY2YtYTRmOWNkMjE1NjdmLmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxODMzMzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNjk3NmNlMDM4MTQyNmRhNmZkZjE1ODYwZGU5OGJlZTlhZGFmNmVkYWNhYWEzMjJiNzUyOGViNzg5NmQ2MDJlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9._fGA6LZ17R1AmO7Ct3RmTr82AH4-f72LxLPYvQNRSUY)
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 Dacker](https://private-user-images.githubusercontent.com/95130614/309919834-9518b90c-4ead-4880-8b69-1a3d5711b0f3.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NTM1MTQsIm5iZiI6MTczODk1MzIxNCwicGF0aCI6Ii85NTEzMDYxNC8zMDk5MTk4MzQtOTUxOGI5MGMtNGVhZC00ODgwLThiNjktMWEzZDU3MTFiMGYzLmpwZWc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxODMzMzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNjEyZTU3Y2FmMmNkYzA3NGM3MGQ1NzFlMDgyY2MyYTRhYTA2MzRhZTlhZGFkNTBiZWU1N2Y2MDg2MjMzNmMwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.kvInt768FgGiri7KjmwdqmwObJGQT3fCD8qkGs0NmnU)
- 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"
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)
-
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
In the future, the documentation will be more and more detailed ....