Skip to content

Repository files navigation

Note&Sum - AI-Powered Note Management System

A Spring Boot REST API with JWT authentication, role-based access control, and AI-powered text summarization using HuggingFace API.

🚀 Features

  • JWT Authentication: Email/password signup/login with role management
  • Role-Based Access: ADMIN (see all data) vs AGENT (own data only)
  • AI Text Summarization: Async background jobs using HuggingFace BART model
  • Status Tracking: Real-time note processing status (queued → processing → done → failed)
  • PostgreSQL Integration: Full database with Flyway migrations
  • Docker Deployment: Containerized application ready for cloud deployment

🛠️ Tech Stack

  • Backend: Spring Boot 3.5.5, Spring Security, Spring Data JPA
  • Database: PostgreSQL 16 with Flyway migrations
  • AI Integration: HuggingFace Transformers API (BART-large-CNN)
  • Authentication: JWT with BCrypt password hashing
  • Containerization: Docker & Docker Compose
  • Build Tool: Maven

📋 API Endpoints

Authentication

  • POST /signup - User registration
  • POST /login - User login (returns JWT token)
  • POST /logout - User logout

Notes Management

  • POST /notes - Create note (queues AI summarization job)
  • GET / - List notes (role-based: agents see own, admins see all)
  • GET /actuator/health - Health check

Admin Dashboard

  • Web interface available at root URL for demo purposes
  • Admin users can view all users' notes and system statistics

🚀 Quick Start

Option 1: Docker Deployment (Recommended)

  1. Clone and configure

    git clone https://github.com/poxju/note-sum.git
    cd note-sum
  2. Set up environment

    # Create .env file with your values
    cat > .env <<EOFDB_PASSWORD=postgresJWT_SECRET=your-secure-256-bit-secret-key-hereJWT_EXPIRATION_MS=your-perfect-time-in-milisecs HUGGINGFACE_API_TOKEN=your_token_hereSPRING_PROFILES_ACTIVE=productionEOF
  3. Deploy with Docker

    docker-compose up -d
  4. Access the application

Option 2: Local Development

./mvnw spring-boot:run

🔧 Environment Variables

VariableDescriptionRequired
DATABASE_URLPostgreSQL connection URLYes (auto in Railway)
JWT_SECRETJWT signing secret (256+ bits)Yes
JWT_EXPIRATION_MSJWT expiration in millisecondsNo (default: 24h)
HUGGINGFACE_API_TOKENHuggingFace API tokenNo (fallback available)
SPRING_PROFILES_ACTIVESpring profileNo (default: production)
PORTServer portNo (default: 8080)

🗄️ Database Schema

Users Table

CREATETABLEusers (
id BIGSERIALPRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role VARCHAR(20) NOT NULLCHECK (role IN ('ADMIN', 'AGENT'))
);

Notes Table

CREATETABLEnotes (
id BIGSERIALPRIMARY KEY,
user_id BIGINTREFERENCES users(id),
title VARCHAR(255) NOT NULL,
content TEXTNOT NULL,
summary TEXT,
status VARCHAR(20) NOT NULL DEFAULT 'queued',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

🤖 AI Summarization Flow

  1. Create Note: POST /notes with title and content
  2. Queue Job: Note status set to "queued", async processing starts
  3. Processing: Status changes to "processing", HuggingFace API called
  4. Complete: Status becomes "done" with generated summary
  5. Error Handling: Status becomes "failed" if API call fails

🔒 Authentication & Authorization

  • First User: Automatically becomes ADMIN (just for development purposes)
  • JWT Tokens: Secure authentication with configurable expiration
  • Role-Based Access:
    • AGENT: Can only see/manage their own notes
    • ADMIN: Can view all users' notes and access admin dashboard

🚀 Cloud Deployment

Railway Deployment

Note: Railway deployment is currently not working due to configuration issues. Local Docker deployment is fully functional.

  1. Connect GitHub repository to Railway
  2. Add PostgreSQL service
  3. Set environment variables
  4. Deploy automatically on git push

Environment Setup for Production

# Railway will auto-provide DATABASE_URL
JWT_SECRET=your-256-bit-secret
HUGGINGFACE_API_TOKEN=your-hf-token
SPRING_PROFILES_ACTIVE=production

🧪 Testing the API

1. User Registration

curl -X POST http://localhost:8080/signup \

2. User Login

curl -X POST http://localhost:8080/login \

3. Create Note (with JWT)

curl -X POST http://localhost:8080/notes \

4. Check Note Status

curl http://localhost:8080/ \

📊 Monitoring

  • Health Check: /actuator/health
  • Application Info: /actuator/info
  • Docker Logs: docker-compose logs -f proksi-app

🎥 Demo

For live demonstration, access the web interface at the root URL which provides:

  • User signup/login functionality
  • Note creation with real-time AI summarization
  • Role-based dashboard views
  • Admin panel for viewing all users' data

📝 License

MIT License

About

AI-powered note management with Spring Boot, JWT auth, and HuggingFace summarization

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages