Giter Club home page Giter Club logo

go-askme's Introduction

Go-ASKME Build Status

This GitHub repo has my attempt to build a web application in Go without any Web Frameworks

Introduction

The idea is a Q/A website where users can send questions to a user they follow, the user may choose to answer all or some of these questions, the answers are public to everyone.

This is not meant to be a production ready product at least initially, it is meant as an educational vehicle to learn good design principals, Go language, as well as other DevOps toolchain like Docker, Kubernetes, ...etc.

Design Goals

The code base follows Uncle Bob's Clean Architecture principals, where the code is broken down to

  1. Entities (model folder)
  2. Components
    1. Questions
    2. Answers
    3. Users
  3. Use Cases
  4. Shared

Entities

The main domain models, which in our case so far Question, Answer, User as well as base entity types and helpers, and basic domain operations on domain models using the domain ubiquitous language, like Ask, Answer, Like ... etc

Components

Each component consists of all the basic layers needed to complete this component from top to bottom, like Use Cases, Repositories, Tests

Framework

This is shaping up to be a tiny MVC framework, interesting

Dependencies

This is not meant to depend on any fat frameworks, especially web frameworks, although a couple of things were used to tie things together.

  1. Uber's dig Dependency Injection framework
  2. Buffalo's box asset management
  3. Google's UUID package
  4. joho/godotenv godotenv
  5. gorm
  6. Okta Jwt Verifier

Build and Run

  • Install Go
  • Make sure your GOPATH environment variable is set correctly
  • Clone the project in any directory outside of your $GOPATH location, this will ensure go modules work as expected, and all dependencies will be downloaded on first run
  • (Optional) Install Docker
  • Clone the repo on your machine
  • Create a new .env file using the .env.dist as a template
    • Fill in the missing secrets suitable for your environment
    • Never check in the .env file, it is already included in .gitignore, and never add actual secrets in .env.dist
  • There are two authentications methods supported
    • Basic Username / Password Auth
      • if you want to use this mode, make sure that AuthController is used in the ask.go instead of OktaController
    • Okta based auth
      • You will need to sign up for Okta developer account, more information on setting up mentioned below
  • From root of the repo on your terminal run the following command
    docker-compose -f docker-local.yml up
    
    go run main.go
  • (Optional) if you prefer Docker, run the following commands
    docker build -t go-askme .
    
    docker run --env-file=.env --rm -p 8080:8080 go-askme
  • (Optional) Use docker compose
    docker-compose build
    
    docker-compose up

Then from a browser window, navigate to http://localhost:8080

Setting up Okta Developer Account

For more up to date information make sure to read through Okta developer docs

  1. Sign up for a new Okta developer account
  2. Create a new Application
    1. Choose Web as an application type
  3. Add a login redirect URI
    1. For local development add http://localhost:8080/authorization-code/callback
  4. Add a logout redirect URI
    1. For local development add http://localhost:8080
  5. Accept other defaults, then Save
  6. Copy generated ClientID, Client Secret, and set them to corresponding OKTA_CLIENT_ID, OKTA_CLIENT_SECRET in your .env file
  7. Navigate to API > Authorization Servers
    1. Copy the default Authorization Server, and set it to OKTA_ISSUER in your .env file
    2. Click on the Trusted Origins tab
      1. Add a new origin, for local development add http://localhost:8080 as both a Redirect & CORS
  8. To enable Registration, navigate to Users > Registration
    1. Click on Enable Registration, fill in the details you need
    2. Make sure to set the Default redirect to http://localhost:8080

Want to Contribute?

All contributions are welcomed, check here for details

go-askme's People

Contributors

arezk84 avatar bashmohandes avatar mohamedelsherif-okta avatar ruthadrineda-okta avatar worldleelavivat-okta avatar

Watchers

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