This project is a geospatial application built with Python[FastAPI], SQLAlchemy[GeoAlchemy], Postgresql[PostGIS] and Alembic. It uses asynchronous database operations to handle geospatial data efficiently. It uses the data bundle from the PostGIS introduction 🏙️ PostGIS Workshop The idea was to serve GeoJSON 🌍 from an asynchronous Python 🐍 backend using API endpoints 🚀. The GeoJSON 🌍 should be parsed and rendered by a JavaScript 🖥️ frontend application and displayed in a web browser 🌐.
- 🚀 Asynchronous database operations with SQLAlchemy and asyncpg
- 🔄 Database migrations with Alembic
- 🗺️ Geospatial data handling
- 🐍 Python 3.9+ (Written in 3.13)
- 🐘 PostgreSQL with PostGIS extension
asyncpg
for asynchronous PostgreSQL operationsSQLAlchemy
for ORMAlembic
for database migrations
-
Clone the repository:
git https://github.com/RobertRivas/geoapp-backend.git cd geoapp-backend
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up the database: refer to for local setup - 🏙️ PostGIS Workshop
createdb nyc psql -d nyc -c "CREATE EXTENSION postgis;"
-
Run database migrations:
alembic upgrade head
-
Start the application:
python main.py
- 📂
alembic/
: Directory for Alembic migrations - 🗄️
database/
: Database models and configuration - 🚀
main.py
: Main application entry point
To create a new migration, use:
alembic revision --autogenerate -m "description"
To apply migrations, use:
alembic upgrade head