Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ccasro/hub/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Hub uses PostgreSQL with PostGIS extension for spatial data support. The database stores venues, bookings, matches, users, and geographic data for location-based features.PostGIS is required for geospatial queries like finding venues near a location.
Database Requirements
- PostgreSQL: Version 16+ (recommended)
- PostGIS: Version 3.4+
- Extensions:
postgis- Spatial data supportpgcrypto- Cryptographic functionsbtree_gist- B-tree and GiST index support for constraints
Quick Start with Docker
The easiest way to run PostgreSQL with PostGIS is using Docker:Start PostgreSQL
Use the provided Docker Compose configuration:This starts a PostgreSQL container with PostGIS pre-installed.
Terminal
Docker Compose Configuration
Thedocker-compose.yml includes a PostgreSQL service with PostGIS:
docker-compose.yml
Data is persisted in the
postgres-data volume. To reset the database, run:Manual PostgreSQL Setup
If you’re not using Docker, follow these steps:Environment Variables
Configure these environment variables for database connectivity:Database server hostnameLocal:
localhostDocker: postgres (service name)Production: your-db-host.comDatabase server portDefault:
5432Database nameExample:
hub_db, padelhub_productionDatabase user with read/write access
Database user password
SSL/TLS mode for database connectionsOptions:
disable- No SSL (local development)require- Require SSL, don’t verify certificateverify-ca- Require SSL, verify certificate authorityverify-full- Require SSL, verify certificate and hostname
disableUse
require or higher in productionConnection Pool Configuration
The application uses HikariCP for connection pooling:application.yaml
auto-commit: false improves performance by allowing explicit transaction management.Database Schema
The schema is managed by Flyway migrations located inbackend/src/main/resources/db/migration/.
Migration Files
V1__init.sql- Initial schema: cities with PostGIS spatial dataV2__users.sql- User accounts and profilesV3__create_venue.sql- Venues (padel clubs)V4__create_resource.sql- Resources (padel courts)V5__create_booking.sql- Booking systemV6__create_payment.sql- Payment trackingV7__create_match_request.sql- Match requests and invitationsV8__seed_dev_data.sql- Development seed data
Key Tables
city
city
Pre-populated table with Spanish cities and coordinates:Contains 40 Spanish cities with PostGIS point geometries.
users
users
User accounts synchronized with Auth0:
auth0_id- Links to Auth0 useremail- User emailname- Display nameprofile_picture- Cloudinary URLskill_level- Padel skill level
venue
venue
Padel clubs and facilities:
name- Venue namecity_id- References city tablelocation- PostGIS point for geospatial queriesphotos- Array of Cloudinary URLsmanager_id- User who manages the venue
resource
resource
Individual padel courts:
venue_id- Parent venuename- Court name (e.g., “Court 1”)surface_type- Court surfaceis_indoor- Indoor/outdoor flag
booking
booking
Court reservations:
resource_id- Court being bookeduser_id- User making the bookingstart_time- Booking startend_time- Booking endstatus- PENDING, CONFIRMED, CANCELLED- Constraint: No overlapping bookings per resource
Flyway Migrations
Flyway automatically manages database schema versions.Configuration
application.yaml
Creating Migrations
To add a new migration:Create SQL file
Create a new file following Flyway naming convention:Example:
V9__add_user_preferences.sqlMigration Best Practices
- Make migrations idempotent when possible
- Use
IF NOT EXISTSfor CREATE statements - Test migrations on a copy of production data
- Never modify existing migration files
- Include rollback scripts for complex migrations
Geospatial Queries
PostGIS enables location-based features:Find Venues Near Location
Find Nearest City
The
<-> operator uses the spatial index for fast nearest-neighbor queries.Database Tools
pgAdmin (Included with Docker)
A web-based PostgreSQL administration tool is included:- Host:
postgres(orhost.docker.internalfrom host machine) - Port:
5432 - Database:
hub_db - Username: From
POSTGRES_USER - Password: From
POSTGRES_PASSWORD
Command Line Tools
Production Configuration
Security Checklist
Managed Database Providers
For production, consider managed PostgreSQL services:- AWS RDS for PostgreSQL (with PostGIS)
- Azure Database for PostgreSQL
- Google Cloud SQL for PostgreSQL
- DigitalOcean Managed Databases
- Supabase (includes PostGIS by default)
Ensure your managed database provider supports PostGIS extension.
Monitoring
Health Check
The application exposes a health check endpoint:Common Issues
Connection refused
Connection refused
Error:
Connection to localhost:5432 refusedSolutions:- Check PostgreSQL is running:
docker ps | grep postgres - Verify
DB_HOSTandDB_PORTare correct - Check firewall rules
Authentication failed
Authentication failed
Error:
password authentication failed for userSolutions:- Verify
DB_USERandDB_PASSWORDmatch PostgreSQL user - Check
pg_hba.confauthentication rules
PostGIS extension missing
PostGIS extension missing
Error:
extension "postgis" does not existSolution:Migration checksum mismatch
Migration checksum mismatch
Error:
Validate failed: Migration checksum mismatchSolution: Never modify existing migrations. Create a new migration to fix issues.Next Steps
Integrations
Configure Cloudinary and Brevo
API Reference
Explore API endpoints
Data Models
Understand data structure
Deployment
Deploy to production