Skip to content

About

Revised Common Lectionary API, Book of Common Prayer Daily Office API, Catholic lectionary API, and liturgical calendar API.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

198 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lectio API β€” Revised Common Lectionary, Daily Office, and Catholic Lectionary API

Lectio API is a free, open-source Revised Common Lectionary API, liturgical calendar API, Book of Common Prayer Daily Office API, and Catholic lectionary API. Churches, apps, and assistants can fetch today's readings, a date's lectionary, or the current RCL year (A, B, or C) over HTTP.

curl "https://lectio-api.org/api/v1/readings/today?tradition=rcl&tz=America/New_York"

Interactive docs live at lectio-api.org/api/docs. The FAQ covers today's readings, the current RCL year, and the Daily Office (also in docs/FAQ.md). Machine-readable entry points: OpenAPI, llms.txt. A Model Context Protocol server is included for assistants (package). Built with Node.js, Express, and TypeScript.

πŸš€ Features

  • Multiple Lectionary Traditions: Support for RCL, Catholic, Episcopal/Anglican, and Lutheran traditions
  • Daily Readings: Get readings for any specific date or today's readings
  • Liturgical Calendar: Complete calendar information with seasons and special days
  • OpenAPI 3.0 Specification: Interactive API documentation with Swagger UI
  • TypeScript: Full type safety and modern development experience
  • Comprehensive Testing: Unit, integration, and end-to-end tests
  • Modern Architecture: Clean separation of concerns with controllers, services, and middleware
  • Performance Optimized: Built-in caching, compression, and rate limiting
  • Production Ready: Logging, monitoring, and deployment configuration

MCP server

A Model Context Protocol server is included in mcp-server/ and is served over official Streamable HTTP at https://lectio-api.org/mcp once this change is deployed. The health check is at /mcp/health. Local stdio (Claude Desktop, Cursor, MCPB) still works from the mcp-server package.

Canonical tools, all snake_case verb_noun, sharing date, tz, and tradition where they apply:

Tool Purpose
get_readings Readings for today, a YYYY-MM-DD date, or a startDate/endDate range
get_calendar Season, cycle, year overview, feast lookup, upcoming holy days, or factual context for a date
list_traditions Metadata for rcl, catholic, episcopal, and bcp
search_lectionary Find readings by season or feast name (not by scripture reference)

Deprecated aliases kept for one release: explore_calendar β†’ get_calendar, analyze_liturgical_context β†’ get_calendar with focus=context. Resources include lectionary://today and lectionary://traditions. Prompts include prepare_sermon_readings. See mcp-server/README.md for configuration, the tool mapping, and the registry server.json (not published until you run mcp-publisher).

πŸ“‹ Prerequisites

  • Node.js 20.0.0 or higher
  • npm or yarn
  • PostgreSQL 12+ (for production)
  • Redis (for caching, optional)

πŸ› οΈ Installation

  1. Clone the repository:
git clone https://github.com/asachs01/lectio-api.git
cd lectionary-api
  1. Install dependencies:
npm install
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
  1. Start the development server:
npm run dev

The API will be available at http://localhost:3000

πŸ“š API Documentation

Documentation Location

All detailed documentation is located in the /docs directory:

  • FAQ: /docs/FAQ.md β€” Today's readings, the current RCL year, Daily Office, and traditions (also at https://lectio-api.org/faq)
  • Database Documentation: /docs/DATABASE_*.md - Schema, setup, and optimization guides
  • Observability: /docs/OBSERVABILITY.md - Monitoring and telemetry setup
  • Migration Guide: /docs/MIGRATION_GUIDE.md - Database migration procedures
  • Entity Diagram: /docs/ENTITY_DIAGRAM.md - Database relationship diagrams

πŸ“– Interactive API Documentation

Once the server is running, access the interactive API documentation at:

  • Swagger UI: http://localhost:3000/api/docs
  • OpenAPI JSON: http://localhost:3000/api/docs.json

πŸ”§ API Endpoints

Health Check

  • GET /health - Health status of the API

Traditions

  • GET /api/v1/traditions - Get all lectionary traditions
  • GET /api/v1/traditions/:id - Get specific tradition
  • GET /api/v1/traditions/:id/seasons - Get seasons for a tradition

Readings

  • GET /api/v1/readings/today - Get today's readings
  • GET /api/v1/readings?date=YYYY-MM-DD - Get readings for a specific date
  • GET /api/v1/readings/range?start=YYYY-MM-DD&end=YYYY-MM-DD - Get readings for a date range

Calendar

  • GET /api/v1/calendar/current - Get current liturgical calendar info
  • GET /api/v1/calendar/:year - Get calendar for a specific year
  • GET /api/v1/calendar/:year/seasons - Get seasons for a year

πŸ§ͺ Testing

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

# Run type checking
npm run typecheck

