Skip to content

About

Free, open-source platform helping 300+ CS students at Le CNAM Lebanon access 50+ course resources efficiently.

Topics

Resources

Contributing

Security policy

Stars

4 stars

Watchers

1 watching

Forks

Repository files navigation

Info Links

Centralized course resource hub for CNAM Lebanon CS students — 50+ courses, 300+ active users, served by a production Go API .

CI Go License: MIT Ask DeepWiki

infolinks.app · User guide · ADRs · Contributing

Quick start

git clone https://github.com/MohamadObeid9/Info_Links.git && cd Info_Links
cp .env.example .env   # fill DATABASE_URL, JWT_SECRET, Supabase keys
go run ./cmd/server    # → http://localhost:8080

Overview

Info Links centralizes course materials (Google Drive, Classroom, Telegram, and more) by program, year, and semester. The backend is Go (net/http, layered architecture, ~74% statement coverage across packages); the frontend is vanilla JS with Vite. Production runs as Docker on Render with CI-gated deploys.

Using the app? See the user guide.


Tech stack

Layer Technology
Frontend HTML5, CSS3, Vanilla JavaScript, Vite
Backend Go 1.26 (net/http, no web framework)
Database PostgreSQL via Supabase
Auth Supabase Auth at login → app-issued JWT for admin routes
Observability slog, Prometheus /metrics, Grafana, /healthz, /readyz
CDN Cloudflare (static assets + /api/content)
Deployment Render (Docker) + Supabase
CI GitHub Actions — test, lint, govulncheck, frontend build, docker build

Architecture

Layered backend: HTTP handlers stay thin; business rules live in services; SQL lives in repositories.

HTTP request
  → middleware (CORS, request ID, metrics, rate limit, recovery, security headers)
  → handler (internal/api)
  → service (internal/service)
  → repository (internal/repository)
  → PostgreSQL (Supabase)

