Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1 change: 1 addition & 0 deletions .env
Copy link
Contributor

@michelleli04 michelleli04 Aug 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remember to add .envs to .gitignore at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oop didn't realize it wasn't already there, i will update

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_BASE_URL=http://localhost:8080
45 changes: 45 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: backend-lint
on:
push:
branches:
- "**"
paths:
- "backend/**"
- ".github/workflows/backend.yaml"

permissions:
contents: read
checks: write

jobs:
backend-lint:
name: backend-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: ./backend/
args: --timeout=5m

backend-tests:
name: Run backend-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Test Backend
run: |
cd backend
go test ./...
57 changes: 57 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: frontend
on:
push:
branches:
- "main"
paths:
- "frontend/**"
- ".github/workflows/frontend.yaml"
pull_request:
branches:
- "main"
paths:
- "frontend/**"
- ".github/workflows/frontend.yaml"

jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "22"

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "22"

- name: Install dependencies
run: npm install

- name: Build
run: npm run build
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should say something abt squash merge in case they are unfamiliar

Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# Contributing

## Overview

To submit changes, create a pull request and fill out the provided template. **Make sure that the pull request title is descriptive.**

## Backend PRs

If you're writing backend code, please include a screenshot of your endpoint(s) working (Postman, Insomnia, etc.). Please also include the URL of your endpoint and any parameters you passed in - this is super helpful for other developers looking to use your endpoint.

## Frontend PRs

If you're writing frontend code, please include a screenshot or screen recording of your new/updated pages.

## Review process

Once submitted, your pull request will require at least one of the tech leads' approval. Additionally, your code will be automatically linted and built using GitHub Actions. This is super important to keep our main branch clean and well-tested. Once the CI checks pass and an approval is given, you're free to merge your PR!

If your pull request is reviewed and not approved, the reviewer will leave some suggestions for changes. (Sometimes we will approve and still leave suggestions). Once you have made your changes, make sure to re-request a review and/or message one of the TLs on Slack to ensure another review.
11 changes: 11 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DB_USER=postgres.zvxatxmclijgdkvxdmbc
DB_PASSWORD=dixva5-gemrut-dAcpuz
DB_HOST=aws-1-us-east-1.pooler.supabase.com
DB_PORT=5432
DB_NAME=postgres

PORT=8080

SUPABASE_URL=https://zvxatxmclijgdkvxdmbc.supabase.co
SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2eGF0eG1jbGlqZ2RrdnhkbWJjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTY0MTM2NDEsImV4cCI6MjA3MTk4OTY0MX0.EHymLjsYov9pankPWHbyrEdwPcz__yf2SMBvMbhP3Eo
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2eGF0eG1jbGlqZ2RrdnhkbWJjIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc1NjQxMzY0MSwiZXhwIjoyMDcxOTg5NjQxfQ.0F_u8r1upt-fA4pKUrXCNY7_CfNSZuK2BQXTTBM4jeE
3 changes: 3 additions & 0 deletions backend/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["denoland.vscode-deno"]
}
24 changes: 24 additions & 0 deletions backend/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"deno.enablePaths": [
"supabase/functions"
],
"deno.lint": true,
"deno.unstable": [
"bare-node-builtins",
"byonm",
"sloppy-imports",
"unsafe-proto",
"webgpu",
"broadcast-channel",
"worker-options",
"cron",
"kv",
"ffi",
"fs",
"http",
"net"
],
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
16 changes: 16 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.23-alpine


# Set the working directory (this is /backend in Arenius)
WORKDIR /app

# Copy only go.mod and go.sum first (to cache dependencies)
COPY go.mod go.sum ./
RUN go mod download

# Copy the entire project
COPY . .

WORKDIR /app/cmd

CMD ["go", "run", "main.go"]
50 changes: 49 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# Backend README
# Special Standard Backend

## Getting Started

