Skip to content

Repository files navigation

🧠 Streaker Backend

Coverage Build GitHub release (latest by date)

Versions

Backend Version Frontend Version Global Version

Streaker is a habit-tracking backend designed for real-world use. Built with Java 21 and Spring Boot 3, it supports JWT authentication, Docker-based deployments, and structured logging β€” making it suitable for production-grade environments and DevOps experimentation.


πŸ“¦ Tech Stack

  • Java 21
  • Spring Boot 3
  • JWT Authentication
  • PostgreSQL
  • Hibernate, Lombok, MapStruct
  • Docker & Docker Compose
  • Splunk (logging)
  • JUnit & Mockito
  • GitHub Actions (CI)
  • PMD & JaCoCo

🧱 Architecture

[Frontend SPA]
     |
     |  HTTPS
     v
[ NGINX Reverse Proxy (SSL Termination) ]
     |
     v
[ Streaker Backend (Spring Boot) ]
     |
     | -- REST API (secured via JWT)
     |
     | -- Docker Logging (Splunk)
     |
     | -- Actuator (/health, /metrics)
     v
[ PostgreSQL DB ]

πŸš€ Getting Started (Local)

βœ… Prerequisites

  • Docker + Docker Compose
  • Java 21 (for manual development builds)

πŸ”§ Run with Docker

git clone https://github.com/MRegra/streaker-business.git
cd streaker-business/backend

# Copy environment file
cp .env.template .env

# Start backend + database + logging
docker compose up --build

Access:

  • API: http://localhost:8080
  • Splunk UI: http://localhost:8000
  • Health: http://localhost:8080/actuator/health

πŸ” Authentication

Streaker uses stateless JWT-based authentication.

Login Example

POST /api/v1/user/login
Content-Type: application/json

{
  "username": "admin",
  "password": "your-password"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR..."
}

Include this token in all secured endpoints:

Authorization: Bearer <JWT>

πŸ“„ API Overview

Full Swagger API documentation is planned.

Endpoint Method Auth Description
/api/v1/user/register POST ❌ Register new user
/api/v1/user/login POST ❌ Login & get JWT token
/api/v1/habit CRUD βœ… Manage habits
/api/v1/category CRUD βœ… Habit categories
/api/v1/streak CRUD βœ… Track habit streaks
/api/v1/log CRUD βœ… Habit activity log
/api/v1/reward CRUD βœ… Reward tracking

πŸ§ͺ Testing

Run tests:

./mvnw test

Check coverage:

open target/site/jacoco/index.html

PMD and other quality checks are configured in the build pipeline.


βš™οΈ Environment Variables

Create an .env file with these keys:

Key Description
SPRING_DATASOURCE_URL JDBC connection string
SPRING_DATASOURCE_USERNAME DB user
SPRING_DATASOURCE_PASSWORD DB password
JWT_SECRET Signing key for JWT tokens
BOOTSTRAP_ADMIN_USERNAME Default admin username
BOOTSTRAP_ADMIN_PASSWORD Default admin password
BOOTSTRAP_ADMIN_EMAIL Admin email

πŸ“Š Monitoring & Observability

  • Actuator endpoints enabled:

    • /actuator/health
    • /actuator/metrics
    • /actuator/info
  • Logs sent to Splunk

  • Prometheus + Grafana integration (in progress)

  • Structured logging planned (JSON w/ request tracing)

We use Fluent Bit + Loki + Grafana for application logging. β†’ See docs/logging-stack.md for details and justification.


πŸš€ Deployment (Contabo VPS)

Steps to deploy:

  1. Set up VPS with Docker
  2. Harden SSH & firewall (only allow ports 22, 80, 443)
  3. Clone this repository
  4. Copy .env with production secrets
  5. Run:
docker compose -f docker-compose.prod.yml up -d
  1. Use NGINX reverse proxy + Let's Encrypt for SSL termination

βœ… CI/CD Pipeline

  • GitHub Actions test pipeline

  • Runs:

    • Unit + integration tests
    • PMD checks
    • JaCoCo reports
  • Deployment integration to VPS planned


πŸ“Œ Roadmap

  • Docker + Compose setup
  • Secure backend (JWT)
  • GitHub Actions for tests
  • Logging to Splunk
  • Swagger/OpenAPI docs
  • Auth rate limiting
  • Refresh token strategy
  • Prometheus + Grafana
  • Production deploy via GitHub SSH

⚠️ License & Use

This project is open for personal use and inspiration. However, I do not offer support, contributions, or issue tracking.

Use it, fork it, break it, learn from it β€” that's the goal.


MIT Β© MRegra

Rules for commit messages:

feat: -> minor bump
fix: -> patch bump
BREAKING CHANGE: -> major bump

Commands

Full docker clean-up:

docker compose down -v --remove-orphans && docker system prune -af --volumes && docker compose build --no-cache && docker compose --profile local -f docker-compose.yml up -d
docker compose down -v --remove-orphans; docker system prune -af --volumes; docker compose build --no-cache; docker compose --profile local --profile caddy --profile watchtower -f docker-compose.yml up -d

GHCR (GitHub Container Registry) Setup

cd backend
docker build -t ghcr.io/mregra/streaker-backend:latest .

For PowerShell:

$env:CR_PAT = "your_pat_goes_year"
docker login ghcr.io -u mregra --password $env:CR_PAT
docker push ghcr.io/mregra/streaker-backend:latest

From the VPS

This one starts the watchtower:

docker compose -f docker-compose.watchtower.yml up -d

This one starts the newly created backend

docker run -d --name streaker-backend --restart always ghcr.io/mregra/streaker-backend:latest

VPS Day-One Bootstrap:

export CR_PAT=your_ghcr_token
export DISCORD_STREAKER_WEBHOOK=https://discord.com/api/webhooks/XXX

git clone https://github.com/yourusername/streaker.git
cd streaker
./infra/deploy.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages