Git Product home page Git Product logo

blapchat's Introduction

Snap But Doesn't Suck

SnapChat but it doesn't suck.

Features include:

  • UI responds to taps in under 2 seconds
  • Does not use excessive amounts of RAM
  • Does not drain your battery

Server

The Server component runs the back end for the Snap But Doesnt Suck app.

Since Gradle is already used as the build system for the Android app it is used for the Server.

All server code is located in the server directory.

Database

On first setup run the dbCreate task to create a Postgres Docker container for development. You can use the dbDestroy task to delete this Docker container.

After first setup you can use the dbStart and dbStop task to manage the Postgres Docker container.

Dependency Vendoring

To vendor dependencies run the goVendor task.

To lock dependency versions run the goLock task.

Building

To build the server run the goBuild task.

You will find the output in server/.gogradle/<Platform_Name>_server

Running

To run the server run the run task.

This will automatically build the server, set run permissions on the executable, and run the executable.

Android App

The Android app is developed with Android studio. Simply import this repository into Android Studio and develop as you normally would.

blapchat's People

Contributors

noah-huppert avatar

Watchers

 avatar  avatar

blapchat's Issues

Transport idea

type TransportManager interface {
    // Start sets up a transport to begin receiving and responding to requests.
    // It should use the Invoker provider by the `invoker` argument to the run the appropriate actions when it receives events. Results from the Invoker should then be sent as responses.
    // It returns a channel which will receive exactly 1 `error` to signify Start is complete. This will be `nil` on success. Or an error if one occured while starting the transport.
    Start(invoker Invoker) <-chan error
    // Stop attempts to shut down a transport. So it will no longer send or receive messages.
    // All requests and responses are expected to be done before `ctx` times out.
    // A channel is returned which will receive exactly 1 `error` to signify Stop is complete. This will be `nil` on success. And an error if one occurs while stopping the transport.
    Stop(ctx context.Context) <-chan error
}

type Invoker interface {
    // Invoke runs the action specified by the `event` argument.
    // It returns a channel which will receive exactly one APIResp before closing to signify Invoke's completion
    Invoke(event Event) <-chan APIResp
}

Implement access control

Implement a standard access control system which guards access based on: User, Resource, Action. Find a library that already provides this functionality and integrate it with server.

Implement a middleware handler which checks an access request and store the result in metadata.

Define controller concept

A key idea in the handler system in the idea of API resources which actions can be performed on. This can be achieved by registering handlers with different actions under the same path.

A controller makes this process easier. A controller has:

  • Data
    • A path array (Similar to a handler)
    • A handler array
    • A middleware handler array
    • A middleware exclusion array
    • Specifies which handlers the middleware does not apply to via action type
    • If empty no handlers are excluded
  • Methods
    • Getters for all data
      • For the handlers provide a RawHandlers getter and a HandlersWithMiddleware getter (pseudonames, find better ones)
    • Add handler method
    • Add middleware method
    • Exclude action from middleware method
    • Test if action excluded method

All handlers in the handler array will be registered under the controllers path + their path. Additionally all handlers defined in the controller will have the same middleware applied to them.

Implement authentication

Add authentication to the server via JWTs.

  • Token struct
    • func parse(rawAuthToken string) (error, Token) to convert JWT text into a struct
    • Token struct to hold information
    • func (t Token) ToJWTString() string to convert a Token to a JWT in string form
  • Handlers
    • A handler which parses a JWT from the request if it exists and adds it to the metadata
    • A handler which will only succeed if authenticated

Figure out handler data should be unmarshalled

Determine the best setup for unmarshalling data for handlers.

  • Exact matching struct for request data
  • Unmarshall into a map[string]interface{}
    • Should these be verified versus a schema

Implement middleware

Middleware can run before a primary handler. This is done via:

  • MiddlewareHandler struct
    • Implements the Handler interface
      • Calls each of the middleware functions
      • If any middleware returns an error it is returned to the user
      • If middleware executes successfully primary handler is called
    • Contains primary handler field
    • Contains list of middleware handlers
    • Getters for all fields
    • Add method for middleware
  • Middleware handler interface
    • Defines what actions should take place when a certain piece of middleware runs
    • Similar to a regular handler: Handle(data HandlerData, metadata *Metadata) error except it can't return data
    • Instead middleware stores data via the metadata struct.

Analytics

Consider how analytics will be recorded. Current ideas:

  • Record to Prometheus
  • Middleware which at the very least records access analytics
  • Run all user ids through a 1 way hasher for anonymity
  • Response time
    • Save start time in Metadata
    • Modify endpoint handler so it has pre and post endpoints (probably a good idea anyway)

Implement Metadata

Implement the metadata struct. The purpose is to hold information about the request created by the application itself. It should provide explicit get and set methods for the following:

  • Auth data
  • Auth status
  • Verified schema's
  • Authorized event targets

Auth vs Authorized: Auth refers to authentication information, Authorized refers to permission to carry out an action at a path

Implement handler registry

A struct needs to be created that ties the whole handler system together. It should complete the following tasks:

  • Bulk register handlers for a provided controller
  • Implement the Multi Transport idea described below

Multi Transport

The Multi Transport should keep track of all other valid transports via a map[TransportType]*Transport. When it receives a request to register a handler it should proxy that request to the correct Transport in the map.

ETag caching

Save the complete checksum of resources. Make certain actions check the ETag first to see if client has latest version of resource.

Maybe cache these ETags in something like Redis as well to reduce needless DB load.

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.