# Run linting
npm run lint

πŸ—οΈ Building for Production

# Build the application
npm run build

# Start production server
npm start

πŸ” Environment Variables

Key environment variables (see .env.example for full list):

NODE_ENV=production
PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_NAME=lectionary_api
DB_USERNAME=postgres
DB_PASSWORD=your_password
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_jwt_secret

πŸ“Š Project Structure

lectionary-api/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ controllers/     # Route handlers
β”‚   β”œβ”€β”€ services/        # Business logic
β”‚   β”œβ”€β”€ models/          # Data models
β”‚   β”œβ”€β”€ middleware/      # Express middleware
β”‚   β”œβ”€β”€ routes/          # API routes
β”‚   β”œβ”€β”€ config/          # Configuration files
β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   └── types/           # TypeScript type definitions
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/           # Unit tests
β”‚   β”œβ”€β”€ integration/    # Integration tests
β”‚   └── e2e/            # End-to-end tests
β”œβ”€β”€ docs/               # Documentation
└── dist/               # Compiled JavaScript

🚒 Deployment

Docker

# Build Docker image
docker build -t lectionary-api .

# Run with Docker Compose
docker-compose up

DigitalOcean App Platform

This project is configured for automated deployment to DigitalOcean App Platform.

Prerequisites

  1. DigitalOcean Account: Create an account at DigitalOcean

  2. doctl CLI: Install the DigitalOcean command-line tool:

    # macOS
    brew install doctl
    
    # Linux
    snap install doctl
    
    # Or download from: https://docs.digitalocean.com/reference/doctl/how-to/install/
  3. Authentication: Configure doctl with your API token:

    doctl auth init

Automated Deployment Methods

Method 1: GitHub Actions (Recommended)

The project includes a GitHub Actions workflow that automatically deploys on push to the main branch.

  1. Fork or push this repository to GitHub
  2. Add your DigitalOcean API token as a GitHub secret:
    • Go to Settings β†’ Secrets and variables β†’ Actions
    • Add a new secret named DIGITALOCEAN_ACCESS_TOKEN
  3. Push to the main branch to trigger deployment
Method 2: Command-Line Deployment

Use the included deployment script for one-command deployment:

# Deploy to DigitalOcean
./scripts/deploy.sh

# View deployment logs
./scripts/deploy.sh logs

# Get app URL
./scripts/deploy.sh url

# Destroy deployment
./scripts/deploy.sh destroy
Method 3: Manual doctl Commands
# Validate app configuration
doctl apps spec validate app.yaml

# Create new app
doctl apps create --spec app.yaml

# Update existing app
APP_ID=$(doctl apps list --format ID,Name --no-header | grep "lectio-api" | awk '{print $1}')
doctl apps update $APP_ID --spec app.yaml

Configuration

The deployment is configured in app.yaml:

  • Region: NYC by default
  • Instance: Basic (512MB RAM, 1 vCPU)
  • Database: Managed PostgreSQL 15
  • Cache: Managed Redis 7
  • Auto-deploy: Enabled for main branch

Environment Variables

Production secrets should be set in the DigitalOcean dashboard:

  1. Navigate to your app in the DigitalOcean console
  2. Go to Settings β†’ App-Level Environment Variables
  3. Add the following secrets:
    • JWT_SECRET: Strong random string (32+ characters)
    • DB_PASSWORD: Will be auto-generated if using managed database
    • REDIS_URL: Will be auto-configured if using managed Redis

Post-Deployment Validation

After deployment, validate the API is working:

# Get the app URL
APP_URL=$(doctl apps get <app-id> --format DefaultIngress --no-header)

# Test health endpoint
curl https://$APP_URL/health

# Test API documentation
open https://$APP_URL/api/docs

# Test sample endpoint
curl https://$APP_URL/api/v1/traditions

Monitoring and Logs

# View real-time logs
doctl apps logs <app-id> --follow

# View deployment history
doctl apps list-deployments <app-id>

# Get app metrics
doctl apps get <app-id>

Cost Optimization

The default configuration uses:

  • App: Basic instance (~$5/month)
  • Database: Dev database (~$15/month)
  • Redis: Dev instance (~$15/month)
  • Total: ~$35/month

For production workloads, consider:

  • Upgrading to Professional instances for auto-scaling
  • Using dedicated database nodes for better performance
  • Implementing CDN for static assets

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-feature
  3. Make your changes and add tests
  4. Run tests: npm test
  5. Commit your changes: git commit -m 'Add new feature'
  6. Push to the branch: git push origin feature/new-feature
  7. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Inspired by the LectServe project
  • Built with modern web technologies and best practices
  • Designed for the global church community

For more information, visit the API documentation or contact the development team.

About

Revised Common Lectionary API, Book of Common Prayer Daily Office API, Catholic lectionary API, and liturgical calendar API.

Topics

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages