# Ticketsystem A ticket system with backend and frontend components. ## Components - **[Backend](../backend/index.html)** - The server-side API and business logic - **[Frontend](../frontend/index.html)** - The client-side user interface ## Usage ### Prerequisite #### IMPORTANT Before compiling the programm you have to install the rust toolchain. For a guide to do this, visit: A instance of a postgresql has to be accessible to the backend. Place the connection details in a .env file into the variable `DATABASE_URL` To setup the tables you either can create them manually by following the sheme specified in `backend/migrations` or apply them with sqlx To install sqlx run `cargo install sqlx` and then in the `backend` directory run `sqlx migrate run` to create the tables ### Environment The .env file has to be in the root directory of the project or in the same directory as the executable Keys: `DATABASE_URL`: Specifying the url and connection details for the database `TOKEN_SECRET`: The JWT token secret, can theoretically be anything but is more secure when generated with a tool, e.g: `ORIGIN`: The origin of the frontend, used for CORS rules `BACKEND_PORT`: The port which the backend should use to run on ### Backend The backend can either be run via `cargo run --release` or `cargo build --release` using the correct target architecture, e.g. 'x86_64-unknown-linux-gnu', the executable will be placed in the `target/release` directory and can then be run via any method ### Frontend The HTML code for the frontend can be generated by using `trunk build`. The resulting files will end up in the `frontend/dist` directory and can be served over any webserver supporting wasm #### NOTE To install trunk run `cargo install trunk` #### IMPORTANT Requests from the frontend to /api/* have to be proxied to the Backend Example with nginx and frontend running at localhost:8000 and backend at localhost:9000 : ```nginx location /api/ { proxy_pass http://localhost:9000/api; } ``` ## Usage of AI Github Copilot CLI was used with the model Claude Haiku 4.5 to generate most of the documentation: ### Prompt Generate comments for cargo doc describing the indivilual components and create links to relevant structs, functions etc. ### Output The comments with `///` or `//!` I've gone over most of it and modified it to my needs and opinions