Skip to content

PedroCo3lho/lightining_node_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Back-end-Coding-Challenge

API JSON built in Rust that periodically consults the Mempool lightning node state, process the data, and stores in a PostgresSQL database. The API features a GET method to retrieve the node's data from the database.

Build tools & versions used

  • PostgreSql (Supabase)
  • axum = "0.8.4"
  • tokio = "1.45.1"
  • diesel = "2.2.0"
  • chrono = "0.4.41"
  • serde = "1.0.219"
  • dotenvy = "0.15"

I chose the stack inspired by Guilherme Salustiano's talk, that showcases the Diesel Internals.

Steps to run the app

  1. Rename the .env file and configure your Database URL
mv .env.example/ .env
  1. Setup the project through the Diesel CLI
diesel setup
  1. Run the migrations
diesel migration run 
  1. Run the project
cargo run 

What was the reason for your focus? What problems were you trying to solve?

My goal was to implement the solution while learning and understanding the structure of a back-end built with this new stack. Some challenges I faced during development were:

  • Researching the stack and figuring out how to integrate all components
  • Learn how to iterate on the JSON structure (reference)
  • Type PgNumeric and DateTime in the the table struct, it was conflicting when applying serde macros

How long did you spend on this project?

I spent 4 days: the 1st day studying and choosing the stack; the 2nd day creating demos and the 3rd and 4º building the solution.

My learning repo, which includes the study materials I used and demos, can be found here:

Did you make any trade-offs for this project? What would you have done differently with more time?

  • I chose to use Supabase PostgreSQL to avoid additional local database setup.
  • Drop from Numeric type to Float in the capacity column, due to errors working with the struct and PgNumeric

With more time I would:

  • Type more the code;
  • Handle better the possible errors;
  • Containerize the solution;
  • Implement better concurrency with diesel_async and tokio::join;
  • Create tests to measure the performance, errors and security;
  • Add a telemetry feature for application monitoring.

What do you think is the weakest part of your project?

The concurrency part

Is there any other information you’d like us to know?

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors