IvanRublev / sre-event-inc-urlshortener

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sre-event-inc-urlshortener

Running application is on https://sre-event-inc-urlshortener.fly.dev/

Architecture Canvas

Value proposition

The application shortens, persists, and redirects to URLs provided by user.

Key Stakeholder

Internet users authenticated at the website.

Core Functions

Quality Requirements

  • Scalability to handle peak loads
  • Cost-effective performance maintenance strategies
  • Robust security practices to protect data and prevent unauthorised actions

Business Context

  • The system persists shortened URLs in the PostgreSQL application sre-event-inc-urlshortener-db on Fly.io
  • Running the system on Fly.io's trial plan may affect the response times of the system

Core Decisions

  • Low test coverage inherited

Technologies

  • Elixir Phoenix/Ecto for webservice
  • bcrypt_elixir/Rustler for password hashing
  • PostgreSQL for data persistance
  • Github Actions for deployment
  • Fly.io for hosting

Components/Modules

+-----------+    +------------+
| Webserver |----| PostgreSQL |
+-----------+    +------------+

Main webserver Routes:

Method Path Purpose Authorization?
GET / Home page, to Register or Sign In No
GET /elevenlettercode/raw Shows the full URL No
GET /v/elevenlettercode Shows the shortened URL No
GET /elevenlettercode Redirects to the full URL No
GET /edit/elevenlettercode Edit the shortened URL Yes

Risks and Missing Information

  • Application doesn't collect redirection metrics
  • Application doesn't have a real-time dashboard displaying usage metrics

CI/CD Pipeline and Deployment

Deployments are made in canary mode: old instances shut down only when new instance launches successfully.

GithubActions workflow:

  • .github/workflows/fly.yml
  • .github/workflows/test-branch.yml

Fly.io schema

  • ./fly.toml

Deployment rules

  • Direct pushes to master are prohibited. You can make changes in a new branch, then make a PR to master
  • PR can be mered to master only when all tests pass

Times

  • Tests for a new branch takes ~1min
  • Deployment to production takes ~2 min

Local Setup

To start your Phoenix server:

  • Copy config/dev.secret.sample.exs to config/dev.secret.exs
  • Fill in the SMTP and database configuration in config/dev.secret.exs
  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Install Node.js dependencies with npm install inside the assets directory
  • Start Phoenix endpoint with mix phx.server

Now you can visit localhost:4000 from your browser.

Additional Documentation

About


Languages

Language:Elixir 77.5%Language:HTML 11.9%Language:CSS 5.7%Language:JavaScript 3.0%Language:Dockerfile 0.8%Language:Rust 0.6%Language:Shell 0.5%Language:Makefile 0.1%Language:Batchfile 0.0%