James Williams
Birmingham Newman University
jwilliams@staff.newman.ac.uk
3-hour session • 2 parts • 2 team tasks
30 minutes: Lecture on documentation types and best practices
45 minutes: Task 1 - Plan documentation needs
15 minutes: Break
30 minutes: Examples and templates
45 minutes: Task 2 - Create project documentation
15 minutes: Review and feedback
# StudySpace Finder
A web application that helps students find and book available study spaces across campus in real-time.

## Features
- 🔍 Search study spaces by building and capacity
- 📅 Real-time availability updates
- 🔐 Secure user authentication
- 📊 Admin dashboard for space management
## Tech Stack
**Frontend:** React 18, TypeScript, Material-UI
**Backend:** Node.js, Express, PostgreSQL
**Hosting:** Heroku
## Getting Started
### Prerequisites
- Node.js 16+
- PostgreSQL 14+
### Installation
```bash
# Clone repository
git clone https://github.com/your-team/studyspace-finder.git
cd studyspace-finder
# Install dependencies
npm install
# Setup database
createdb studyspace_db
npm run migrate
# Start development server
npm run dev
```
Visit http://localhost:3000
## Team
- Tom Johnson - Frontend Lead
- Bob Smith - Backend Lead
- Charlie Davis - Database & DevOps
## License
MIT
Explain your system design with diagrams and text.
# System Architecture
## High-Level Overview
```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ HTTPS │ │ SQL │ │
│ React │ ◄─────► │ Express │ ◄─────► │ PostgreSQL │
│ Frontend │ │ Backend │ │ Database │
│ │ │ │ │ │
└──────────────┘ └──────┬───────┘ └──────────────┘
│
│ HTTPS
▼
┌──────────────┐
│ Google Maps │
│ API │
└──────────────┘
```
## Components
### Frontend (React)
- User interface for searching and booking spaces
- Built with Material-UI components
- State management with React Context
### Backend (Express)
- REST API endpoints
- User authentication with JWT
- Business logic for bookings
### Database (PostgreSQL)
- Stores users, spaces, bookings
- Normalized schema
- Indexes on frequently queried fields
## GET /api/spaces
Get list of all study spaces.
**Query Parameters:**
- `building` (string, optional) - Filter by building name
- `capacity` (number, optional) - Minimum capacity
**Response:** 200 OK
```json
{
"spaces": [
{
"id": 1,
"name": "Room 204",
"building": "Library",
"capacity": 6,
"available": true
}
]
}
```
**Example Request:**
```bash
curl https://api.example.com/spaces?building=Library&capacity=4
```
**Errors:**
- `400` - Invalid parameters
- `500` - Server error
# ADR 001: Use PostgreSQL for Database
**Date:** 2024-10-15
**Status:** Accepted
## Context
Our application needs to store user accounts, study spaces, and bookings.
These entities have clear relationships (users → bookings → spaces), and
we need strong data consistency to prevent double-booking.
## Decision
We will use PostgreSQL as our database.
## Alternatives Considered
1. **MongoDB (NoSQL):** Good for flexible schemas, but we have fixed structure
2. **Firebase:** Easy setup, but vendor lock-in and limited querying
3. **MySQL:** Similar to PostgreSQL, but Postgres has better JSON support
## Consequences
### Positive
- ACID transactions prevent booking conflicts
- Foreign keys ensure data integrity
- Team has PostgreSQL experience
- Free tier on Heroku
### Negative
- More complex setup than Firebase
- Need to run migrations for schema changes
- Requires SQL knowledge
Detailed guide from fresh computer to running app.
// Increment i
i++;
// Check if user is null
if (user === null) {
// Return error
return error;
}
Just restating obvious code
// HACK: parseFloat returns NaN for "5%"
// so we strip the % first
const value = parseFloat(str.replace('%', ''));
// NOTE: Must validate email before
// calling sendVerification, otherwise
// API returns 500 instead of 400
validateEmail(user.email);
sendVerificationEmail(user);
// TODO: Extract to config file
const MAX_RETRIES = 3;
Explain WHY, not what
Time: 45 minutes
Deliverable: Prioritized documentation plan with assignments
Take a break. Next: Creating documentation!
Part B: Documentation Sprint
```mermaid
graph TD
A[User] -->|HTTPS| B[React Frontend]
B -->|API Calls| C[Express Backend]
C -->|SQL| D[PostgreSQL]
C -->|API Call| E[Google Maps API]
```
# Database Schema
## Tables
### users
| Column | Type | Constraints | Description |
|--------|------|-------------|-------------|
| id | SERIAL | PRIMARY KEY | Unique user ID |
| email | VARCHAR(255) | UNIQUE, NOT NULL | User email |
| password_hash | VARCHAR(255) | NOT NULL | Bcrypt hashed password |
| created_at | TIMESTAMP | DEFAULT NOW() | Account creation date |
### spaces
| Column | Type | Constraints | Description |
|--------|------|-------------|-------------|
| id | SERIAL | PRIMARY KEY | Unique space ID |
| name | VARCHAR(100) | NOT NULL | Space name (e.g., "Room 204") |
| building | VARCHAR(100) | NOT NULL | Building name |
| capacity | INTEGER | CHECK > 0 | Max occupancy |
### bookings
| Column | Type | Constraints | Description |
|--------|------|-------------|-------------|
| id | SERIAL | PRIMARY KEY | Unique booking ID |
| user_id | INTEGER | FOREIGN KEY → users(id) | Who booked |
| space_id | INTEGER | FOREIGN KEY → spaces(id) | Which space |
| start_time | TIMESTAMP | NOT NULL | Booking start |
| end_time | TIMESTAMP | NOT NULL | Booking end |
# Deployment Guide
## Heroku Deployment
### Prerequisites
- Heroku account
- Heroku CLI installed
### Steps
1. **Create Heroku app**
```bash
heroku create your-app-name
```
2. **Add PostgreSQL**
```bash
heroku addons:create heroku-postgresql:hobby-dev
```
3. **Set environment variables**
```bash
heroku config:set NODE_ENV=production
heroku config:set API_KEY=your_key_here
```
4. **Deploy**
```bash
git push heroku main
```
5. **Run migrations**
```bash
heroku run npm run migrate
```
6. **Verify**
Visit https://your-app-name.herokuapp.com
feat: add user registration endpoint
fix: prevent double booking bug
docs: update API documentation
| Criterion | Questions |
|---|---|
| Functionality | Does it work? Are core features complete? |
| Code Quality | Is code clean, tested, maintainable? |
| Architecture | Is system well-structured? |
| Documentation | Can someone else understand and run it? |
| Ethics | Is data secure? Is it accessible? |
| Team Process | Did team collaborate well? |
Time: 45 minutes
Deliverable: Complete documentation in docs/ folder
Presentation Sprint 1
Structuring technical presentations and creating demo scripts