-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
Initial development will be on a core domain model, persistence, and a RESTful web service to access models.
I selected the following
| Component | Rationale | Drawbacks or Negatives |
|---|---|---|
| Python for backend | WS tools are more mature, scalable, and secure than Javascript frameworks. Python is simpler than Java REST frameworks with more deployment options. | Async behavior rather complex in Python. |
| FastAPI for Web Service | Much faster than Django RestFramework, good async support, excellent documentation, large community. | Less consistent and elegant syntax for WS endpoints than Django or Java REST API; requires separate "schema" classes for models that result in some duplicate code. |
| Postgres DB; Sqlite for testing | Free & well supported. RDBMS is appropriate for structured data in this app. Both have async interfaces. | - |
The backend services can be implemented using standard synchronous Python code or asynchronous code.
Asynchronous code has higher throughput -- up to 10X faster for I/O bound applications. I expect the web service and database will be running on a separate cloud services or different container from the web service, hence there may be network latency.
The drawbacks of async code are complexity and less support.
- PostgreSQL 2.0 mainstreams support for async mode, but it requires separate packages and is much less widely used. Some operations don't work.
- Sqlite support for async is by a 3rd party package that still has not reached version 1.0
- Testing async code is more complex and also requires extra packages.
- My own limited understanding of async code in Python may result in code defects.
As usual, strive for a component-based design with loose coupling. We should be able to replace the framework or library used in a component with low (or no) change needed in the rest of the code.
I asked DeepSeek and ChatGPT this question:
I want to build a simple application to record residential data such as electric power and water usage. It will have both a web-based and mobile interface.
The major features are:
- user can input home data with a timestamp,
- user can view all data for his home.
- There will be only a few users, and each user may create more than one data source for his home.
What software architecture(s) would be best suited for this?
Later, I rephrased the question with a reference to the wiki page for Requirements instead of writing requirements in the question.
The answers were long and I asked follow-up questions, so I put them in separate files.
I asked follow-up questions, such as:
- how to accommodate a LINE interface using a LINE Mini-App
- comparison of something like Railway (Python & FastAPI) + Supabase (Postgres) with Firebase or Cloudflare Workers + D1.
- in a separate chat I asked for comparison of using Python (FastAPI or Django DRF) and Javascript/Typescript (Express) in terms of performance, development effort, and security. For security and development effort, FastAPI and Python look better.
Deepseek Suggested Architecture
ChatGPT Suggested Architecture
I compared Javascript and Python for the backend web service, and a few REST frameworks for each language.