This repository is intended to serve as a working example of an API that combines several tools and topics. Basically, FastrawGIS supports asynchronous handling of HTTP requests with GraphQL syntax, converting them into database queries and returning the proper results.
The main purpose of the app is to design and model events, locations, and timetables so that the underlying spatial database allows queries regarding distance and time factors.
- Simple setup.
- Fast response.
- Validation of requests.
- Type hinted code, divided in different layers.
- Easily extendable with more models, fields, and filters.
- Search by space, supporting geographic coordinates and radius with meters accuracy.
- Search by time, supporting schedules with minutes accuracy.
- Docker Compose.
- Some GraphQL client, like for example Bruno.
docker compose upHost's port 80 should be available. Otherwise, it can be customized at docker-compose.yml.
The following two commands create and load the database.
docker exec -it fastrawgis-app python app/cli/database/main.py create
docker exec -it fastrawgis-app python app/cli/database/main.py loadWe can leverage real sample data and perform POST requests to http://localhost/graphql,
obtaining two items with each of the following queries.
Search by space.
{
events (
day: "25-07-12",
lat: 41.39491039820101,
lon: 2.1755553553648936,
radius: 2500,
) {
id
venue {
id
town {
id
name
}
name
point {
lat
lon
}
address
distance
}
name
start
end
desc
}
}Search by time.
{
events (
day: "25-07-12",
startTime: "8:00",
endTime: "12:00",
) {
id
venue {
id
town {
id
name
}
name
point {
lat
lon
}
address
}
name
start
end
desc
}
}If you change the GraphQL schema at schema.py and want to check
the corresponding schema.gql, it can be generated this way.
docker exec -it fastrawgis-app strawberry export-schema app.api.schema:schema > app/api/schema.gqlThe diagram shows the interaction between the main components of the application.
