diff options
-rw-r--r-- | readme.md | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -110,6 +110,59 @@ of annotated raw SQL queries, exposing them as callable Python functions. | |||
110 | [embrace]: https://pypi.org/project/embrace/ | 110 | [embrace]: https://pypi.org/project/embrace/ |
111 | [DAO]: https://en.wikipedia.org/wiki/Data_access_object | 111 | [DAO]: https://en.wikipedia.org/wiki/Data_access_object |
112 | 112 | ||
113 | #### CGI scripts vs. Services | ||
114 | |||
115 | The most simple and primitive way of making Python programs accessible from a | ||
116 | web browser would be through the Common Gateway Interface ([CGI]). Through it, | ||
117 | the user is able to execute the scripts by visiting a matching URL, to then | ||
118 | visualise its output directly in their browser. | ||
119 | |||
120 | [CGI]: https://en.wikipedia.org/wiki/Common_Gateway_Interface | ||
121 | |||
122 | The other approach is to make the program a server application as a persistent | ||
123 | service process, in charge of accepting, handling and replying to network | ||
124 | requests by itself. | ||
125 | |||
126 | The former, identical to the way the oldest PHP scripts are run, has become | ||
127 | less popular in favour of the latter, mainly for performance and | ||
128 | maintainability concerns for real applications outside of trivial, independent, | ||
129 | and self-contained scripts. For those reasons, this project will be implemented | ||
130 | as a service process. | ||
131 | |||
132 | #### Comprehensive vs. Light-weight frameworks | ||
133 | |||
134 | While bare Python could be used to create such a web service, it is desirable | ||
135 | to work at a higher abstraction level to focus on the application-specific | ||
136 | features rather than the standard protocol implementation details. | ||
137 | |||
138 | Python frameworks such as [Django] offer comprehensive solutions for building | ||
139 | web applications based on the Model-View-Controller ([MVC] or MTV/MVT) design | ||
140 | pattern, ensuring [separation of concerns] while abstracting lower level logic. | ||
141 | This kind of complete solutions provide routing logic to map requests to | ||
142 | user-defined handlers, and are integrated with a Object-Relational Mapper as | ||
143 | well as with a templating engine to generate HTML pages dynamically. | ||
144 | |||
145 | [Django]: https://www.djangoproject.com/ | ||
146 | [MVC]: https://en.wikipedia.org/wiki/Model-view-controller | ||
147 | [separation of concerns]: https://en.wikipedia.org/wiki/Separation_of_concerns | ||
148 | |||
149 | Other more light-weight frameworks such as [Flask] or the more recent [FastAPI] | ||
150 | instead focus on the first part, taking care of unpacking and routing requests | ||
151 | to the user-defined handlers, while leaving the rest to the application | ||
152 | developers. This approach does not fully impose an entire environment, and | ||
153 | allows better composability with libraries which can be freely chosen. | ||
154 | |||
155 | [Flask]: https://flask.palletsprojects.com/ | ||
156 | [FastAPI]: https://fastapi.tiangolo.com/ | ||
157 | |||
158 | Because the use of an ORM is not desirable in this project for the reasons | ||
159 | detailed in a previous section, the choices of frameworks is limited to these | ||
160 | light-weight frameworks. Here, FastAPI is preferred over Flask due to its more | ||
161 | modern architecture, using parameters and [dependency injection] over | ||
162 | thread-local global variables. | ||
163 | |||
164 | [dependency injection]: https://en.wikipedia.org/wiki/Dependency_injection | ||
165 | |||
113 | ### Project structure overview | 166 | ### Project structure overview |
114 | 167 | ||
115 | * `./sql/` | 168 | * `./sql/` |