Giter Site home page Giter Site logo

cvwo-be's Introduction

Gossip with Go (Backend) [22/23 CVWO Winter Assignment]

A web forum built with React and Golang.

You can find the live version of the project here. Postman API here. You can find the frontend here and its repository here.

Submission Details

Name: Loh Jian Rong

Matric No.: A0252735A

Mid-Assignment Writeup

Final Writeup PDF

Final Writeup

Getting started on your local machine

  1. Clone the reponsitory.
$ git clone [email protected]:jianrong7/cvwo-be.git
  1. Copy template env file (.env.example).
PORT=3000 # Port number that your server will listen to

DB_URI=YOUR_DB_URI # PostgreSQL DB_URI
# SAMPLE_DB_URI=postgres://USER:PASSWORD@localhost:5432/DB_NAME

JWT_SECRET=YOUR_JWT_SECRET # Random string to sign JWT Tokens

OPENAI_API=YOUR_OPENAI_API # OpenAI API Key to fetch AI generated posts

AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY # AWS S3 Key for uploading of profile pictures
AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY # AWS S3 Key for uploading of profile pictures
AWS_DEFAULT_REGION=YOUR_AWS_DEFAULT_REGION # AWS S3 Key for uploading of profile pictures
  1. Run the server!
<!-- If you have gin set up, you can use hot reload. -->
$ gin

<!-- If not, the default command would be. -->
$ go run main.go

Tools/Technologies used

  • Gin with Golang for backend framework
  • GORM for object relational mapping
  • AWS SDK to upload images to S3
  • OpenAI SDK to connect with OpenAI
  • bcrypt to hash password

Database Schema

Database schema

Project Structure

backup.sh          # Cron job to backup PostgreSQL database onto the EC2 instance.
controllers        # Handles GET, POST, PUT, DELETE logic.
initializers       # Connect database, load environment variables, start AWS and OpenAI clients.
middleware         # Contains the CORS middleware as well as the authentication middlware.
models             # Contains the models as defined by the database schema.
routes             # Contains routes to endpoints, separated by respective entities.
utils              # Contains JWT related functions.
docker-compose.yml # Dockerize application and start database image simultaneously.
Dockerfile         # To dockerize application.
main.go            # Main app file

Deployment

This app is deployed on an AWS EC2 instance. As I do not have a custom domain and I do not want to pay for one, I used a workaround to obtain HTTPS support. Since the AWS EC2 instance did not allow us to generate SSL certificates, I made use of Caddy to create a reverse proxy. This web server is also handy in giving automatic HTTPS support. That way, I do not need a custom domain for HTTPS support, albeit sacrificing the "niceness" of the URL.

cvwo-be's People

Contributors

jianrong7 avatar

Watchers

 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.