Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/yeremyacuna/LYNX/llms.txt

Use this file to discover all available pages before exploring further.

FileManager (defined in include/FileManager.h) is the persistence layer for LYNX. All data files live in the assets/ directory relative to the application’s working directory and are loaded at startup by AuthManager. Every time a record is created, updated, or deleted, the relevant manager calls the appropriate FileManager write method to keep the files in sync with the in-memory state.
AuthManager’s constructor calls FileManager methods directly to populate all in-memory structures from the assets/ files. There is no reloadAll() method — the constructor handles the full initialisation sequence automatically. Individual reload methods (reloadPassengers(), reloadDrivers(), reloadAdmins()) exist on AuthManager for selective refreshes after external file changes.

Data Files

FilenameFormatField order / Contents
passengers.txtPipe-delimited textpassengerId|name|dni|password|rating|totalTrips|totalSpent
drivers.txtPipe-delimited textdriverId|name|dni|password|rating|isAvailable|totalTrips|totalEarnings|plate|brand|model|color|year
admins.txtPipe-delimited textadminId|username|password
passwords.binBinaryFixed-width records: tipo[16], id[24], dni[16], password[32] — mirrors passengers then drivers
passwords.txtPlain textHuman-readable export generated from passwords.bin — for reference only
trips.txtPipe-delimited texttripId|origin|destination|price|tipe|status|driverName|driverDni|passengerDni|date
cities.csvCSVid,city,city_ascii,country — city identifiers and display names
connections.csvCSVfrom_id,from_city_ascii,to_id,to_city_ascii,distance_km — road connections
passwords.bin is a binary file — do not edit it manually with a text editor. Its records use fixed-size char arrays and any corruption will cause malformed reads. If the file becomes corrupted, delete it and restart the application — it will be regenerated from the current passenger and driver lists on the next saveAll() call.

Key Methods

Driver File

guardarDriversTXT
bool
Writes the entire vector<Driver> to assets/drivers.txt, one driver per line in the 13-field pipe-delimited format. Overwrites the file on each call.
bool guardarDriversTXT(const vector<Driver>& listaDeDrivers);
leerDriversTXT
vector<Driver>
Reads assets/drivers.txt line by line. Splits each line on |, expects at least 13 fields, and reconstructs the embedded Vehicle from fields 9–13. Creates the file if it does not exist.
vector<Driver> leerDriversTXT();

Passenger File

guardarPassengersTXT
bool
Writes the entire vector<Passenger> to assets/passengers.txt in the 7-field format.
bool guardarPassengersTXT(const vector<Passenger>& listaDePassengers);
leerPassengersTXT
vector<Passenger>
Reads assets/passengers.txt, expects at least 7 fields per line, and reconstructs each Passenger. Creates the file if absent.
vector<Passenger> leerPassengersTXT();

Trip File

guardarTripsTXT
bool
Writes all trips to assets/trips.txt in the 10-field pipe-delimited format.
bool guardarTripsTXT(const vector<Trip>& listaDeTrips);
leerTripsTXT
vector<Trip>
Reads assets/trips.txt. Handles both 9-field and 10-field lines to maintain backward compatibility with older file versions.
vector<Trip> leerTripsTXT();

Admin File

guardarAdminsTXT
bool
Writes the admin list to assets/admins.txt in the 3-field format.
bool guardarAdminsTXT(const vector<AdminPreview>& listaDeAdmins);
leerAdminsTXT
vector<AdminPreview>
Reads assets/admins.txt, expecting at least 3 fields. Returns an empty vector and creates the file if absent.
vector<AdminPreview> leerAdminsTXT();
generarAdminsTXT
bool
Seeds assets/admins.txt with four fixed admin accounts and 111 randomly generated accounts if the file does not yet exist. Called once in AuthManager’s constructor.
bool generarAdminsTXT();
generarIdAdmin
string
Produces a zero-padded admin ID string in the format ADM-XXX.
string generarIdAdmin(int contador);
// generarIdAdmin(5) → "ADM-005"

Password Binary File

guardarPasswordsBIN
bool
Writes fixed-size PasswordRecordBin structs (88 bytes each) to assets/passwords.bin — first all passengers, then all drivers.
bool guardarPasswordsBIN(const vector<Passenger>& passengers,
                         const vector<Driver>& drivers);
leerPasswordsBIN
vector<PasswordPreview>
Reads passwords.bin sequentially and returns a vector of human-friendly PasswordPreview structs.
vector<PasswordPreview> leerPasswordsBIN();
guardarPasswordsTXT
bool
Calls leerPasswordsBIN() and writes a plain-text version to assets/passwords.txt. Inserts a blank separator line between the passenger and driver sections.
bool guardarPasswordsTXT();

CSV Parsing for the City Graph

FileManager exposes two structs and two methods specifically for TripManager::loadCityGraph().

Structs

struct City {
    string id;       // numeric city identifier (e.g. "3936456")
    string name;     // display name / city_ascii column
    string country;
};

struct Connection {
    string idfrom;   // origin city ID
    string idto;     // destination city ID
    string from;     // origin city display name
    string to;       // destination city display name
    double weight;   // road distance in km
};

leerCitiesCSV

Reads assets/cities.csv, skipping the header row (id column). Expects at least 4 comma-separated fields per line and maps them as:
CSV column indexStruct field
0City.id
2City.name (city_ascii)
3City.country
vector<City> leerCitiesCSV();

leerConnectionsCSV

Reads assets/connections.csv, skipping the header row (from_id column). Expects at least 5 fields:
CSV column indexStruct field
0Connection.idfrom
1Connection.from
2Connection.idto
3Connection.to
4Connection.weight (parsed with stod)
vector<Connection> leerConnectionsCSV();

How TripManager Uses the CSV Data

void TripManager::loadCityGraph(FileManager& file) {
    vector<FileManager::City> ciudades = file.leerCitiesCSV();
    vector<FileManager::Connection> conexiones = file.leerConnectionsCSV();

    for (auto& c : ciudades) {
        int idx = cityGraph.addVertex(c.id);
        cityIdByDisplayName[c.name] = c.id;   // O(1) lookup by display name
    }

    for (auto& con : conexiones) {
        // Distances stored as integer units of 100 m for integer Dijkstra
        int weightInHundredMeters = (int)(con.weight * 100.0 + 0.5);
        cityGraph.addEdge(fromIdx, toIdx, weightInHundredMeters);
    }
}

Nested Public Structs

FileManager exposes three plain structs used by AuthManager as data-transfer types:
StructFieldsUsed For
PasswordPreviewtipo, id, dni, password (all strings)Reading back from the binary file
AdminPreviewid, username, passwordAdmin record in memory and in admins.txt
Cityid, name, countryCity data from cities.csv
Connectionidfrom, idto, from, to, weightRoad data from connections.csv

Field Separator

FileManager uses | (pipe) as the field separator in all text files. The constructor stores it as char separador = '|'. An alternate constructor accepts a custom separator:
FileManager();                  // uses '|'
FileManager(char _separador);   // uses the provided character

Build docs developers (and LLMs) love