https://github.com/apilogicserver/postgres-nw
https://github.com/apilogicserver/postgres-nw
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/apilogicserver/postgres-nw
- Owner: ApiLogicServer
- Created: 2023-08-14T00:19:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-01T13:38:13.000Z (almost 3 years ago)
- Last Synced: 2025-05-19T09:12:54.151Z (about 1 year ago)
- Language: Python
- Size: 231 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Security: security/__init__.py
Awesome Lists containing this project
README
# Using this readme
This readme contains the following sections:
| Section | Info |
|:-------------------------|:-----------------------------------|
| [1. Setup and Run](#1-setup-and-run) | Information about API Logic Server, and setting up your venv |
| [2. Deployment](#2-deployment) | Deploy early previews to the cloud - enable team collaboration |
| [3. Key Customization Files](#3-key-customization-files) | Quick idea of the key files you'll alter |
| [4. Project Requirements](#4-project-requirements) | Options for capturing requirements |
| [5. Project Information](#5-project-information) | Creation dates, versions |
| [Appendix - Key Technologies](#appendix-key-technologies) | Doc links of key libraries |
# 1. Setup and Run
To run your project, the system requires various runtime systems for data access, api, and logic. These are included with API Logic Server ([architecture doc here](https://apilogicserver.github.io/Docs/Architecture-What-Is/)). So, to run your project ([instructions here](#setup-instructions)):
1. __Establish your Python Environment__ to activate these runtime systems
2. __Run__
Setup your Python environment, according to whether you did a *local install*, or *Docker*. Choose the appropriate section, then run.
## Establish Your Python Environment - Local Install
You `requirements.txt` has already been created, so...
```bash title="Install API Logic Server in a Virtual Environment"
python -m venv venv # may require python3 -m venv venv
venv\Scripts\activate # mac/linux: source venv/bin/activate
python -m pip install -r requirements.txt # accept "new Virtual environment"
```
Notes:
* See also the `venv_setup` directory in this API Logic Project.
* If using SqlServer, install `pyodbc`. Not required for docker-based projects. For local installs, see the [Quick Start](https://apilogicserver.github.io/Docs/Install-pyodbc/).
* If you are creating multiple projects, you may wish to use a [Shared venv](https://apilogicserver.github.io/Docs/Project-Env/).
## Establish Your Python Environment - Docker
Your runtime systems are part of Dev Container, which you probably activated when you [opened the project](https://apilogicserver.github.io/Docs/IDE-Execute/).
* If you did not accept the "Open in Container" option when you started VSCode, use __View > Command Palette > Remote-Containers: Reopen in Container__.
## Run
To run your project

As shown above:
1. Use the pre-supplied Run Configuration; use either:
* `**ApiLogicServer - No Security (e.g., for behave tests** to run *with security* (recommended initially)
* `**ApiLogicServer** to run [with security](https://apilogicserver.github.io/Docs/Security-Swagger/)
2. Click the url in the console to start the Admin App
* Use it to explore your data (shown below)
* And your API (via Swagger)

# 2. Deployment
The `devops` directory contains several scripts for creating container images, testing them, and deploying them.
Since API Logic Server creates working software (UI, API), you can do this after creating your project, to [collaborate with your team](https://apilogicserver.github.io/Docs/DevOps-Containers-Preview/).
# 3. Key Customization Files
Your project is ready to run, but it's likely you'll want to customize it - declare logic, new endpoints, etc.
The ___Key Customization Files___ listed in the table below are created as stubs, intended for you to add customizations that extend
the created API, Logic and Web App.
* Since they are separate files, the project can be
[rebuilt](https://apilogicserver.github.io/Docs/Project-Rebuild/) (e.g., synchronized with a revised schema), preserving your customizations.
Please see the `nw` sample for examples of typical customizations. You can open it in GitHub (use Shift + "." to view in project mode) - [click here](https://github.com/ApiLogicServer/demo).
| Directory | Usage | Key Customization File | Typical Customization |
|:-------------- |:------------------------------|:-----------------------------------|:--------------------------------------------------------------------------------------|
| ```api``` | **JSON:API**
*Ready to Run* | ```api/customize_api.py``` | Add new end points / services |
| ```ui``` | **Multi-Page Admin App**
*Ready to Run* | ```ui/admin/admin.yaml``` | Control field display - order, captions etc. |
| ```database``` | SQLAlchemy Data Model Classes | ```database/customize_models.py``` | Add derived attributes, and relationships missing in the schema |
| ```logic``` | **Transactional Logic**
spreadsheet-like rules | ```logic/declare_logic.py``` | Declare multi-table derivations, constraints, and Python events such as send mail / messages |
| ```security``` | Authentication, Authorization | ```security/declare_security.py``` | Control login, role-based row access |
| ```tests``` | Behave Test Suite | ```tests/api_logic_server_behave/features``` | Declare and implement [Behave Tests](https://apilogicserver.github.io/Docs/Behave/) |
# 4. Project Requirements
Optionally, you can **document requirements** as part of an **executable test plan**. Test plan execution creates documentation (in markdown), including **requirements traceability** into implementation. [See example here](test/api_logic_server_behave/reports/Behave%20Logic%20Report%20Sample.md).
# 5. Project Information
This API Logic Project was created with the `ApiLogicServer create` command.
For information on Managing API Logic Projects, [click here](https://apilogicserver.github.io/Docs/Project-Structure).
| About | Info |
|:-------------------------|:-----------------------------------|
| Created | October 01, 2023 06:34:56 |
| API Logic Server Version | 09.04.00 |
| Created in directory | ../../../servers/postgres-nw |
| API Name | api |
| Execution begins with | `api_logic_server_run.py` |
# Appendix: Key Technologies
API Logic Server is based on the projects shown below.
Consult their documentation for important information.
### SARFS JSON:API Server
[SAFRS: Python OpenAPI & JSON:API Framework](https://github.com/thomaxxl/safrs)
SAFRS is an acronym for SqlAlchemy Flask-Restful Swagger.
The purpose of this framework is to help python developers create
a self-documenting JSON API for sqlalchemy database objects and relationships.
These objects are serialized to JSON and
created, retrieved, updated and deleted through the JSON API.
Optionally, custom resource object methods can be exposed and invoked using JSON.
Class and method descriptions and examples can be provided
in yaml syntax in the code comments.
The description is parsed and shown in the swagger web interface.
The result is an easy-to-use
swagger/OpenAPI and JSON:API compliant API implementation.
### LogicBank
[Transaction Logic for SQLAlchemy Object Models](https://apilogicserver.github.io/Docs/Logic-Why/)
Use Logic Bank to govern SQLAlchemy update transaction logic -
multi-table derivations, constraints, and actions such as sending mail or messages. Logic consists of _both:_
* **Rules - 40X** more concise using a spreadsheet-like paradigm, and
* **Python - control and extensibility,** using standard tools and techniques
Logic Bank is based on SQLAlchemy - it handles `before_flush` events to enforce your logic.
Your logic therefore applies to any SQLAlchemy-based access - JSON:Api, Admin App, etc.
### SQLAlchemy
[Object Relational Mapping for Python](https://docs.sqlalchemy.org/en/13/).
SQLAlchemy provides Python-friendly database access for Python.
It is used by JSON:Api, Logic Bank, and the Admin App.
SQLAlchemy processing is based on Python `model` classes,
created automatically by API Logic Server from your database,
and saved in the `database` directory.
### Admin App
This generated project also contains a React Admin app:
* Multi-page - including page transitions to "drill down"
* Multi-table - master / details (with tab sheets)
* Intelligent layout - favorite fields first, predictive joins, etc
* Logic Aware - updates are monitored by business logic
### Python Tips
If you are new to Python, check out [these tips](https://apilogicserver.github.io/Docs/Tech-Python/).