Under the Hood of My Website: From Python to Interactive Maps

Many of you visit this site to browse interactive maps, read articles on ecology, or review research findings. You see the final product – the pages, the data, the visualizations. But perhaps you've wondered what's going on behind the scenes. What technological magic keeps it all running 24/7?

In this article, I want to give you a brief tour "under the hood" of this project. It’s a story not just about tools, but about the philosophy behind their selection.

The Philosophy of Choice: A Bet on Reliability and Flexibility

When it came time to create the site, I could have taken the easy route and used a ready-made website builder. However, for a scientific project where customization, data control, and the ability to integrate specific tools (like GIS) are crucial, a more flexible approach was needed.

My choice was to build the application from scratch. This allows me to be independent of platform limitations, optimize performance, and be confident that the system works exactly as I intended.

The Heart of the Project: What Makes It All Work

The site is built on a set of technologies from the Python world, all tested by time and a vast community.

The Brain of the Operation: Python and Flask

At the core of everything is Python, a programming language known for its simplicity and power, especially in data analysis and scientific computing.

For the web application's framework, I use Flask. It's a "micro-framework," which means it doesn't impose a rigid structure and gives me complete freedom in building the architecture. It's like a LEGO set: you start with a few basic bricks and add only what you truly need.

The System's Memory: The Database and SQLAlchemy

User data, access roles, and other structured information are stored in a PostgreSQL database management system. It's an incredibly reliable and powerful solution capable of handling heavy loads.

To interact with the database from Python code, I use SQLAlchemy. This library acts as a "translator." It allows me to work with database tables as if they were regular Python objects, which significantly simplifies and speeds up development.

Access Control: Roles and Security

Some sections of the site are only available to registered users or those with a specific role (e.g., fzs_user). This logic is implemented using the Flask-Login and Flask-Bcrypt extensions. User passwords are not stored in plain text; they undergo irreversible encryption (hashing), ensuring their security.

Two Languages, One Site: Internationalization

Since the site is intended for both a Ukrainian and an international audience, supporting multiple languages was essential. Thanks to the Flask-Babel extension, the site automatically detects the user's browser language and displays the appropriate version of the page (/uk/ or /en/). It also allows for easy switching between languages.

A Home for the Code: How the Site Lives on the Server

Writing the code is only half the battle. To make it accessible to everyone on the internet, it needs to be properly deployed and configured on a remote server. My setup consists of three key components working in concert.

  1. Nginx – The Welcoming Administrator. This is the web server that first greets you when you visit the site. It acts as a reverse proxy, quickly serving static files (images, CSS styles) and forwarding more complex requests to the application's "brain."

  2. Gunicorn – The Manager of Work Processes. This is the WSGI server that directly runs my Flask application. It manages multiple concurrently running copies of the app (known as "workers"), allowing the site to efficiently handle requests from many users at once.

  3. Systemd – The Tireless Supervisor. This is the init system on the Ubuntu server. I have configured the application as a service, and systemd ensures that it runs continuously. If the process fails for any reason, systemd will automatically restart it.

Why All This?

Creating such a technological "sandwich" might seem overly complex for a personal website. However, each element in this system plays a crucial role, providing speed, security, reliability, and flexibility.

This is a solid foundation that allows me to stop thinking about technical limitations and focus on what's most important – creating quality content: new maps, publishing data, and sharing scientific knowledge.