mirror of
https://github.com/dsec-hub/dsec-notebook.git
synced 2026-09-22 07:24:27 +00:00
added github actions and updated README
This commit is contained in:
parent
2bb77ea3ac
commit
b7ef043e6c
3 changed files with 149 additions and 27 deletions
31
.github/workflows/deploy.yml
vendored
Normal file
31
.github/workflows/deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
name: Deploy to VPS
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build and start containers
|
||||||
|
run: docker compose up -d --build --remove-orphans
|
||||||
|
|
||||||
|
- name: Prune dangling images
|
||||||
|
run: docker image prune -f
|
||||||
|
|
||||||
|
- name: Health check
|
||||||
|
run: |
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
if curl -fsS http://localhost:4073 > /dev/null; then
|
||||||
|
echo "App is up"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "App did not become healthy" >&2
|
||||||
|
exit 1
|
||||||
129
README.md
129
README.md
|
|
@ -1,42 +1,133 @@
|
||||||
# sv
|
# DSEC Notebook
|
||||||
|
|
||||||
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
A centralised resource hub for Deakin University students studying **SIT** (IT, computer science, and cybersecurity) and **Mathematics** units. Students can share study notes, ask questions, and browse content organised by unit and topic.
|
||||||
|
|
||||||
## Creating a project
|
> Written by students, for students. This project is not affiliated with Deakin University.
|
||||||
|
|
||||||
If you're seeing this, you've probably already done this step. Congrats!
|
## Features
|
||||||
|
|
||||||
|
- 📚 **Notes** — post study notes in Markdown, organised by unit and topic.
|
||||||
|
- ❓ **Questions & answers** — ask questions, post answers, and mark questions as solved.
|
||||||
|
- 💬 **Comments** — discuss notes directly.
|
||||||
|
- 👍 **Voting** — upvote or downvote notes and questions.
|
||||||
|
- 🔍 **Search** — find notes by title or content.
|
||||||
|
- 🎓 **Deakin-only sign in** — only `@deakin.edu.au` email addresses can contribute.
|
||||||
|
- 🗂️ **Units & topics** — browse content by Deakin unit code (e.g. `SIT102`, `SIT192`) or topic (e.g. Algorithms, Mathematics).
|
||||||
|
- 💾 **Persistent storage** — all data is stored in a local SQLite database.
|
||||||
|
|
||||||
|
## Tech stack
|
||||||
|
|
||||||
|
- [SvelteKit](https://svelte.dev/docs/kit) with [Svelte 5](https://svelte.dev)
|
||||||
|
- [TypeScript](https://www.typescriptlang.org/)
|
||||||
|
- [Tailwind CSS 4](https://tailwindcss.com/)
|
||||||
|
- [adapter-node](https://svelte.dev/docs/kit/adapters) for the Node.js server
|
||||||
|
- Node's built-in `node:sqlite` for persistence
|
||||||
|
- [Vitest](https://vitest.dev/) for unit and browser tests
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- [Node.js](https://nodejs.org/) 24 or newer (Node 22+ may work, but the project is developed and containerised against Node 24)
|
||||||
|
- npm
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
1. Clone the repository and install dependencies:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# create a new project
|
npm install
|
||||||
npx sv create my-app
|
|
||||||
```
|
```
|
||||||
|
|
||||||
To recreate this project with the same configuration:
|
2. Configure environment variables (optional):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# recreate this project
|
cp .env .env.local
|
||||||
npx sv@0.17.0 create --template minimal --types ts --add vitest="usages:unit,component" tailwindcss="plugins:none" --install npm .
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Developing
|
The only variable is `DATABASE_PATH`, which defaults to `data/dsec.db`.
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
3. Start the development server:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
|
||||||
npm run dev -- --open
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
4. Open the URL printed in the terminal (usually `http://localhost:5173`).
|
||||||
|
|
||||||
To create a production version of your app:
|
## Environment variables
|
||||||
|
|
||||||
|
| Variable | Description | Default |
|
||||||
|
| --------------- | --------------------------------------- | -------------- |
|
||||||
|
| `DATABASE_PATH` | Path to the SQLite database file | `data/dsec.db` |
|
||||||
|
| `HOST` | Host the Node server binds to (build) | `0.0.0.0` |
|
||||||
|
| `PORT` | Port the Node server listens on (build) | `3000` |
|
||||||
|
|
||||||
|
## Scripts
|
||||||
|
|
||||||
|
| Script | Description |
|
||||||
|
| ------------------- | ------------------------------------------- |
|
||||||
|
| `npm run dev` | Start the Vite/SvelteKit development server |
|
||||||
|
| `npm run build` | Build a production bundle |
|
||||||
|
| `npm run preview` | Preview the production build locally |
|
||||||
|
| `npm run check` | Run `svelte-check` type checking |
|
||||||
|
| `npm test` | Run unit and browser tests once |
|
||||||
|
| `npm run test:unit` | Run tests in watch mode |
|
||||||
|
|
||||||
|
## Running with Docker
|
||||||
|
|
||||||
|
A `Dockerfile` and `docker-compose.yml` are included. The app runs on port `3000` inside the container and is mapped to host port `4073`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run build
|
docker compose up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
You can preview the production build with `npm run preview`.
|
Then open `http://localhost:4073`.
|
||||||
|
|
||||||
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
The SQLite database is persisted in the `dsec-data` Docker volume. To change the exposed port, edit `docker-compose.yml`.
|
||||||
|
|
||||||
|
## Project structure
|
||||||
|
|
||||||
|
```
|
||||||
|
src/
|
||||||
|
├── lib/
|
||||||
|
│ ├── components/ # Reusable UI components (Navbar, FeedRow, VoteStack)
|
||||||
|
│ ├── server/ # Server-side API and SQLite database logic
|
||||||
|
│ ├── stores/ # Svelte stores (auth state)
|
||||||
|
│ ├── api.ts # Client-side API helper
|
||||||
|
│ ├── types.ts # Shared TypeScript types
|
||||||
|
│ └── time.ts # Relative time formatting
|
||||||
|
├── routes/
|
||||||
|
│ ├── +page.svelte # Home page
|
||||||
|
│ ├── +layout.svelte # App layout and nav
|
||||||
|
│ ├── notes/ # Notes feed and note detail pages
|
||||||
|
│ ├── questions/ # Questions feed and question detail pages
|
||||||
|
│ ├── post/ # Create note / question forms
|
||||||
|
│ ├── topics/[slug]/ # Topic pages
|
||||||
|
│ ├── units/[code]/ # Unit pages
|
||||||
|
│ ├── search/ # Search page
|
||||||
|
│ ├── auth/login/ # Sign in page
|
||||||
|
│ └── api/+server.ts # JSON API endpoint
|
||||||
|
└── app.html
|
||||||
|
```
|
||||||
|
|
||||||
|
## How it works
|
||||||
|
|
||||||
|
- The frontend calls a single JSON API endpoint (`POST /api`) with a function name and arguments.
|
||||||
|
- The server dispatches those calls to handlers in `src/lib/server/api.ts`, backed by SQLite.
|
||||||
|
- On first run, the database is created automatically and seeded with common Deakin SIT/Math units and CS/maths topics.
|
||||||
|
- Authentication is session-token based: signing in with a valid `@deakin.edu.au` email creates or reuses a user and stores a token in `localStorage`.
|
||||||
|
|
||||||
|
## Data model
|
||||||
|
|
||||||
|
The SQLite database contains the following tables:
|
||||||
|
|
||||||
|
- `users` — Deakin email accounts
|
||||||
|
- `units` — Deakin unit codes and names
|
||||||
|
- `topics` — CS and maths topics
|
||||||
|
- `notes` — shared study notes
|
||||||
|
- `questions` — student questions
|
||||||
|
- `comments` — note comments and question answers
|
||||||
|
- `votes` — upvotes/downvotes on notes and questions
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
DSEC Notebook is a community resource for Deakin University students. It is not affiliated with, endorsed by, or officially connected to Deakin University.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ services:
|
||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "4073:3000"
|
||||||
environment:
|
environment:
|
||||||
DATABASE_PATH: data/dsec.db
|
DATABASE_PATH: data/dsec.db
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue