Skip to content

Management app backend with REST API. Exercise for a company. Backend made with Rust's Axum. Still figuring out the frontend.

Notifications You must be signed in to change notification settings

flakelolz/management-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DISCLAIMER

Originally, I only had 2 days to finish this project and my lack of experience didn't allow me to make a good frontend so I'm figuring out what solution I should use, HTMX or React, at the moment. The frontend was a simple index.html file with a script tag at the bottom and javascript to fetch and display data.

This was a project to get selected for a 2-month long unpaid internship. I got selected.

How to run

Since this web application is just a backend made with Rust which serves an HTML, the whole application is just a binary executable.

Go to the Releases section of this repository to download the executable. https://github.com/flakelolz/management-app/releases/

Otherwise, you can build it from source if you have Rust and cargo (Rust's toolchain) installed. For that you'll need to:

  • Go to Rust's main page - https://www.rust-lang.org/learn/get-started
  • Download and install Rustup to get the Rust toolchain
  • Download the source code of this repository
  • In your terminal, navigate to the backend folder (Where the cargo.toml is)
  • Run the cargo run command in your CLI to run the backend

For the frontend, it still working from an html file served by the backend

image

How to use the app

This is an example for management app that deals with employees and projects for a company. The main page is located on http://localhost:3001/.

On the main page you add employees or projects, click an employee or project on their respective lists and update information or delete them.

For the APIs there's the following endpoints:

  • http://localhost:3001/employees
  • http://localhost:3001/projects
  • http://localhost:3001/employees/:employee_id
  • http://localhost:3001/projects/:project_id
  • http://localhost:3001/tasks
  • http://localhost:3001/tasks/:task_id
  • http://localhost:3001/tasks/employee/:employee_id
  • http://localhost:3001/tasks/project/:project_id
  • http://localhost:3001/tasks/employee/employee_id/not

With this endpoints you can perform CRUD operations from a tool that allows you to send request like https://hoppscotch.io/

API

The following API requests are valid:

  • GET to /employees, /projects or /tasks will return a list of all the respective items in the database.
  • GET to /employees/:id, /projects/:id or /tasks:id will return the item that matches the id passed through the URL.
  • POST to /employees, /projects or /tasks will create a new item when paired with a JSON payload.
    • For employees the JSON will need name: string
    • For projects the JSON will need name: string
    • For tasks the JSON will need project_id: int and employee_id: int
  • PUT to /employees/:id, /projects/:id or /tasks:id will update the information of the item that matches the id given. Send a JSON payload with the new information.
    • For employees the JSON will need name: string
    • For projects the JSON will need name: string
    • For tasks the JSON will need project_id: int and employee_id: int
  • DELETE to /employees/:id, /projects/:id or /tasks:id will delete the item that matches the id given.
  • GET to /tasks/employee/:employee_id will return all the projects (tasks) assigned to the employee ID given.
  • GET to /tasks/project/project_id will return all the employees (tasks) assigned to the project ID given.

Database

I used SQLite in memory, which means that everything added from the API after the app is running is not gong to remain after the app is closed.

If you wish to add data in a more permanent way, you can do so by writing the queries on the sql file inside the migrations folder.

About

Management app backend with REST API. Exercise for a company. Backend made with Rust's Axum. Still figuring out the frontend.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published