The backend is written in [Golang](https://go.dev/learn/) and handles code dependencies with Go modules managed within go.mod and go.sum.
In order to run the backend, the most straightforward way is to navigate to backend/cmd and execute **go run main.go** or
**go build -o main . && ./main**.

Alternatively, we will use **Docker** to build and run isolated containers to ensure that environment dependencies and runtimes are consistent across our machines.

### Steps to use Docker

Install [Docker Desktop](https://docs.docker.com/get-started/get-docker/) (or just [Docker Engine](https://docs.docker.com/engine/install/)).

In a terminal of your choice:

```bash
cd /specialstandard
docker compose up --build --watch
```

This will compose a cluster consisting of the backend and frontend containers.
Docker Watch is utilized for hot/live reloading to make development easier. The Docker Engine
watches for changes within the backend and frontend, syncs file changes from
the host to the respective container, and then restarts the respective container.

To end development, in the terminal press ctrl+c / cmd+c OR in another terminal execute:

```bash
docker compose down
```

Open <http://localhost:8080/health> with your browser to see the result. Requests *should* be logged in your terminal.

## Postman

For further development and testing, install [Postman](https://www.postman.com/downloads/), which simplifies making network requests.

## Learn More

- [Go Modules](https://faun.pub/understanding-go-mod-and-go-sum-5fd7ec9bcc34) - article about go.mod and go.sum.
- [Tour of Go](https://go.dev/tour/welcome/1) - guided tour of Golang.
- [Go Video](https://youtu.be/8uiZC0l4Ajw?si=YJq6z9nqTN-B-c8c) - fantastic build up of data structures and syntax to write a complicated API.
- [Fiber Framework](https://docs.gofiber.io/) - web framework, similar to Express, SpringBoot, Flask, FastAPI, etc.
- [Docker Engine](https://docs.docker.com/engine/) - documentation for docker building and running docker containers.
- [pgx](https://pkg.go.dev/github.com/jackc/pgx) - driver and toolkit for PostgreSQL which can be used to interact with Supabase.
- [Supabase](https://supabase.com/docs) - database hosting service, with Auth service alongside.

This tech stack is totally flexible--suggestions are welcome!
58 changes: 58 additions & 0 deletions backend/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"context"
"log"
"log/slog"
"os"
"os/signal"
"specialstandard/internal/config"
"specialstandard/internal/service"
"syscall"

"github.com/joho/godotenv"
"github.com/sethvargo/go-envconfig"
)

func main() {
err := godotenv.Load("../.env")
if err != nil {
log.Fatalf("Error loading .env file: %v", err)
return
}

var config config.Config
if err := envconfig.Process(context.Background(), &config); err != nil {
log.Fatalln("Error processing .env file: ", err)
}

app := service.InitApp(config)

// Pushing the closing of the database connection onto a
// stack of statements to be executed when this function returns.

// **Uncomment after repo connection is actually made**
// defer app.Repo.Close()

port := config.Application.Port
// Listen for connections with a goroutine.
go func() {
if err := app.Server.Listen(":" + port); err != nil {
log.Fatalf("Failed to start server: %v", err)
}
}()

quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)

// Wait for the termination signal:
<-quit

// Then shutdown server gracefully.
slog.Info("Shutting down server")
if err := app.Server.Shutdown(); err != nil {
slog.Error("failed to shutdown server", "error", err)
}

slog.Info("Server shutdown")
}
11 changes: 11 additions & 0 deletions backend/env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DB_USER=""
DB_PASSWORD=""
DB_HOST=""
DB_PORT=""
DB_NAME=""

PORT="8080"

SUPABASE_URL=""
SUPABASE_ANON_KEY=""
SUPABASE_SERVICE_ROLE_KEY=""
34 changes: 34 additions & 0 deletions backend/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module specialstandard

go 1.23.1

require (
github.com/goccy/go-json v0.10.5
github.com/gofiber/fiber/v2 v2.52.9
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.7.5
github.com/lib/pq v1.10.9
github.com/pkg/errors v0.9.1
)

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sethvargo/go-envconfig v1.3.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
)
Loading
Loading