Table of Contents
The primary objective of this project is to develop an advanced Geographic Information System (GIS) application tailored for the management and uti- lization of the Master Plan of the Italian province of Fano with a population of approximately 250,000 inhabitants, Fano’s Master Plan serves as a crucial blueprint for urban and territorial development. This project seeks to address the specific needs of planners and the general public, offering them a platform that facilitates the creation, maintenance, and accessibility of plan variants, thus fostering efficient urban planning and informed decision-making.
Agora
├── backend
│ ├── app
│ ├── Dockerfile
│ ├── Dockerfile.without_k8s
├── environment.env
├── docker-compose.yml
├── README.md
Inside the app
folder we have the main application + the initial_data.py
script that fetch the data from sitemap and fill the db with it, and the pyproject.toml
file that contains the dependencies of the project.
App
├── app
│ ├── api
│ │ ├── v1 -> endpoint to get the data (content)
│ ├── core (contains config)
│ ├── crud (contains crud operations)
│ ├── db (used for init database & session management)
│ ├── models
│ ├── schemas
│ ├── utils
│ ├── initial_data.py (script to fetch data from sitemap and fill the db)
│ ├── main.py (main application)
├── pyproject.toml
├── poetry.lock
After adding models to the models
folder you should create crud and schema for them in the crud
and schemas
folder respectively.
We have base_crud.py
that contains the base crud operations that we can use for all models like get_all
, get_by_id
, create
, update
, delete
and ... .
And if you need some specific crud operations for a model you can define the function in a crud file related to that model.
In schemas folder for each model we have three different schemas for each model:
IModelRead
that contains the fields that we can read from the modelIModelCreate
that contains the fields that we can create the model withIModelUpdate
that contains the fields that we can update the model with, this one can use with decorator@optional
to make the fields optionalIModel...
that match your needs
In the api
folder we have the endpoints that we can use to get the data from the db.
Define your endpoint as route under router = APIRouter()
and write your function under it.
Set up the application and add the routers to it. Also, we add middleware to the application to handle CORS
and add the db
to the application, this way we can use db
in our endpoints without initializing session each time in each endpoint.
This command will build the image and run the container
docker-compose up --build
In command section of docker-compose.yml we have two commands:
python app/initial_data.py
to create the db and fill it with initial data that fetch from sitemapuvicorn app.main:app --workers 5 --host 0.0.0.0 --port 8000
to run the server
For debugging or add new code to the project you can add --reload
to the command to reload the server when you change the code in the command section of docker-compose.yml
command: bash -c "python app/initial_data.py && uvicorn app.main:app --reload --workers 5 --host --host 0.0.0.0 --port 8000`
But consider that when you add --reload
to the command the --workers
parameter will be ignored and the server will run with one worker.
For adding environment variables to the docker-compose.yml or your application you can add them to the environment.env
file in the root of the project.
- Farzad Shami
Distributed under the MIT License. See LICENSE.txt
for more information.
Part of Geographic Information Systems 2022-2023 course of University of Padova