Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Add SQLite database backend with REST API for locations and characters#35

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-7c7dcc34-83d1-48b4-ad9c-c843f53ad7a7
Closed

Add SQLite database backend with REST API for locations and characters#35
Copilot wants to merge 1 commit intomainfrom
copilot/fix-7c7dcc34-83d1-48b4-ad9c-c843f53ad7a7

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 25, 2025

This PR implements a complete SQLite database integration for the Armchair dialogue editor, adding persistent storage for locations and characters with a RESTful API backend.

Problem Statement

The application previously stored all data in memory using Re-frame state management with only file-based import/export capabilities. This limited data persistence and made it difficult to manage larger datasets or provide multi-user access to shared game data.

Solution Overview

Added a Node.js Express backend with SQLite database that provides REST API endpoints for locations and characters, while preserving the existing ClojureScript frontend architecture.

Backend Implementation

  • SQLite Database: Two tables with comprehensive schemas matching existing data models
    • locations: id, display_name, bounds, sprite layers, blocked positions, placements, connection triggers
    • characters: id, display_name, color, sprite file and coordinates
  • REST API Endpoints:
    • GET /api/locations - Retrieve all locations
    • GET /api/locations/:id - Retrieve specific location by ID
    • GET /api/characters - Retrieve all characters
    • GET /api/characters/:id - Retrieve specific character by ID
    • GET /api/health - Server health check
  • Data Seeding: Sample locations (Village, Tavern) and characters (Hugo, Gustav, Conni)

Frontend Integration

  • API Client: HTTP client (src/cljs/armchair/api.cljs) using fetch with async/await patterns
  • Re-frame Events: New events for loading data from API while maintaining existing state management patterns
  • React Components: New "Database View" page displaying locations and characters from the backend
  • Efficient Data Fetching: Caching utilities and individual item refresh capabilities

Key Features

  • Minimal Architecture Changes: Preserves existing ClojureScript/Re-frame patterns
  • Data Compatibility: API returns data in the same format as existing data models
  • Development Workflow: Single npm run dev starts both frontend and backend
  • Comprehensive Testing: Backend API tests verify all endpoints work correctly
  • Error Handling: Graceful fallbacks and user feedback for API failures

Database Schema

The SQLite schema supports the full complexity of the existing data models:

  • Locations store sprite layers, blocked positions, character placements, and connection triggers as JSON
  • Characters maintain color, sprite coordinates, and display names
  • All entities use UUID primary keys matching the existing system

Usage

# Start full development environment
npm run dev

# Seed database with sample data  
npm run seed

# Run API endpoint tests
npm run test:api

The "Database View" menu item provides access to the new interface showing real-time data from the SQLite backend.

![Database Integration Demo](https://github.com/user-attachments/assets/30c2957c-43c5-47e7-b277-130f83c6f947)

This implementation provides a solid foundation for data persistence while maintaining the existing editor functionality and user experience.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.clojars.org

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@maiwald maiwald closed this Aug 25, 2025
Copilot AI changed the title [WIP] Add SQLite DB with list and item queries for locations and characters Add SQLite database backend with REST API for locations and characters Aug 25, 2025
Copilot AI requested a review from maiwald August 25, 2025 21:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants