Giter Club home page Giter Club logo

chirp-backend's Introduction

Backend for Chirp: A Twitter clone

We created Chirp, a very simple copy of Twitter to learn about Agile Process Management, Collaboration, Web Technologies and Relational Databases. This repository contains the backend code for Chirp.

Website Frontend Repository Postman Docs Swagger Docs

The backend is built on Deno + Oak and currently deployed on Deno Deploy. It uses synchronous JWTs for authorization and a Cockroach database on Cockroach Labs. However, apart from Row-Based TTL, our implementation is compatible to PostgreSQL. The system additionally interacts with MailerSend for sending emails to users and ImageKit.io for storing user data.

The frontend repository can be found here

Servers

The API is publicly accessible using the proper user authentication.

Production Server: https://api.thechirp.de
Sandbox Server: https://sandbox.api.thechirp.de

If you stumble across a chirp.koenidv.de, it is equivalent to thechirp.de.

Running locally

  1. If you haven't already, install deno
  2. Get the .env or new keys for each environment variable
  3. Run deno run -A main.ts

Documentation

The public interactive API documentation can be found at docs.api.thechirp.de.
If you prefer using Postman, you can refer to the badge above. Please note joining the Postman Team requires manual approval.

Project Architecture

Project Architecture

Testing

Run tests using deno test --allow-read --allow-env.

Mock Server

The GET methods at and below /v1/tweet and /v1/user are available as mocked endpoints for frontend testing. Simply direct your requests to https://a092a8fb-fc57-4e0e-b09f-3f41170486b0.mock.pstmn.io.

Mocked user: halbunsichtbar
Mocked tweet: 72969718891000
Mocked comment: 73013027891000

Load Testing

Load testing is done using Locust against localhost (testing database integration) or the sandbox server.

To start Locus, use:
locust -f ./locust/locustfile.py --headless -H http://sandbox.api.thechirp.de/v1 -u 15 -r 1 -t 5m

Refer to the Locust documentation for more information.

Environment Variables

Make sure to include these paramters in your environment to make the service work:

  • DATABASE_URL - Connection string to your Cockroach database
  • JWT_KEY - 256bit synchronous key for JWT signing
  • MAILERSEND_KEY - API key for MailerSend
  • CDN_KEY - API key for ImageKit.io
  • SENTRY_DSN - DSN for Sentry

Deploying

This project is continuously deployed on Deno Deploy on pushes to main.
If you'd rather deploy on your own infrastructure, a Dockerfile is set up. However, the database will not be set up automatically and you will have to run ./db/makeTables.ts manually.

Security

Threat Model

A list of security measures implemented can be found in securitymeasures.md.

Data Model

ERD

chirp-backend's People

Contributors

koenidv avatar

Watchers

 avatar  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.