Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b9ca3b4
feat: add github oAuth
var-code-5 Jun 2, 2025
115d4fa
feat:add jwt auth
var-code-5 Jun 13, 2025
1320a96
feat: add docker file
var-code-5 Jun 13, 2025
1df87d9
feat: add github featch readme
var-code-5 Jun 14, 2025
418937f
fix: frontend redirection
var-code-5 Jun 14, 2025
055402d
feat: add cors
var-code-5 Jun 14, 2025
7122e2c
feat: add options for the preflight req
var-code-5 Jun 14, 2025
f943c2d
feat: add cd on oracle
var-code-5 Jun 14, 2025
987b635
fix: cd workflow
var-code-5 Jun 14, 2025
a914759
fix: yml formating
var-code-5 Jun 14, 2025
7da87ce
feat: add redis cache
var-code-5 Jun 15, 2025
59cd247
refactor: to use docker hub image
var-code-5 Jun 15, 2025
dc39a7c
feat: add image autobuild workflow
var-code-5 Jun 15, 2025
d1dbb62
feat: add upadte and create readme routes
var-code-5 Jun 15, 2025
90dac40
fix: error handling for readme post
var-code-5 Jun 15, 2025
18623d1
fix: option token checking in middleare
var-code-5 Jun 15, 2025
6552dca
fix: exiting repo but no readme
var-code-5 Jun 15, 2025
3684c4f
fix: better logging
var-code-5 Jun 15, 2025
0f8f017
test: docker image
var-code-5 Jun 15, 2025
886440a
fix: docker image issue
var-code-5 Jun 15, 2025
78c3a52
feat: add traefik ssl
var-code-5 Jul 2, 2025
fa66557
fix: add email
var-code-5 Jul 2, 2025
952c158
fix: docker-compose indenting
var-code-5 Jul 2, 2025
2be96db
fix: cors issue using env
var-code-5 Jul 2, 2025
f606d76
feat: add widgets
var-code-5 Jul 10, 2025
caac12e
refactor: change the cors lib
var-code-5 Jul 12, 2025
ca48c7d
feat: add marketplace endpoint
var-code-5 Jul 13, 2025
84bc36f
feat: add documentation for the app
var-code-5 Aug 4, 2025
2133e76
feat: add encryption to the github tokens
var-code-5 Aug 5, 2025
3f8b723
chore: update cors
var-code-5 Aug 10, 2025
3e1d849
fix: handle cors using rs
var-code-5 Aug 10, 2025
693bf01
fix: trailing slash in cors
var-code-5 Aug 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GITHUB_CLIENT_ID=your_client_id_here
GITHUB_CLIENT_SECRET=your_client_secret_here
PROD_DOMAIN=http://localhost
LOG_LEVEL=debug
MONGODB_URI=mongodb+srv://your_mongodb_uri_here
MONGODB_DB_NAME=devBoard
JWT_REFRESH_SECRET=your_refresh_secret_here
JWT_ACCESS_SECRET=your_access_secret_here
FRONTEND_URL=http://localhost:3000
REDIS_URL=redis://localhost:6379
GH_PAT=your_github_pat_here
ENCRYPTION_KEY=your_32_byte_random_secret_key
72 changes: 72 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: "Deploy to Oracle Cloud"
on: workflow_dispatch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
varcode05/devboard-backend:latest
varcode05/devboard-backend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts

- name: Deploy to Oracle Cloud
run: |
echo "Deploying to Oracle Cloud..."
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << EOF
echo "Navigating to devboard-backend and pulling latest changes..."
cd devboard-backend
git pull

echo "Stopping existing services..."
docker compose down

echo "Setting IMAGE_TAG environment variable..."
export IMAGE_TAG=${{ github.sha }}

echo "Starting services with specific SHA tag..."
IMAGE_TAG=${{ github.sha }} docker compose up -d
EOF

- name: Cleanup SSH
if: always()
run: |
rm -f ~/.ssh/id_rsa

