This document explains the architecture of the current stage of the Tornado-based blogging web application.
@@ -135,80 +135,6 @@ The database schema is defined in `schema.sql` (presumably includes tables like
-**Scalable Deployment**:
- Dockerized environment ensures consistency and ease of deployment.
## Visualization of This Stage
```mermaid
graph TD
subgraph Application
TornadoServer["Tornado Server"]
Templates["HTML Templates (Jinja-like)"]
StaticAssets["Static Assets (CSS/JS)"]
end
subgraph Database
PostgreSQL["PostgreSQL Database"]
end
subgraph Docker
BlogService["Blog Service (Python/Tornado)"]
DatabaseService["Database Service (PostgreSQL)"]
end
User["User"] -->|HTTP Requests| TornadoServer
TornadoServer -->|Renders| Templates
TornadoServer -->|Serves| StaticAssets
TornadoServer -->|Async Queries| PostgreSQL
TornadoServer -->|Renders| Responses
BlogService -->|Links To| DatabaseService
TornadoServer -->|Port 8888| BlogService
PostgreSQL -->|Port 5432| DatabaseService
```
---
This architecture provides a solid foundation for building a more complex web application. Future enhancements might include additional user roles, improved UI, or REST API support.
## Additional Notes
Enter the postgres database container using,
```bash
docker exec-it tornado-backend_postgres_1 psql -U blog -d blog
This configuration does not define any volume for the PostgreSQL service so if the container is removed or recreated the data will be lost. To make the data persistent use add a volume mapping to the postgres service in the docker compose file, e.g.,
```yml
volumes:
-postgres_data:/var/lib/postgresql/data
```
Note, the exposer of port 3306 is probably a mistake. The PostgrSQL default port is 5432 which is also used in `./tornado-backend/blog.py` to connect to the database.
Note also, the python image used installs tornado version 6.2, thus the `set_secure_cookie` and `get_secure_cookie` instead of `set_signed_cookie` and `get_signed_cookie` used in `./tornado-backend/blog.py`. The naming of these methods changed with tornado version 6.3. This is another mistake in the blog demo on GitHub. ([see](https://www.tornadoweb.org/en/stable/web.html#))
@@ -61,24 +68,36 @@ Note also, the python image used installs tornado version 6.2, thus the `set_sec
```mermaid
graph TD
subgraph Blog Service
TornadoServer["Tornado Server"]
%% External user
User["User (Web Browser)"]
%% Docker network
subgraph Docker_Network["Docker Network"]
%% Blog Container
subgraph BlogContainer["Blog Container"]
TornadoServer["🐍 Tornado Web Server"]
Templates["HTML Templates (Jinja-like)"]
StaticAssets["Static Assets (CSS/JS)"]
end
subgraph Database Service
PostgreSQL["PostgreSQL Database"]
%% Database Container
subgraph DBContainer["PostgreSQL Container"]
PostgreSQL["🐘 PostgreSQL Database"]
Volume["📦 Data Volume (Not Persistent Storage Here!)"]