当前位置:网站首页>Day8 - cloud information project introduction and creation
Day8 - cloud information project introduction and creation
2022-06-27 22:13:00 【laufing】
List of articles
Look back yesterday
1.Flask How the framework is configured across domains ?
2. What is the syntax for model creation ?
3. How to write a migration script ?
4. What are the migration commands ?
5.Flask How to create API, How to write restful Style API?
Today's content
1. Cloud information project product introduction ***
2.MVC Pattern and large project structure creation *****
3. Project initialization *****
4. Database design *****
1. Cloud information product introduction
1.1 Product introduction
# Product introduction
Cloud information is an integrated multi terminal technology information reading product , Similar to today's headlines , Provide users with science and technology news and information . The product is divided into the following terminals :
1. User side
Users can get news information from the client , With reading , Focus on , Comment on , Collection , Select the specified category channel and other functions , Sub movement web page , APP End etc. .
2. From the media side
We media end is used by we media workers , Provide information published by authors of our media , Edit information , The platform for viewing the operation data of we media number
3.MIS Management backstage
MIS The management background is the background for the operation and management of cloud information product companies , User management is available , Article review and management , Comment management, etc
1.2 Product technical architecture design
# Technical architecture design
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-9M25DoGG-1656156686772)(images/8-1.png)]
1.3 Description of personnel organization and development cycle
# Description of the organizational structure and development cycle of the developer
- The product manager : 1 people
- UI Design : 1 people
- front end : 2 people
- APP Development : 1 people
- Vue Development : 1 people
- Web Back end : 2 people
- test : 1 people
# The development cycle : 24 God
2.MVC Design patterns and large project structures
2.1MVC Design patterns
# Design patterns
What is design pattern ? What design patterns have you learned ?
1. What is design pattern :
Design patterns are created by GoF First of all , Design patterns are solutions to specific problems .
2. Common design patterns :
The singleton pattern , Facade mode , MVC Pattern , Factory mode
# MVC Pattern
MVC A pattern is a model - View - Controller design mode .
MVC It's not just a software pattern that implements the user interface , It is also an easy to modify and maintain architecture . MVC The national principle of the model is as follows :
Models provide data and business logic ( How to store and query information ), The view is responsible for displaying the data ( How to present ), The controller is the glue between the two , Coordinate the model and view according to the presentation required by the user .
MVC The flow of the pattern is shown in the figure below :8-2
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-DsXrPJvH-1656156686773)(images/8-2.png)]
2.2 Large project structure
project # General catalogue of the project
common # General catalog
cache # The cache directory
models # Model catalog
settings # Profile directory
utils # Tool class script Directory
project # Project inner Directory
resources # Blueprints source directory
schedule # List of scheduled tasks
tests # Test file directory
main.py # Master file
mis # mis Service catalog
im # im Service catalog
README.md # Documentation
requirments.txt # Dependency list
3. Project initialization operation
# Project initialization :
1. Create a configuration
2. Create database connection object
3. Create test blueprints
4. encapsulation APP: Load the configuration , Registered blueprint , db binding , Cross domain configuration , establish api object
5. Master file main.py To write , And run the project
6. Test the access of blueprint route
3.1 Configure class construction
# 1. Project configuration class build : stay settings Create default.py
class DefaultConfig(object):
""" Flask The default configuration """
# flask-sqlalchemy Parameters used
SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]:3306/cloudnews'
SQLALCHEMY_TRACK_MODIFICATIONS = False # Tracking data modification signals
SQLALCHEMY_ECHO = True
3.2 database db objects creating
# 2. database db objects creating : models Under the __init__.py file
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
3.3 Creation of blueprints
# 3. Creation of blueprints : resources Create bptest Blueprint folder , And create bpt Blueprints are tested
from flask import Blueprint
from flask_restful import Api, Resource
tbp = Blueprint('tbp', __name__)
api = Api(tbp)
class TestResource(Resource):
def get(self):
return 'bp_test'
api.add_resource(TestResource, '/test')
3.4APP encapsulation
# 4. encapsulation APP: stay cloudnews Under folder __init__.py Create factory function encapsulation in APP
from flask import Flask
from cloudnews.resources.bptest.bpt import tbp
from common.models import db
from flask_restful import Api
from flask_cors import CORS
def create_flask_app(config):
app = Flask(__name__)
# Load the configuration
app.config.from_object(config)
# Registered blueprint
app.register_blueprint(tbp)
# db Object binding app
db.init_app(app)
# Cross domain configuration
cors = CORS(app, resources={
r"/api/*": {
"origins": "*"}})
# establish api object
api = Api(app)
return app
3.5db binding APP Register with blueprint
# 5.db binding APP Register with blueprint
# Registered blueprint
app.register_blueprint(tbp)
# db Object binding app
db.init_app(app)
3.6 Cross domain configuration and API introduce
# 6. Cross domain configuration and API introduce
# Cross domain configuration
cors = CORS(app, resources={
r"/api/*": {
"origins": "*"}})
# establish api object
api = Api(app)
# 7. Master document preparation
import os
import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(BASE_DIR)
sys.path.insert(0, BASE_DIR)
#
from cloudnews import create_flask_app
from common.settings.default import DefaultConfig
app = create_flask_app(DefaultConfig)
if __name__ == '__main__':
print(app.url_map)
app.run()
# 8. test run : function main.py
Use postman visit : http://127.0.0.1:5000/test
Respond to : bp_test Indicates that the project is running normally
4. Database design
4.1 Database design method
# Database design issues
The first thing at the beginning of the project is the design of data , The quality of database design directly affects the progress of the project . The design of database is mainly from the following aspects
- Table structure design
- Field type selection , Is it allowed to be empty , Whether there are constraints such as default values
- Index design
- The choice of database engine
# Database design basis
Before the database design, it was not imagined out of thin air , It is based on the analysis and design of the product prototype . Therefore, the product prototype should be provided before the database design , Members design the database according to the product prototype , UI According to the product prototype design UI Interface .
The front end and back end get the product prototype , It can be developed at the same time . The constraints developed at the same time between the front end and the back end are the excuse documents . The two parties shall work separately , Unified in the interface , Finally, carry out front and rear end joint commissioning and test , Finally online , Keep iterating .
4.2 Table structure analysis
Cloud information includes three terminals , We are based on users pc End as an example for database design .
(1). Table analysis
# 1. The login page : The user login
User table

