Skip to content

Sosakpanha/Java-Spring-Boot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo API

A simple Spring Boot REST API for managing Todo items backed by Google Firebase Firestore. The project demonstrates a layered architecture with optional Firebase ID token authentication.

Overview

  • Java 17
  • Spring Boot 3.4
  • Firestore via Firebase Admin SDK
  • Layered design: controller → service → repository → Firestore

Prerequisites

  • Java 17
  • Maven
  • A Firebase project and service account JSON key

Setup

  1. In Firebase Console go to Project Settings → Service Accounts and generate a new private key JSON.
  2. Save the file and export the path:
    • macOS/Linux: export GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/service-account.json
    • Windows PowerShell: $env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\service-account.json"
  3. Edit src/main/resources/application.yml and set firebase.project-id to your project id.
  4. Run the application:
    ./mvnw spring-boot:run

To enable authentication, set security.enabled=true in application.yml. When enabled, all requests must include a Firebase ID token in the Authorization: Bearer <token> header. The UID from the token is used as the userId for stored todos.

API Examples

Create

curl -X POST http://localhost:8080/api/todos \
  -H "Content-Type: application/json" \
  -d '{"title":"Buy milk","description":"2%","priority":"HIGH","dueDate":"2025-08-20T00:00:00Z"}' -i

List

curl "http://localhost:8080/api/todos?status=OPEN&limit=5"

Get

curl http://localhost:8080/api/todos/{id}

Put

curl -X PUT http://localhost:8080/api/todos/{id} \
  -H "Content-Type: application/json" \
  -d '{"title":"Buy bread","description":"Whole grain","status":"IN_PROGRESS","priority":"MEDIUM"}'

Patch

curl -X PATCH http://localhost:8080/api/todos/{id} \
  -H "Content-Type: application/json" \
  -d '{"status":"DONE"}'

Delete

curl -X DELETE http://localhost:8080/api/todos/{id} -i

Notes

  • Search parameter q performs a simple case-insensitive contains filter on title/description after fetching results from Firestore.
  • Pagination uses a base64 encoded page token of the last document id.
  • Time fields use ISO-8601 instants.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages