docs: add project setup and usage guide

This commit is contained in:
2026-04-18 11:00:00 +01:00
parent c86efa6ee5
commit 9b69be299f

213
README.md Normal file
View File

@@ -0,0 +1,213 @@
# SecureCam Final Year Project
This repository contains the current SecureCam prototype:
- `Backend/` - Bun + Express API, Better Auth, Socket.IO, Drizzle ORM, MinIO integration
- `WebApp/` - SvelteKit browser dashboard for camera and client flows
- `docker-compose.yml` - local development stack for Postgres, MinIO, TURN, backend, and web app
The easiest way to run the project is with Docker Compose. Manual setup instructions are included below if you want to run the backend and web app directly on your machine.
## Quick Start
### Prerequisites
- Docker
- Docker Compose
### Start the full local stack
From the repository root:
```bash
docker compose up --build
```
This starts:
- Postgres
- MinIO
- coturn
- Backend on `http://localhost:3000`
- Web app on `http://localhost:5173`
### Open the app
- Web app: `http://localhost:5173`
- Backend API: `http://localhost:3000`
- Swagger docs: `http://localhost:3000/docs`
- OpenAPI JSON: `http://localhost:3000/openapi.json`
- Admin dashboard: `http://localhost:3000/admin`
- MinIO console: `http://localhost:9001`
Default admin dashboard credentials:
- Username: `admin`
- Password: `strong-password`
Default MinIO credentials:
- Username: `minioadmin`
- Password: `minioadmin`
### Stop the stack
```bash
docker compose down
```
To remove volumes as well:
```bash
docker compose down -v
```
## Manual Development Setup
Use this path if you want to run the backend and web app outside Docker.
### Prerequisites
- [Bun](https://bun.sh) for the backend
- Node.js + npm for the web app
- A running Postgres instance
- A running MinIO-compatible object store
- Optional: coturn if you want the local TURN configuration to work as-is
### 1. Configure the backend
```bash
cd Backend
cp .env.example .env
```
Set the values in `Backend/.env` for your environment, especially:
- `DATABASE_URL`
- `BETTER_AUTH_SECRET`
- `BETTER_AUTH_BASE_URL`
- `BETTER_AUTH_TRUSTED_ORIGINS`
- `MINIO_ENDPOINT`
- `MINIO_PORT`
- `MINIO_USE_SSL`
- `MINIO_ACCESS_KEY`
- `MINIO_SECRET_KEY`
- `MINIO_BUCKET`
If your backend connects to MinIO on an internal hostname but the browser must upload to a different public hostname, also set:
- `MINIO_PUBLIC_ORIGIN`
Example:
```env
BETTER_AUTH_BASE_URL=http://localhost:3000
BETTER_AUTH_TRUSTED_ORIGINS=http://localhost:5173
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_USE_SSL=false
```
### 2. Install backend dependencies
```bash
cd Backend
bun install
```
### 3. Run backend migrations
```bash
cd Backend
bun run db:migrate
```
### 4. Start the backend
```bash
cd Backend
bun run dev
```
The backend will be available at `http://localhost:3000`.
### 5. Install web app dependencies
```bash
cd WebApp
npm install
```
### 6. Start the web app
```bash
cd WebApp
npm run dev
```
The web app will be available at `http://localhost:5173`.
## Useful Commands
### Docker
```bash
docker compose up --build
docker compose logs -f backend webapp
docker compose down
```
### Backend
```bash
cd Backend
bun run dev
bun test
bun run db:migrate
bun run db:studio
```
### Web app
```bash
cd WebApp
npm run dev
npm run build
npm run check
npm run test
```
## First-Time Usage
Once the app is running:
1. Open `http://localhost:5173`
2. Create an account or sign in
3. Register the browser as either a `camera` or `client` device
4. Open a second browser window or profile if you want to simulate both roles locally
The web app is the primary interface now. The old static simulator pages and mobile scaffold have been removed from the repo.
## Troubleshooting
### Browser upload fails with a MinIO URL that looks unreachable
If uploads point to an internal hostname such as `http://minio:9000`, set `MINIO_PUBLIC_ORIGIN` in the backend env to a browser-reachable MinIO host and restart the backend.
### Backend starts but MinIO checks fail
Make sure:
- the MinIO server is running
- the bucket credentials are correct
- the backend can reach the configured MinIO host
- TLS settings such as `MINIO_CA_CERT_PATH` or `MINIO_INSECURE_SKIP_TLS_VERIFY` match your environment
### TURN issues on other devices
The default compose setup uses `127.0.0.1` in coturn-related configuration. If camera and client browsers are on different devices, replace those localhost TURN references with the host machine's LAN IP.
## More Detail
- Backend setup, env, and API details: [Backend/README.md](./Backend/README.md)
- Web app source: [WebApp/](./WebApp)