init commit

This commit is contained in:
Nicholas Orlowsky 2025-07-06 20:49:07 -04:00
parent d4b364716f
commit 4466021f07
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
18 changed files with 4734 additions and 2 deletions

1
.env Normal file
View file

@ -0,0 +1 @@
DB_CONNSTR=postgres://adminis:password@localhost:5432/septastic

2
api/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
target/
.env

2997
api/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

13
api/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "septastic_api"
version = "0.1.0"
edition = "2024"
[dependencies]
actix-web = "4"
anyhow = "1.0.98"
dotenv = "0.15.0"
env_logger = "0.11.8"
log = "0.4.27"
serde_json = "1.0.140"
sqlx = { version = "0.8.6", features = [ "runtime-async-std", "postgres" ] }

40
api/src/main.rs Normal file
View file

@ -0,0 +1,40 @@
use actix_web::{get, App, HttpResponse, HttpServer, Responder};
use env_logger::Env;
use log::*;
use dotenv::dotenv;
use serde_json::json;
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().json("{}")
}
#[actix_web::main]
async fn main() -> ::anyhow::Result<()> {
env_logger::init_from_env(Env::default().default_filter_or("septastic_api=info"));
dotenv().ok();
let version: &str = option_env!("CARGO_PKG_VERSION").expect("Expected package version");
info!("Starting SEPTASTIC Server v{} (commit: {})", version, "NONE");
info!("Connecting to postgres database");
let connection_string =
std::env::var("DB_CONNSTR").expect("Expected database connection string");
let pool = ::sqlx::postgres::PgPoolOptions::new()
.max_connections(5)
.connect(&connection_string)
.await?;
let mut transaction = pool.begin().await?;
HttpServer::new(|| {
App::new()
.service(hello)
})
.bind(("127.0.0.1", 8080))?
.run()
.await?;
Ok(())
}

1
data_loader Submodule

@ -0,0 +1 @@
Subproject commit d577568fec8b1b7356cd0bb0520a20283318096a

View file

@ -12,4 +12,3 @@ services:
volumes:
db:
driver: local
minio_data:

1
example.env Normal file
View file

@ -0,0 +1 @@
DB_CONNSTR=

1
libseptastic/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
target/

1583
libseptastic/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

7
libseptastic/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "libseptastic"
version = "0.1.0"
edition = "2024"
[dependencies]
sqlx = "0.8.6"

5
libseptastic/src/lib.rs Normal file
View file

@ -0,0 +1,5 @@
pub mod route;
pub mod stop;
pub mod route_stop;
pub mod stop_schedule;
pub mod schedule_day;

41
libseptastic/src/route.rs Normal file
View file

@ -0,0 +1,41 @@
#[derive(sqlx::Type, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_route_type", rename_all = "snake_case")]
pub enum RouteType {
Trolley,
SubwayElevated,
RegionalRail,
Bus,
TracklessTrolley
}
#[derive(sqlx::Type, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_direction_type", rename_all = "snake_case")]
pub enum CardinalDirection {
Northbound,
Southbound,
Eastbound,
Westbound // (and down)
}
#[derive(Debug, Clone)]
pub struct Directional {
pub direction: CardinalDirection,
pub direction_destination: String
}
#[derive(Debug, Clone)]
pub struct RouteDirectional {
pub primary: Directional, // 0
pub secondary: Directional, // 1
}
#[derive(Debug, Clone)]
pub struct Route {
pub name: String,
pub short_name: String,
pub color_hex: String,
pub route_type: RouteType,
pub id: String,
pub directional: RouteDirectional
}

View file

@ -0,0 +1,9 @@
use super::route::CardinalDirection;
#[derive(Debug, Clone)]
pub struct RouteStop {
pub route_id: String,
pub stop_id: i64,
pub direction: CardinalDirection,
pub stop_sequence: i64
}

View file

@ -0,0 +1,5 @@
#[derive(Debug, Clone)]
pub struct ScheduleDay {
pub date: String,
pub service_id: String
}

16
libseptastic/src/stop.rs Normal file
View file

@ -0,0 +1,16 @@
#[derive(sqlx::Type, PartialEq, Debug, Clone)]
#[sqlx(type_name = "septa_stop_type", rename_all = "snake_case")]
pub enum StopType {
FarSide,
MiddleBlockNearSide,
Normal
}
#[derive(Debug, Clone)]
pub struct Stop {
pub id: i64,
pub name: String,
pub lat: f64,
pub lng: f64,
pub stop_type: StopType
}

View file

@ -0,0 +1,12 @@
use super::route::CardinalDirection;
#[derive(Debug, Clone)]
pub struct StopSchedule {
pub route_id: String,
pub trip_id: String,
pub service_id: String,
pub direction: CardinalDirection,
pub arrival_time: i64,
pub stop_id: i64,
pub stop_sequence: i64
}

@ -1 +0,0 @@
Subproject commit ff2c1ce762cf0b6b1c4b0a45d5923e4d23a36bd3