- name: Notify Deployment Success
run: |
cat << 'EOF'
Deployment to Oracle Cloud completed successfully.
_____ _ _
| __ \ | | | |
| | | | ___ _ __| | ___ _ _ ___ __| |
| | | |/ _ \ '_ \ |/ _ \| | | |/ _ \/ _` |
| |__| | __/ |_) | | (_) | |_| | __/ (_| |
|_____/ \___| .__/|_|\___/ \__, |\___|\__,_|
| | __/ |
|_| |___/
EOF
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
cors-test.html
localtest.go
84 changes: 66 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,107 @@
<a href="https://dscvit.com">
<img width="400" src="https://user-images.githubusercontent.com/56252312/159312411-58410727-3933-4224-b43e-4e9b627838a3.png#gh-light-mode-only" alt="GDSC VIT"/>
</a>
<h2 align="center"> < Insert Project Title Here > </h2>
<h4 align="center"> < Insert Project Description Here > <h4>
<h2 align="center"> DevBoard Backend </h2>
<h4 align="center"> A Go-based backend API service for the DevBoard application, providing authentication, GitHub integration, and marketplace functionality <h4>
</p>

---
[![Join Us](https://img.shields.io/badge/Join%20Us-Developer%20Student%20Clubs-red)](https://dsc.community.dev/vellore-institute-of-technology/)
[![Discord Chat](https://img.shields.io/discord/760928671698649098.svg)](https://discord.gg/498KVdSKWR)

[![DOCS](https://img.shields.io/badge/Documentation-see%20docs-green?style=flat-square&logo=appveyor)](INSERT_LINK_FOR_DOCS_HERE)
[![UI ](https://img.shields.io/badge/User%20Interface-Link%20to%20UI-orange?style=flat-square&logo=appveyor)](INSERT_UI_LINK_HERE)
[![DOCS](https://img.shields.io/badge/Documentation-API%20Docs-green?style=flat-square&logo=appveyor)](https://devboard.varshith.tech/api/docs)
[![UI ](https://img.shields.io/badge/User%20Interface-DevBoard%20Frontend-orange?style=flat-square&logo=appveyor)](https://devboard.varshith.tech)


## Features
- [ ] < feature >
- [ ] < feature >
- [ ] < feature >
- [ ] < feature >
- [x] GitHub OAuth Authentication
- [x] JWT-based Authorization
- [x] Redis Caching
- [x] MongoDB Integration
- [x] GitHub API Integration
- [x] Marketplace API
- [x] Widgets Management

<br>

## Dependencies
- < dependency >
- < dependency >
- Go 1.24+
- MongoDB
- Redis
- Docker & Docker Compose (for deployment)


## Running

### Prerequisites
1. Create a `.env` file in the root directory with the following environment variables:

< directions to install >
```bash
< insert code >
# Server Configuration
LOG_LEVEL=info
PORT=3000

# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=devboard

# Redis Configuration
REDIS_URL=redis://localhost:6379

# GitHub OAuth Configuration
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GH_PAT=your_github_personal_access_token

# JWT Configuration
JWT_ACCESS_SECRET=your_jwt_access_secret
JWT_REFRESH_SECRET=your_jwt_refresh_secret

# Frontend Configuration
FRONTEND_URL=http://localhost:5173
PROD_DOMAIN=devboard.example.com

# Encryption for the tokens
ENCRYPTION_KEY=your_32_byte_random_secret_key

```


### Development Setup

```bash
# Clone the repository
git clone https://github.com/var-code-5/devboard-backend.git
cd devboard-backend

# Download dependencies
go mod download

# Run the server
go run cmd/main.go
```

< directions to execute >
### Docker Deployment

```bash
< insert code >
# Build and run using Docker Compose
docker-compose up -d
```

## Contributors

<table>
<tr align="center">
<td>
John Doe
Varshith
<p align="center">
<img src = "https://dscvit.com/images/dsc-logo-square.svg" width="150" height="150" alt="Your Name Here (Insert Your Image Link In Src">
<img src="https://temp-dep.vercel.app/_next/image?url=%2Fteam%2Ftechnical%2Fvarshith.jpg&w=1920&q=75" width="150" height="150" alt="Varshith Kumar">
</p>
<p align="center">
<a href = "https://github.com/person1">
<a href = "https://github.com/var-code-5">
<img src = "http://www.iconninja.com/files/241/825/211/round-collaboration-social-github-code-circle-network-icon.svg" width="36" height = "36" alt="GitHub"/>
</a>
<a href = "https://www.linkedin.com/in/person1">
<a href = "https://www.linkedin.com/in/varshith-kumar-reddy-meda/">
<img src = "http://www.iconninja.com/files/863/607/751/network-linkedin-social-connection-circular-circle-media-icon.svg" width="36" height="36" alt="LinkedIn"/>
</a>
</p>
Expand Down
35 changes: 35 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"net/http"
"os"

log "github.com/sirupsen/logrus"

"github.com/joho/godotenv"
"github.com/var-code-5/devboard-backend/internal/routes"
)

func init() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}

log.SetOutput(os.Stdout)
// log.SetFormatter(&log.JSONFormatter{}) // Uncomment this line to use JSON format for logs

logLevel, err := log.ParseLevel(os.Getenv("LOG_LEVEL"))
if err != nil {
logLevel = log.InfoLevel
}

log.SetLevel(logLevel)
}

func main() {
router := routes.Router()
log.Info("Router initialized successfully")
log.Info("Starting server on :3000")
log.Fatal(http.ListenAndServe(":3000", router))
}
57 changes: 57 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: "3.8"
services:
traefik:
image: traefik:v2.10
command:
- --api.dashboard=true
- --api.insecure=false
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --providers.docker=true
- --certificatesresolvers.myresolver.acme.httpchallenge=true
- --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.myresolver.acme.email=varshithisgod@gmail.com
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`devboard.varshith.tech`) && PathPrefix(`/traefik-dashboard`)"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.tls.certresolver=myresolver"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=varcode:$$apr1$$3msTBU5l$$sH0xSDeZajSQ0QeV1.u1Y/"

app:
image: varcode05/devboard-backend:${IMAGE_TAG:-latest}
env_file:
- .env
volumes:
- .env:/app/.env
depends_on:
- redis
labels:
- "traefik.enable=true"
- "traefik.http.routers.app.rule=Host(`devboard.varshith.tech`)"
- "traefik.http.routers.app.entrypoints=websecure"
- "traefik.http.routers.app.tls.certresolver=myresolver"
- "traefik.http.services.app.loadbalancer.server.port=3000"
restart: always

redis:
image: redis:alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
command: redis-server --appendonly yes
restart: always

volumes:
redis-data:
letsencrypt:
34 changes: 34 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM golang:1.24-alpine AS builder

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-w -s" -o app ./cmd

# Use a minimal Alpine image for the final container
FROM alpine:3.19

# Add ca-certificates for HTTPS and timezone data
RUN apk --no-cache add ca-certificates tzdata

# Create a non-root user and group
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

# Set working directory
WORKDIR /app

# Copy the binary from the builder stage
COPY --from=builder /app/app .

# Use the non-root user
USER appuser

# Expose the port your application runs on (adjust as needed)
EXPOSE 3000

# Command to run the application
CMD ["./app"]
30 changes: 30 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module github.com/var-code-5/devboard-backend

go 1.24.3

require github.com/gorilla/mux v1.8.1

require (
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/joho/godotenv v1.5.1
github.com/redis/go-redis/v9 v9.10.0
github.com/rs/cors v1.11.1
github.com/sirupsen/logrus v1.9.3
go.mongodb.org/mongo-driver v1.17.3
)

require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.22.0 // indirect
)
Loading
Loading