Giter VIP home page Giter VIP logo

sendfiles's Introduction

sendfiles.dev

sendfiles.dev allows for encrypted, browser-to-browser file transfer using WebRTC.

Architecture

sendfiles.dev has two components - a transfer metadata store and WebRTC signalling/coordination. Each component has an API Gateway, a Lambda function and a DynamoDB database.

Transfers:

  • Transfers DynamoDB - stores metadata (filename, size, keys) for transfers, but not the file contents
  • Transfers Lambda - simple API wrapper around Transfers DynamoDB
  • Transfers API Gateway - HTTP gateway sitting in front of Transfers Lambda

Coordination:

  • Sessions DynamoDB - stores API Gateway websocket IDs of file owners so receivers can request files and coordinate WebRTC
  • Coord Lambda - allows sender/receiver to communicate in order to set up WebRTC connections
  • Coord API Gateway - Websocket gateway sitting in front of Coord Lambda, keeping websockets open

architecture diagram

Project Structure

backend/ - code for both Lambdas, written in Rust
frontend/ - webapp, written in React
scripts/ - misc helper scripts for build/deploy
terraform/ - config for all the infrastructure

Deployment

The Lambdas, API Gateways, DynamoDBs, IAM permissions and frontend S3 bucket/CloudFront distribution are deployed with Terraform:

Terraform

docker run -it --rm \
    -v "$(pwd)/terraform":/work/terraform \
    -w /work/terraform \
    -v "$HOME/.aws:/root/.aws" \
    -e AWS_PROFILE=sendfiles \
    -e AWS_DEFAULT_REGION=us-west-2 \
    --entrypoint sh \
    hashicorp/terraform:1.6

Backend

docker run -it --rm \
    -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc \
    -e RUSTFLAGS="-C target-feature=+crt-static" \
    -v "$(pwd)/backend":/src \
    -w /src \
    rust:1.75 \
    bash

apt-get -qq update && apt-get -qq install -y gcc-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-gnu
cargo build --target=aarch64-unknown-linux-gnu --release
./scripts/deploy-backend.sh

Frontend

Frontend assets are deployed to an S3 bucket fronted by CloudFront:

./scripts/deploy-statics.sh

Development

Running a Rust Lambda function locally is brutally difficult, so test in prod.

Running Frontend

docker run -it --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd)/frontend":/usr/src/app:ro \
    -w /usr/src/app \
    -p 3000:3000 \
    node:21 \
    npm run start

Prettier

docker run -it --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd)/frontend":/usr/src/app \
    -w /usr/src/app \
    node:21 \
    npx prettier --write src

Website Design

Colors: https://coolors.co/e7e247-3d3b30-4d5061-5c80bc-e9edde

Favicon: https://favicon.io/favicon-generator/

  • Font: Inconsolata
  • Font Size: 90px
  • Font Colour: #E9EDDE
  • Background Colour: #4D5061
$ mv ~/Downloads/favicon_io.zip .
$ unzip favicon_io.zip
$ mv favicon.ico frontend/public/favicon.ico
$ mv android-chrome-192x192.png frontend/public/logo192.png
$ mv android-chrome-512x512.png frontend/public/logo512.png

sendfiles's People

Contributors

jchorl avatar cybershadow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.