# 2. home page : All channels , User channel , Information list
Channel table
User channel table ( A user can follow multiple channels , A channel can be watched by multiple users --> Many to many )
Information sheet


# 3. Information details page : Focus on , Comment on , Collection , give the thumbs-up ( It belongs to information )
Focus on ( Concern and be concerned , Many to many --> The third form )
Comment table
Collection table ( One can collect a lot , A piece of information can be collected by many people --> The third form )
Like the watch

# 4. Search page :
Search history table
# summary :
1. User table
2. Channel table
3. User channel table ( The third form )
4. Information sheet
5. Focus on the table ( The third table between users )
6. Comment content table ( Set the foreign key associated user )
7. Collection table ( The third table between users and information )
8. Comments and likes
9. Search history table ( Set the foreign key associated user )
4.2 Table field analysis
# 1. User table
Field name Field type constraint describe
uid Integer primary_key user ID
mobile String cell-phone number
password String password
user_name String nickname
profile_photo String Head portrait
last_login DateTime Last login time
is_media Boolean default Whether it is we media
is_verified Boolean default Real name authentication
introduction String brief introduction
certificate String authentication
article_count nteger default posts
following_count Integer default Number of people concerned
fans_count Integer default The number of people being watched ( Number of fans )
like_count Integer default Cumulative number of likes
read_count Integer default Cumulative number of readers
account String(32) account number
email String(64) mailbox
status db.Integer default state , Is it available
# 2. User focus table
Field name Field type constraint describe
user_id Integer ForeignKey,primary_key user ID
foller_id Integer ForeignKey,primary_key fans ID
relation Boolean state (1, Focus on ;0, Cancel )
create_time DateTime default Creation time
update_time DateTime default Update time
# 3. Channel table
Field name Field type constraint describe
cid Integer ForeignKey,primary_key channel ID
name String name
is_delete Boolean default state (1, You can use ; 0, Unavailable )
sequence Integer default Serial number
# 4. User channel table
Field name Field type constraint describe
id Integer User channel ID
uid Integer ForeignKey,primary_key user ID
cid Integer ForeignKey,primary_key channel ID
# 5. Information sheet
Field name Field type constraint describe
nid Integer primary_key article ID
user_id Integer ForeignKey user ID
channel_id Integer ForeignKey channel ID
title String(64) title
cover String(32) cover
ctime DateTime default Creation time
comment_count Integer default comments
good_count Integer default Number of likes
read_count Integer default Reading volume
is_allow_comment Boolean default Whether to allow comments
utime DateTime default Update time
content Text The content of the post
# 6. Comment table
Field name Field type constraint describe
cmid Integer primary_key Comment on ID
user_id Integer ForeignKey user ID
article_id Integer ForeignKey article ID
parent_id Integer Comments commented on id
like_count Integer default Number of likes
reply_count Integer default Number of replies
content String(128) Comment content
is_top Boolean default Whether it's at the top
status Integer default Comment status
ctime DateTime default Creation time
# 7. Collection table
Field name Field type constraint describe
collect_id Integer primary_key Primary key
user_id Integer ForeignKey,primary_key user ID
news_id Integer ForeignKey,primary_key information ID
is_delete Boolean state (1, Focus on ;0, Cancel )
边栏推荐
- 【MySQL】数据库函数通关教程下篇(窗口函数专题)
- [LeetCode]572. A subtree of another tree
- ∫(0→1) ln(1+x) / (x ² + 1) dx
- [MySQL] database function clearance Tutorial Part 2 (window function topic)
- This set of steps for performance testing using JMeter includes two salary increases and one promotion
- [LeetCode]30. 串联所有单词的子串
- QT large file generation MD5 check code
- Stm32f107+lan8720a use stm32subemx to configure network connection +tcp master-slave +udp app
- 哈希表-数组之和
- 我想我要开始写我自己的博客了。
猜你喜欢
管理系统-ITclub(中)
Go from introduction to actual combat - execute only once (note)
[MySQL] database function clearance Tutorial Part 2 (window function topic)
【MySQL】数据库函数通关教程下篇(窗口函数专题)
Bit. Store: long bear market, stable stacking products may become the main theme
Common problems encountered by burp Suite
使用Fiddler模拟弱网测试(2G/3G)
Simulink导出FMU模型文件方法
Professor of Tsinghua University: software testing has gone into a misunderstanding - "code is necessary"
I think I should start writing my own blog.
随机推荐
开源技术交流丨一站式全自动化运维管家ChengYing入门介绍
Codeforces Round #717 (Div. 2)
管理系统-ITclub(中)
Experience sharing of meituan 20K Software Test Engineers
[LeetCode]572. 另一棵树的子树
清华大学教授:软件测试已经走入一个误区——“非代码不可”
Acwing week 57 longest continuous subsequence - (binary or tree array)
Codeforces Round #719 (Div. 3)
Fill in the blank of rich text test
Go from introduction to actual combat - task cancellation (note)
[MySQL] database function clearance Tutorial Part 2 (window function topic)
使用sqlite3语句后出现省略号 ... 的解决方法
C语言程序设计详细版 (学习笔记1) 看完不懂,我也没办法。
Read write separation master-slave replication of MySQL
regular expression
Gao fushuai in the unit testing industry, pytest framework, hands-on teaching, will do this in the future test reports~
Management system itclub (Part 2)
Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager
深度学习又有新坑了!悉尼大学提出全新跨模态任务,用文本指导图像进行抠图
GBase 8a OLAP分析函数cume_dist的使用样例