# lenekerc98/geoportal-backend architecture

> Architecture diagram of the GitHub repository lenekerc98/geoportal-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lenekerc98/geoportal-backend
- Repository: https://github.com/lenekerc98/geoportal-backend

## Overview

Catastro API 2026 is a FastAPI backend for a GIS-enabled cadastral system. The main workflow is an API client calling registered routes: authentication and authorization protect requests, GIS routes read or modify cadastral/spatial data, and responses return to the client. Separate routes manage users, companies, projects, configuration, drawings, and system operations. Spatial services catalog orthoimages and process GIS files; PostgreSQL/PostGIS stores application and spatial data. The excerpts show application wiring and selected service calls, but not the full GIS route behavior, so uncertain service links are omitted or marked unverified.

Main entry points: [`app/core/database.py`](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/database.py) (Database sessions), [`app/main.py`](https://github.com/lenekerc98/geoportal-backend/blob/main/app/main.py) (FastAPI application), [`app/routers/gis.py`](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/gis.py) (Cadastral GIS routes), [`app/routers/auth.py`](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/auth.py) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and operations"]
  node_application["FastAPI application<br/>[main.py]"]
  node_config_routes["Configuration routes<br/>[config.py]"]
  node_system_routes["System routes<br/>[system.py]"]
end

subgraph group_access["Identity and administration"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_user_routes["User and role routes<br/>[users.py]"]
  node_company_routes["Company routes<br/>[empresas.py]"]
  node_project_routes["Project routes<br/>[proyectos.py]"]
  node_user_model["User and tenancy models<br/>[user.py]"]
  node_security["Password and token security<br/>[security.py]"]
end

subgraph group_spatial["GIS and cataloging"]
  node_drawing_routes["Drawing routes<br/>[dibujo.py]"]
  node_gis_routes["Cadastral GIS routes<br/>[gis.py]"]
  node_drawing_model["Drawing model<br/>[dibujo.py]"]
  node_catalog_service["Orthoimage cataloging"]
  node_ortho_service["Orthoimage processing"]
  node_file_utils["GIS file utilities<br/>[file_utils.py]"]
  node_shapefile_service["Shapefile processing"]
  node_cad_service["CAD processing<br/>[cad_service.py]"]
  node_sqlserver_service["SQL Server integration"]
end

subgraph group_platform["Data and platform"]
  node_config_model["SMTP configuration model<br/>[config.py]"]
  node_database["Database sessions<br/>[database.py]"]
  node_postgres[("PostgreSQL and PostGIS")]
  node_schema_init["Spatial schema initialization<br/>[init_db.py]"]
  node_audit["Audit and alerting<br/>[logger.py]"]
  node_log_model["Audit log model<br/>[log.py]"]
end

node_client(("API client"))
node_smtp(("SMTP mail service"))

node_client -->|"sends requests"| node_application
node_application -->|"registers routes"| node_auth_routes
node_application -->|"registers routes"| node_user_routes
node_application -->|"registers routes"| node_company_routes
node_application -->|"registers routes"| node_project_routes
node_application -->|"registers routes"| node_config_routes
node_application -->|"registers routes"| node_drawing_routes
node_application -->|"registers routes"| node_system_routes
node_application -->|"registers routes"| node_gis_routes
node_application -->|"initializes schema"| node_schema_init
node_application -->|"creates tables"| node_database
node_application -->|"logs failures"| node_audit
node_auth_routes -->|"gets sessions"| node_database
node_auth_routes -->|"verifies and signs"| node_security
node_user_routes -->|"gets sessions"| node_database
node_user_routes -->|"uses token security"| node_security
node_config_routes -->|"gets sessions"| node_database
node_drawing_routes -->|"gets sessions"| node_database
node_company_routes -->|"gets sessions"| node_database
node_project_routes -->|"gets sessions"| node_database
node_system_routes -->|"gets sessions"| node_database
node_gis_routes -->|"gets sessions"| node_database
node_database -->|"connects to"| node_postgres
node_schema_init -->|"creates spatial schema"| node_postgres
node_user_model -->|"maps ORM tables"| node_database
node_config_model -->|"maps ORM table"| node_database
node_drawing_model -->|"maps ORM table"| node_database
node_log_model -->|"maps ORM table"| node_database
node_audit -->|"writes audit records"| node_log_model
node_audit -->|"sends alerts"| node_smtp
node_catalog_service -->|"uses path helpers"| node_file_utils
node_ortho_service -->|"uses storage helpers"| node_file_utils
node_gis_routes -.->|"dispatches cataloging"| node_catalog_service
node_gis_routes -.->|"dispatches processing"| node_ortho_service
node_gis_routes -.->|"uses GIS processing"| node_shapefile_service
node_gis_routes -.->|"uses CAD processing"| node_cad_service
node_gis_routes -.->|"uses integration"| node_sqlserver_service

click node_application "https://github.com/lenekerc98/geoportal-backend/blob/main/app/main.py"
click node_auth_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/auth.py"
click node_user_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/users.py"
click node_company_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/empresas.py"
click node_project_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/proyectos.py"
click node_config_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/config.py"
click node_drawing_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/dibujo.py"
click node_system_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/system.py"
click node_gis_routes "https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/gis.py"
click node_user_model "https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/user.py"
click node_config_model "https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/config.py"
click node_drawing_model "https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/dibujo.py"
click node_database "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/database.py"
click node_schema_init "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/init_db.py"
click node_security "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/security.py"
click node_catalog_service "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/catalogacion_service.py"
click node_ortho_service "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/ortofoto_service.py"
click node_file_utils "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/file_utils.py"
click node_shapefile_service "https://github.com/lenekerc98/geoportal-backend/blob/main/app/services/shapefile_service.py"
click node_cad_service "https://github.com/lenekerc98/geoportal-backend/blob/main/app/services/cad_service.py"
click node_sqlserver_service "https://github.com/lenekerc98/geoportal-backend/blob/main/app/services/sqlserver_service.py"
click node_audit "https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/logger.py"
click node_log_model "https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/log.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_config_routes,node_system_routes,node_client toneBlue
class node_auth_routes,node_user_routes,node_company_routes,node_project_routes,node_user_model,node_security toneAmber
class node_drawing_routes,node_gis_routes,node_drawing_model,node_catalog_service,node_ortho_service,node_file_utils,node_shapefile_service,node_cad_service,node_sqlserver_service toneMint
class node_config_model,node_database,node_postgres,node_schema_init,node_audit,node_log_model toneRose
class node_smtp toneIndigo
```

## Components

### API and operations

- [FastAPI application](https://github.com/lenekerc98/geoportal-backend/blob/main/app/main.py): `app/main.py`
- [Configuration routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/config.py): `app/routers/config.py`
- [System routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/system.py): `app/routers/system.py`

### Identity and administration

- [Authentication routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [User and role routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/users.py): `app/routers/users.py`
- [Company routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/empresas.py): `app/routers/empresas.py`
- [Project routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/proyectos.py): `app/routers/proyectos.py`
- [User and tenancy models](https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/user.py): `app/models/user.py`
- [Password and token security](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/security.py): `app/core/security.py`

### GIS and cataloging

- [Drawing routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/dibujo.py): `app/routers/dibujo.py`
- [Cadastral GIS routes](https://github.com/lenekerc98/geoportal-backend/blob/main/app/routers/gis.py): `app/routers/gis.py`
- [Drawing model](https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/dibujo.py): `app/models/dibujo.py`
- [Orthoimage cataloging](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/catalogacion_service.py): `app/core/catalogacion_service.py`
- [Orthoimage processing](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/ortofoto_service.py): `app/core/ortofoto_service.py`
- [GIS file utilities](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/file_utils.py): `app/core/file_utils.py`
- [Shapefile processing](https://github.com/lenekerc98/geoportal-backend/blob/main/app/services/shapefile_service.py): `app/services/shapefile_service.py`
- [CAD processing](https://github.com/lenekerc98/geoportal-backend/blob/main/app/services/cad_service.py): `app/services/cad_service.py`
- [SQL Server integration](https://github.com/lenekerc98/geoportal-backend/blob/main/app/services/sqlserver_service.py): `app/services/sqlserver_service.py`

### Data and platform

- [SMTP configuration model](https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/config.py): `app/models/config.py`
- [Database sessions](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/database.py): `app/core/database.py`
- **PostgreSQL and PostGIS**
- [Spatial schema initialization](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/init_db.py): `app/core/init_db.py`
- [Audit and alerting](https://github.com/lenekerc98/geoportal-backend/blob/main/app/core/logger.py): `app/core/logger.py`
- [Audit log model](https://github.com/lenekerc98/geoportal-backend/blob/main/app/models/log.py): `app/models/log.py`

### Other components

- **API client**
- **SMTP mail service**

## Connections

- API client → FastAPI application: sends requests (evidence: `app/main.py`)
- FastAPI application → Authentication routes: registers routes (evidence: `app/main.py`)
- FastAPI application → User and role routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Company routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Project routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Configuration routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Drawing routes: registers routes (evidence: `app/main.py`)
- FastAPI application → System routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Cadastral GIS routes: registers routes (evidence: `app/main.py`)
- FastAPI application → Spatial schema initialization: initializes schema (evidence: `app/main.py`)
- FastAPI application → Database sessions: creates tables (evidence: `app/main.py`)
- FastAPI application → Audit and alerting: logs failures (evidence: `app/main.py`)
- Authentication routes → Database sessions: gets sessions (evidence: `app/routers/auth.py`)
- Authentication routes → Password and token security: verifies and signs (evidence: `app/routers/auth.py`)
- User and role routes → Database sessions: gets sessions (evidence: `app/routers/users.py`)
- User and role routes → Password and token security: uses token security (evidence: `app/routers/users.py`)
- Configuration routes → Database sessions: gets sessions (evidence: `app/routers/config.py`)
- Drawing routes → Database sessions: gets sessions (evidence: `app/routers/dibujo.py`)
- Company routes → Database sessions: gets sessions (evidence: `app/routers/empresas.py`)
- Project routes → Database sessions: gets sessions (evidence: `app/routers/proyectos.py`)
- System routes → Database sessions: gets sessions (evidence: `app/routers/system.py`)
- Cadastral GIS routes → Database sessions: gets sessions (evidence: `app/routers/gis.py`)
- Database sessions → PostgreSQL and PostGIS: connects to (evidence: `app/core/database.py`)
- Spatial schema initialization → PostgreSQL and PostGIS: creates spatial schema
- User and tenancy models → Database sessions: maps ORM tables (evidence: `app/models/user.py`)
- SMTP configuration model → Database sessions: maps ORM table (evidence: `app/models/config.py`)
- Drawing model → Database sessions: maps ORM table (evidence: `app/models/dibujo.py`)
- Audit log model → Database sessions: maps ORM table (evidence: `app/models/log.py`)
- Audit and alerting → Audit log model: writes audit records (evidence: `app/core/logger.py`)
- Audit and alerting → SMTP mail service: sends alerts (evidence: `app/core/logger.py`)
- Orthoimage cataloging → GIS file utilities: uses path helpers (evidence: `app/core/catalogacion_service.py`)
- Orthoimage processing → GIS file utilities: uses storage helpers (evidence: `app/core/ortofoto_service.py`)
- Cadastral GIS routes → Orthoimage cataloging: dispatches cataloging (evidence: `app/routers/gis.py`)
- Cadastral GIS routes → Orthoimage processing: dispatches processing (evidence: `app/routers/gis.py`)
- Cadastral GIS routes → Shapefile processing: uses GIS processing (evidence: `app/routers/gis.py`)
- Cadastral GIS routes → CAD processing: uses CAD processing (evidence: `app/routers/gis.py`)
- Cadastral GIS routes → SQL Server integration: uses integration (evidence: `app/routers/gis.py`)