The Go server also:

  • Serves the built frontend from frontend/dist (or frontend/ source in local dev when dist/ is absent)
  • Renders SSR SEO pages for /course/{code}, /program/{slug}, /courses, sitemap, and robots.txt
  • Exposes a JSON API under /api/* — see GET /api for a live endpoint directory
  • Shuts down gracefully on SIGTERM/SIGINT (waits for in-flight requests, then closes the DB pool)

Production traffic hits Cloudflare first: hashed static files and GET /api/content are cached at the edge. A 10-minute cron ping keeps /api/content warm. Origin also keeps a 60s in-memory copy (singleflight on miss) so a flood that skips the CDN does not run the JSON aggregation once per request. k6 against that origin (2026-09-01): 50-VU normal load p95 1.53 ms (100% 200); burst ~17k req/s with 99.93% 429s and p95 of allowed 200s 8.91 ms. Same-day uncached normal p95 was 4.91 s. Details: docs/load-test.md.

Deploy pipeline:

PR → GitHub Actions (test, lint, govulncheck, docker build) → merge main → Render (checksPass) → infolinks.app

Deep dives: docs/adr/ · docs/learnings/


Project structure

info_links/
├── cmd/server/           # Entry point (HTTP timeouts + graceful shutdown)
├── cmd/seed/             # Load an admin backup JSON into local Postgres
├── internal/
│   ├── api/              # Router, handlers, JSON helpers
│   ├── service/          # Validation and business logic
│   ├── repository/       # Postgres queries behind interfaces
│   ├── middleware/       # Auth, rate limit, metrics, logging, recovery
│   ├── seo/              # Server-side SEO page rendering
│   ├── config/           # Environment configuration
│   ├── database/         # DB client (pgx)
│   ├── models/           # Shared domain types
│   ├── device/           # User-Agent → phone/laptop classification
│   └── errs/             # Sentinel errors
├── frontend/             # Vanilla JS SPA (Vite for dev/build)
├── db/
│   ├── migrations/       # Versioned Postgres schema (golang-migrate + schema.sql snapshot)
│   └── README.md         # How to apply migrations locally and in CI
├── docs/
│   ├── adr/              # Architecture Decision Records
│   ├── learnings/        # Per-package engineering notes
│   ├── load-test.md      # k6 results for GET /api/content
│   └── user-guide.md     # Student and admin walkthrough
├── Dockerfile            # Multi-stage: Node build → Go build → distroless
├── docker-compose.yml    # Local Postgres + migrate + seed + app
├── .air.toml             # Go hot-reload config
└── .env.example          # Required environment variables

Getting started

Prerequisites

  • Git
  • Go 1.26+ (go.mod)
  • Node.js 20+ (frontend build and Vite dev server)
  • Supabase project with a Postgres connection string
  • Docker & Docker Compose v2.22+ (optional, for containerized dev)
  • Air (optional, for Go hot reload)

Environment

Copy .env.example to .env and fill in:

Variable Required Description
DATABASE_URL Yes Supabase Postgres connection string
JWT_SECRET Yes Secret for signing admin JWTs
SUPABASE_URL Yes Supabase project URL
SUPABASE_ANON_KEY Yes Supabase anon/public key (admin login)
PORT No Default 8080
APP_ENV No development or production
SITE_BASE_URL No Canonical URL for SEO/sitemap
CORS_ALLOWED_ORIGINS No Comma-separated origins for local Vite dev
METRICS_BASIC_AUTH_* Prod only Required when APP_ENV=production

Run locally

Fastest path — no frontend build needed (serves frontend/ source):

go run ./cmd/server

Production-like assets — includes PWA manifest and service worker:

cd frontend && npm ci && npm run build && cd ..
go run ./cmd/server

Open http://localhost:8080.


Development

Pick the workflow that matches what you're changing.

Goal Command
Fastest dev loop air + npm run dev (see below)
API work, single port go run ./cmd/server
Full stack in Docker, auto-rebuild make watch or docker compose up --watch
First run / Dockerfile changed make rebuild or docker compose up --build
Verify container builds once make build or docker compose build
Match CI image build docker build -t infolinks:local .
Restart existing containers make up or docker compose up

Native (recommended for daily coding)

Terminal 1 — Go API on port 8080:

go run ./cmd/server
# or, for Go hot reload:
air

Terminal 2 — Vite dev server on port 5173 (proxies /api and SEO routes to 8080):

cd frontend && npm ci && npm run dev
# → http://localhost:5173

Use 5173 while editing HTML/CSS/JS. Fastest feedback loop.

Docker (local app + local Postgres)

Requires Docker Compose v2.22+ (for watch). Starts Postgres, applies db/migrations, seeds db/test-data.json if the DB is empty, then the app.

make up
# or: COMPOSE_DISABLE_ENV_FILE=1 docker compose up
# → http://localhost:8080

Seeding uses -if-empty so later up does not wipe local edits. Wipe and re-seed with docker compose down -v then up again.

COMPOSE_DISABLE_ENV_FILE=1 stops Compose from treating $ in .env (for example a Supabase password) as a variable. The app still loads .env with format: raw. Or run make up.

APP_ENV=development uses LOCAL_DATABASE_URL pointing at the db service. .env still supplies JWT and Supabase Auth keys. Postgres is published on host 5432 as well (postgres://postgres:postgres@localhost:5432/infolinks?sslmode=disable) for air / go run against the same local database.

Watch (rebuild app on file changes):

make watch
# or: COMPOSE_DISABLE_ENV_FILE=1 docker compose up --watch

Build image only (same as CI):

docker build -t infolinks:local .
docker run --rm -p 8080:8080 --env-file .env infolinks:local

Testing & CI

go test -race ./cmd/... ./internal/...
golangci-lint run ./cmd/... ./internal/...
cd frontend && npm ci && npm run lint && npm test && npm run build
docker build -t infolinks:local .

Integration tests (real Postgres — repo + HTTP flows):

# Start Postgres and apply migrations (see db/README.md)
export INTEGRATION_DATABASE_URL="postgres://postgres:postgres@localhost:5432/infolinks?sslmode=disable"
migrate -path db/migrations -database "$INTEGRATION_DATABASE_URL" up
go test -tags=integration -race ./internal/integration/...

CI runs on every push/PR: Go build, unit tests with coverage, Postgres migrations, integration tests, golangci-lint, govulncheck, frontend lint/test/build, and docker build. See .github/workflows/ci.yml.

main is branch-protected — all CI jobs must pass before merge. Render deploys only after those checks pass.


Deployment

Single Docker web service on Render:

Setting Value
Runtime Docker (dockerfilePath: ./Dockerfile)
Start ENTRYPOINT ["/server"]
Health check GET /readyz
Auto-deploy On merge to main, only when CI checks pass
Domains infolinks.app, www.infolinks.app
CDN Cloudflare in front of Render

The Dockerfile is multi-stage: Node builds frontend/dist, Go compiles the server, final image runs on distroless as non-root. CI runs the same docker build before Render deploys — what is tested is what ships.

On deploy, Render sends SIGTERM. The server stops accepting new connections, drains in-flight requests (10s budget), stops the stale-guest cleanup ticker, then closes the database pool.

GET /api/content is publicly cacheable (max-age=60, stale-while-revalidate=600). Cloudflare serves most student hits; a cron request every 10 minutes keeps that cache warm. Grafana showed p95/p99 drop from multi-second spikes to a stable sub-500ms band after this went live (21 Aug 2026). Origin also caches the same JSON in process (60s TTL). Origin-only k6 after that change: normal p95 1.53 ms, burst ~17,009 req/s (docs/load-test.md).

Set environment variables in the Render dashboard (see .env.example). In production, APP_ENV=production and metrics basic auth are required for /metrics.


Documentation

Resource Description
docs/adr/ Architecture Decision Records
docs/learnings/ Engineering notes per package
docs/load-test.md k6 load test results
docs/user-guide.md Student and admin walkthrough
docs/roadmap.md Milestones and planned work
frontend/README.md Frontend layout
DEV — origin story How Info Links started
DEV — Go rebuild Backend migration write-up

Contributing

Contributions welcome — see CONTRIBUTING.md. Security issues: SECURITY.md.


Connect


License

MIT — see LICENSE.

Built by students, for students.

About

Free, open-source platform helping 300+ CS students at Le CNAM Lebanon access 50+ course resources efficiently.

Topics

Resources

Contributing

Security policy

Stars

4 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages