How ngodinhtruong/ptud-gk-de-1 works
Main Components
• Client/User Interface: Represents the users’ browsers interacting with the web application. It sends HTTP requests to the server and renders HTML responses. Note that the client-side uses responsive HTML templates (located in the “templates” directory) along with CSS (under “static/css”) and potentially JavaScript.
• Web Server/Backend: The central component is the Flask application (app.py), which handles routing, request processing, session management (via Flask-Login), and form handling (via Flask-WTF). This component also manages the business logic for blog posts, user management, and comments.
• Database: The SQLite database (blog.db located inside the “instance” folder) is the data layer for persistent storage of blog content, comments, and user data.
• Auxiliary/Setup and Configuration: The requirements.txt and setup.bat provide the dependencies and installation scripts for setting up the environment.
Relationships and Data Flows
• The Flask server processes these requests by routing to various endpoints – for example, endpoints for viewing the index, signing in, signing up, posting a new blog, viewing details of a blog post, and dashboard statistics.
• Static assets (CSS, images) and HTML templates are served to the client for rendering the UI.
Architectural Patterns & Design Principles
• MVC-Like Pattern: Although not formally separated into MVC folders, you still have a separation of concerns where routes (in app.py) act as controllers, HTML templates as views, and the SQLite database as the model.
• Single Application File: Notice that the application logic is centralized in app.py, indicating a monolithic architecture typical for small Flask applications.
• Role-Based Authentication: The application distinguishes users by roles (Actor vs. User), which should be noted in the component that handles authentication and authorization logic (via Flask-Login).
Relevant Technologies, Frameworks, and Libraries
• Backend: Flask, Flask-Login, Flask-WTF.
• Database: SQLite.