Thanks to visit codestin.com
Credit goes to github.com

Skip to content

listellodavide/sparrow-air

 
 

Repository files navigation

Sparrow Air 2

Project Overview

Sparrow Air 2 is a fun pet project focused on building a reactive airline management system using a step by step vibe coding (with manual interventions when it breaks the project or goes too astray). The project aims to leverage reactive programming principles throughout the entire stack while carefully considering database isolation levels to ensure data consistency and integrity. We're just getting started, but the goal is to create a fully reactive application.

Getting Started

You just need:

  1. Java 21 or higher
  2. Docker
  3. Run the program with datademo profile to load the sample data (sample data is also generated by AI ;) )
  4. view swagger at http://localhost:8080/swagger-ui/index.html & have fun!

Database Configuration

If docker is installed, it should just work. The PostgreSQL database, running in Docker, is configured with the following parameters:

  • Database Name: mydatabase
  • Username: myuser
  • Password: secret
  • Port: 5432 (mapped from container to host)

Connecting to the PostgreSQL Container

1. Check Running Containers

First, ensure that the Docker containers are running:

docker ps

Look for a container running the postgres:latest image.

2. Connect to the PostgreSQL Container

You can connect to the PostgreSQL container using the following command:

docker exec -it <container_id> bash

Alternatively, you can use the container name:

docker exec -it sparrow-air-2-postgres-1 bash

Logging into PostgreSQL

Once you're inside the container, you can log into PostgreSQL using the psql command-line tool:

psql -U myuser -d mydatabase

When prompted, enter the password: secret

Viewing Database Tables

After logging into PostgreSQL, you can use the following commands to explore the database:

List All Tables

\dt

View Table Structure

To view the structure of a specific table:

\d+ table_name

Common SQL Commands

Here are some useful SQL commands to explore the database:

-- Count records in a table
SELECT COUNT(*) FROM table_name;

-- Exit PostgreSQL
\q

Database Schema

These tables are created and managed using Liquibase migrations defined in the application.

Spring Profiles

The application supports the following Spring profiles:

datademo

The datademo profile initializes the database with sample airport data on startup. This is useful for development and testing purposes.

To activate this profile, you can:

  1. Set the spring.profiles.active property in your application.properties file:

    spring.profiles.active=datademo
    
  2. Or pass it as a command-line argument when running the application:

    ./gradlew bootRun --args='--spring.profiles.active=datademo'
  3. Or set it as an environment variable:

    export SPRING_PROFILES_ACTIVE=datademo
    ./gradlew bootRun

When this profile is active, the application will automatically populate the database with sample airport data for major international airports.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%