Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.0
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,24 @@ help: ## Show help
@echo " make db-seed (DEPRECATED) Use 'make books' instead."
@echo " make db-setup (DEPRECATED) Use 'make setup' instead."

install: $(PIP)

$(PIP): requirements.txt
@echo "--> Creating virtual environment and installing dependencies..."
# Step 1: Ensure the virtual environment exists
$(PYTHON):
@echo "--> Creating virtual environment..."
python3 -m venv $(VENV_DIR)
@echo "Virtual environment created."

# Step 2: Ensure dependencies are installed/updated
$(PIP): requirements.txt | $(PYTHON)
@echo "--> Upgrading pip..."
$(PIP) install --upgrade pip
## pip is idempotent. It will only install what's necessary.
@echo "--> Installing dependencies..."
$(PIP) install -r requirements.txt
@echo "Installation complete."

# Install target (just an alias)
install: $(PIP)

run: $(PIP)
@echo "--> Starting Flask development server..."
$(PYTHON) -m flask --debug run
Expand Down
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ This project provides a books API that will allow users to add, retrieve, reserv
- [Contributing Guidelines](CONTRIBUTING.md)
- [License Information](LICENSE.md)

## Prerequisites
## Development Setup

Before you begin, ensure you have the following installed:
This project uses a specific version of Python. It is **highly recommended** to use `pyenv` to manage your Python versions to ensure a consistent development environment.

* **Python 3**: Version 3.7 or newer is recommended. You can download it from [python.org](https://www.python.org/downloads/).
* **pip**: Python's package installer. It usually comes with Python installations.
### 1. Prerequisites (One-time setup on your machine)

* **Homebrew:** The standard package manager for macOS. [Install it from brew.sh](https://brew.sh/).
* **`pyenv`:** A tool for managing multiple Python versions.
```bash
brew install pyenv
```
After installing, follow the on-screen instructions from Homebrew to add the `pyenv init` command to your shell's startup file (e.g., `.zshrc`).
* **make**: A build automation tool. Pre-installed on macOS/Linux. Windows users may need to install it (e.g., via Chocolatey or WSL).
* [Docker](https://formulae.brew.sh/formula/docker)
* [Colima](https://github.com/abiosoft/colima) (for Mac/Linux users)
Expand All @@ -36,7 +42,17 @@ This project uses a `Makefile` to automate setup and common tasks.
make help
```

### Step 2: Set Up and Run MongoDB
### Step 2: Install Python and Dependencies
1. **Install the correct Python version:** `pyenv` will read the `.python-version` file in this repository and know which version is needed.
```bash
pyenv install $(cat .python-version)
```
2. **Install project dependencies:** This Makefile command will automatically create a virtual environment using the correct Python version (thanks to `pyenv`) and install all required packages.
```bash
make install
```

### Step 3: Set Up and Run MongoDB

This project requires MongoDB to be running locally. We recommend using **Docker** and **Colima** for a lightweight, consistent environment.

Expand All @@ -63,15 +79,15 @@ Look for a container named mongodb with port 27017 exposed. You can also connect



### Step 3: Install Project Dependencies
### Step 4: Install Project Dependencies

The `Makefile` will create a local virtual environment (venv) and install all required Python packages. You only need to run this once.

```bash
make install
```

### Step 4: Set Up the Database
### Step 5: Set Up the Database

To perform a full database reset and populate it with initial data for development, run the main setup command:
```bash
Expand All @@ -93,7 +109,7 @@ To use the API, you first need to populate the database with some initial data.



### Step 5: Run the API
### Step 6: Run the API

With the database seeded, you can now run the Flask application.

Expand Down
2 changes: 2 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def create_app(test_config=None):
from app.routes.auth_routes import auth_bp
from app.routes.legacy_routes import register_legacy_routes
from app.routes.reservation_routes import reservations_bp
from app.routes.web_routes import web_bp

# Register routes with app instance
register_legacy_routes(app)
app.register_blueprint(auth_bp)
app.register_blueprint(reservations_bp)
app.register_blueprint(web_bp)

return app
22 changes: 22 additions & 0 deletions app/routes/web_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Routes for serving user-facing web pages.
"""

from flask import Blueprint, render_template

# Blueprint keeps routes organized
web_bp = Blueprint("web_bp", __name__)

# Commented out as not doing much right now
# @web_bp.route("/", methods=["GET"])
# def index():
# """Serves the home page."""
# # For now, shows the books list as the home page
# return render_template("books.html")


@web_bp.route("/show-books", methods=["GET"])
def show_books_page():
"""Serves the page that lists all books."""
# The actual data fetching happens via JavaScript in the template
return render_template("books.html")
2 changes: 2 additions & 0 deletions app/scss/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This path is relative to this file, pointing to the installed package
@import "../../node_modules/govuk-frontend/dist/govuk/all";
Binary file added app/static/assets/fonts/bold-affa96571d-v2.woff
Binary file not shown.
Binary file added app/static/assets/fonts/bold-b542beb274-v2.woff2
Binary file not shown.
Binary file added app/static/assets/fonts/light-94a07e06a1-v2.woff2
Binary file not shown.
Binary file added app/static/assets/fonts/light-f591b13f7d-v2.woff
Binary file not shown.
Binary file added app/static/assets/images/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions app/static/assets/images/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/static/assets/images/govuk-crest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/assets/images/govuk-icon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/assets/images/govuk-icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/assets/images/govuk-icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/static/assets/images/govuk-icon-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions app/static/assets/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"icons": [
{
"src": "images/favicon.ico",
"type": "image/x-icon",
"sizes": "48x48"
},
{
"src": "images/favicon.svg",
"type": "image/svg+xml",
"sizes": "150x150",
"purpose": "any"
},
{
"src": "images/govuk-icon-180.png",
"type": "image/png",
"sizes": "180x180",
"purpose": "maskable"
},
{
"src": "images/govuk-icon-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "maskable"
},
{
"src": "images/govuk-icon-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "images/govuk-icon-mask.svg",
"type": "image/svg+xml",
"sizes": "150x150",
"purpose": "monochrome"
}
]
}
Binary file added app/static/assets/rebrand/images/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions app/static/assets/rebrand/images/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/static/assets/rebrand/images/govuk-crest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/static/assets/rebrand/images/govuk-icon-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions app/static/assets/rebrand/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"icons": [
{
"src": "images/favicon.ico",
"type": "image/x-icon",
"sizes": "48x48"
},
{
"src": "images/favicon.svg",
"type": "image/svg+xml",
"sizes": "150x150",
"purpose": "any"
},
{
"src": "images/govuk-icon-180.png",
"type": "image/png",
"sizes": "180x180",
"purpose": "maskable"
},
{
"src": "images/govuk-icon-192.png",
"type": "image/png",
"sizes": "192x192",
"purpose": "maskable"
},
{
"src": "images/govuk-icon-512.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
},
{
"src": "images/govuk-icon-mask.svg",
"type": "image/svg+xml",
"sizes": "150x150",
"purpose": "monochrome"
}
]
}
Loading