Skip to content

jinmatt/twtrgo

Repository files navigation

twtrgo

A basic twitter app to search tweets and to display user's home feed.

See demo here.

Dependencies

How to

Instructions are based on considering the repo is cloned into a Go workspace

  1. Rename dev.env as .env, set exports for environment variables for local development, including Twitter app credentials:
TWTRGO_ENV=default
PORT=8080
TWITTER_CONSUMER_KEY=<consumer-key>
TWITTER_CONSUMER_SECRET=<consumer-secret>
TWITTER_ACCESS_TOKEN=<access-token>
TWITTER_ACCESS_TOKEN_SECRET=<access-token-secret>

Otherwise export environment variables directly in terminal, whichever is preferable

  1. Install hero cli as mentioned in Dependencies. Html templates are compiled into directory http/templates. If need to recompile templates from http/templates/src run:
$ make template

Default package name will be github.com/jinmatt/twtrgo/http/template. The render functions can be found under http/template/src inside .html files(home/search/error)

  1. Build app:
$ make build
  1. Run tests:
$ make test
  1. Run app:
$ make

App starts on default port set in .env file (PORT=8080 ; https://localhost:8080)

Package Layout

The app package layout is based on an approach to scale(Ref. here).

  • twtrgo - The main package holds Tweets type and TweetService interface services should implement based on the requirements
  • twitter - implements twtrgo.TweetService interface with Twitter API client. Can be swapped out with other implementations or to use a cache/db service
  • http/handler - Handles http routes
  • services - Handles global connection/client objects like API/DB/cache objects, so they are only initialized once and destroyed once
  • config - Handles runtime configs
  • cmd/twtrgo - App binary package, inits configs, services and starts http server
  • mock - A mock package for tests, implements twtrgo.TweetService
  • test - Test package, tests only http routes(behavioral tests)

About

TwtrGo - A badly named twitter app!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published