Skip to content

hauserpierre/newflix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Newflix

Newflix is a personal streaming application composed of a frontend (Angular 17), a backend (Spring Boot 3), and a database (PostgreSQL) to store metadata for movies, TV shows, and episodes.

The project follows an API-first architecture: openapi.yaml at the root is the single source of truth for all API contracts. Backend Java entities and Spring interfaces, as well as frontend TypeScript models and Angular services, are generated from this file.

Prerequisites

  • Java 17+, Maven 3.8+
  • Node.js 18+, npm
  • Docker & Docker Compose (for containerised deployment)
  • A TheMovieDB API key — register at https://www.themoviedb.org

Development Setup

1. Configure environment variables

Copy the example file and fill in your values:

cp deployment/docker/.env.example deployment/docker/.env
Variable Description Required
TMDB_API_KEY Your TheMovieDB API key — get one at https://www.themoviedb.org/settings/api Yes
DATABASE_USERNAME PostgreSQL username Yes
DATABASE_PASSWORD PostgreSQL password Yes
CORS_ALLOWED_ORIGINS Comma-separated allowed origins (default: http://localhost:4200,http://localhost:8080) No

Never commit your .env file. It is already listed in .gitignore.

2. Generate code from the OpenAPI spec

After any change to openapi.yaml, regenerate backend and frontend code:

# Backend — generates JPA entities + Spring API interfaces
cd backend-service && mvn generate-sources

# Frontend — generates TypeScript models and Angular services
cd web && npm run generate:api

3. Run the backend

cd backend-service

# Local dev — uses H2 in-memory DB, no env vars needed, debug on port 5005
mvn spring-boot:run

# Run tests
mvn test

# Build JAR (skip tests)
mvn package -DskipTests

To run against a local PostgreSQL instead of H2, pass the required env vars:

SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/newflix \
SPRING_DATASOURCE_USERNAME=admin \
SPRING_DATASOURCE_PASSWORD=yourpassword \
SPRING_JPA_HIBERNATE_DDL_AUTO=none \
SPRING_FLYWAY_ENABLED=true \
SPRING_SQL_INIT_MODE=never \
mvn spring-boot:run

4. Run the frontend

cd web
npm install
ng serve           # Dev server at http://localhost:4200
npm run build      # Development build
npm run buildprod  # Production build
ng test            # Unit tests

Docker Compose Deployment

cd deployment/docker
docker-compose build
docker-compose up -d
docker-compose down

Services:

Service Port
Frontend (Nginx) 8080
Backend (Spring Boot) 8081
PostgreSQL 5432

Kubernetes / Helm Deployment

Credentials (required before install)

Sensitive values are not stored in values.yaml. Pass them at install time using --set or a local override file that you never commit.

Option A — --set flags (quick)

helm install newflix . -n newflix \
  --set secrets.dbUsername=admin \
  --set secrets.dbPassword=your_strong_password \
  --set secrets.tmdbApiKey=your_tmdb_api_key \
  -f values.yaml \
  --kubeconfig="/etc/rancher/k3s/k3s.yaml"

Option B — local values file (recommended)

Create a values.secret.yaml file (already gitignored):

# values.secret.yaml  — DO NOT COMMIT
secrets:
  dbUsername: admin
  dbPassword: your_strong_password
  tmdbApiKey: your_tmdb_api_key

Then install with both files:

helm install newflix . -n newflix \
  -f values.yaml \
  -f values.secret.yaml \
  --kubeconfig="/etc/rancher/k3s/k3s.yaml"

Helm will create a Kubernetes Secret named newflix-secrets in the namespace, and the backend and PostgreSQL pods will read credentials from it via valueFrom.secretKeyRef.

Other Helm commands

cd deployment/helm/newflix

# Render templates locally (dry run)
helm template -f values.yaml -f values.secret.yaml .

# Upgrade a running release
helm upgrade newflix . -n newflix \
  -f values.yaml \
  -f values.secret.yaml \
  --kubeconfig="/etc/rancher/k3s/k3s.yaml"

# Uninstall
helm uninstall newflix -n newflix --kubeconfig="/etc/rancher/k3s/k3s.yaml"

Traefik configuration for large file uploads

apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: upload-limit
  namespace: default
spec:
  buffering:
    maxRequestBodyBytes: 0
    maxResponseBodyBytes: 0
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-
    additionalArguments:
      - "--entryPoints.web.transport.respondingTimeouts.readTimeout=3600s"
      - "--entryPoints.web.transport.respondingTimeouts.writeTimeout=3600s"
      - "--entryPoints.web.transport.respondingTimeouts.idleTimeout=3600s"
      - "--entryPoints.websecure.transport.respondingTimeouts.readTimeout=3600s"
      - "--entryPoints.websecure.transport.respondingTimeouts.writeTimeout=3600s"
      - "--entryPoints.websecure.transport.respondingTimeouts.idleTimeout=3600s"

API Documentation

With the backend running, access the Swagger UI at:

http://localhost:8081/swagger-ui.html

The OpenAPI JSON spec is available at:

http://localhost:8081/v3/api-docs

Project Structure

newflix/
├── openapi.yaml                    # API contract (source of truth)
├── backend-service/                # Spring Boot 3 + Java 17
│   └── src/
│       └── main/java/com/picture/newflix/
│           ├── api/                # Generated Spring interfaces (do not edit)
│           ├── models/             # Generated JPA entities + FromApi records
│           ├── controllers/        # Implement generated API interfaces
│           ├── services/           # Business logic
│           └── repositories/       # Spring Data JPA repositories
└── web/                            # Angular 17 frontend
    └── src/app/
        ├── generated/              # Generated TS models + Angular services (do not edit)
        ├── components/             # UI components
        └── services/               # Angular services (use generated code)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

When modifying the API:

  1. Edit openapi.yaml first
  2. Run mvn generate-sources and npm run generate:api
  3. Update controller implementations if method signatures changed
  4. Update tests as appropriate

About

Newflix is a personal streaming application composed of a frontend (Angular 17), a backend (Spring Boot 3), and a database (PostgreSQL) to store metadata for movies, TV shows, and episodes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors