Wednesday, June 11, 2025

Traveller System Generator Part 14 - An Attempt At Directions

Figured I'd try & put better directions on how to download and run the software that I've been working on. Especially as someone asked over on COTI. 

First, I'm using the MIT open-source license which I think is the most open. Basically, you can do anything you want with it. All the code is in GitHub here so you can click the various things there. To download a zip file of the code, you can select the "download zip" via the green Code button:

click the green <> Code button and at the bottom is download zip
This will download a zip file. Windows, Linux and Mac should all be able to open that file. It will be named "TravSystem-master.zip". Unzipping that file where you want, and you will have a top-level directory TravSystem-master.

In that directory there are several files you can ignore - I was playing with Docker so there are some files there. The other files:
  • License.txt = the license
  • readme.md = a markdown file. plain text, markdown is a lightweight formatting markup thing.
  • TravSystem.sln = the Visual Studio solution. Unless you have Visual Studio, it does not do anything for you. It is the configuration and stuff for that development environment.
  • .gitignore and .gitattributes = source control stuff.
Opening up that directory you have a bunch of folders, and several files. If you are running Windows, and using the File Explorer, you can right-click in there and open a terminal there. For a Mac you will need to open a bash shell there. For that, you just open a terminal (hmm, "just open a terminal" => hit the cmd + space bar to bring up the application launcher, start typing "terminal" and you should be able to open a terminal session. Not entirely sure you can do this directly in Finder as you can in File Explorer but that would be easier if so. Else you will need to get to where you unzipped that file. Note that for bash, the command "ls -al' will list the files, and "cd" is used to change directories. If you have questions, please leave comments and I can address those directly)
open a terminal session in the TravSystem directory

Then type in "dotnet run", and it *should* try to build the software then leave a bunch of stuff in the terminal - this is actual program running. BUT: it is a web site, and you will see in the console what port it is running on:
the web site is running!
Go to your browser of choice, and in the URL enter "localhost:5269" (note the " Now listening on: http://localhost:5269" which is just telling you that you have a service, in this case the Traveller software, listening at port 5269). 

Doing that you should now have the site up & running. It has already created your local SQLite DB in that directory.

On a Mac it should do the same - while I want to think it will attempt to download .NET if you don't already have it, I am not sure that it will. Hard to test on my Mac as I also write .NET code on there, so I installed that a while ago. If you need to install .NET 8 (which is what this runs), you can go here to download it: https://learn.microsoft.com/en-us/dotnet/core/install/macos. Pick .NET 8. Note this also works on Linux:

your OS of choice
Just closing the web site does NOT stop the application. On the terminal you started it on, use "ctl-C" to stop that process (same for Windows, Mac and Linux). 

Hopefully that helps!

Files in the TravSystem folder

This is a MVC (Model-View-Controller) type of web site. Though organized a bit differently as I tend to experiment sometimes, but should be basically recognizable to any web developer (and I still maintain I am not a web developer, but I may have to admit it sooner or later)

Controllers - this is the directory that has the various controllers. This tells the browser where to go basically. You can see that there are files for all the things we want to do: Home, TAtmosphereController.cs for all the atmosphere stuff, and so on. Each file (and they are text files so you can look around) are really pretty similar - some initialization stuff so we have database access, an index to show all the stuff, details for showing details of a specific thing and so forth. Each of those actions maps 1:1 to the views, which we'll get to in a bit.
Data is where we have data-related stuff. The Models directory has the models - the software representation of the things like law level, government and all that. The Repositories directory contains the repositories - the actual "read and get from the database" stuff. They are all pretty similar as well. We initialize them to be able to connect to the DB. The RepositoryContracts are the interfaces for the repositories. I am using dependency injection, so we need to basically be able to define a contract. If really curious I can point you to a better explanation than I can give. There is also the TravellerDbContext.cs file which basically sets up the database to be able to read the data. There is also a bunch of other things telling the system how the tables interact. 
Migrations contains the SQL scripts to update the DB. as I add and change things. we need to keep the database updated. I've set this up in the startup to automatically check. So if I make an update, and you want that, you will have to probably make a copy of the DB, save it, follow the stuff above, and stick the DB back in the TravSystem directory (Traveller.db). 
obj is the compiled code and all that and gets created when you run the software.
Properties just has a launchsettings.json file, telling how to launch the web site. I never mess with it - one of those auto-created things with .NET.
Services holds all the various services, cush as the TPlanetGenService.cs file that does the actual planet generation. 
Views contains all the views for the controllers listed above - this is where you can find the Index and Details views. A view is just a web page. Like this blog post. There is 1 folder per controller and is the actual web page. There is a Shared folder that has views common to all views. 
wwwroot contains the "public" files for the site, such as CSS, javascripts and stuff.

There are then a few files - the appsettings...json files are application settings - you can have settings per environment you run in but the one that you use is the plain appsettings.json file which really has nothing in it. Usually, you set up logging info and stuff like that. 

The big file that actually starts the site is the Program.cs file: this is where we add all those repositories and services to the dependency injection container so that they are available where we need them. It also sets up a few other things (controllers, the DB and any migrations it may need to run). There are several things I could probably remove as there is no authorization but it is boilerplate code.

Related Post

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-1-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-2-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-3-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-4-of.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-5-and.html

https://traveller-ct.blogspot.com/2025/04/traveller-system-generator-part-6.html

Part 7 towards the bottom here

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-8.html

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-9.html

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-10.html

https://traveller-ct.blogspot.com/2025/05/traveller-system-generator-part-11-and.html

https://traveller-ct.blogspot.com/2025/05/game-switching-traveller-system.html

https://traveller-ct.blogspot.com/2025/05/traveller-generator-part-13-settings.html

No comments: