From 2700955f311e3ee8eae45b65c1a4e460888de25b Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 12 Dec 2025 21:34:09 +0100 Subject: [PATCH] Moving folders --- README.md | 189 +++++------------- .env.example => api/.env.example | 0 api/README.md | 161 +++++++++++++++ {config => api/config}/config.php | 0 api/db/.gitkeep | 0 {public => api/public}/index.php | 0 {src => api/src}/Autoloader.php | 0 .../src}/Controllers/ItemController.php | 0 .../src}/Controllers/ListController.php | 0 {src => api/src}/Database.php | 0 {src => api/src}/Env.php | 0 {src => api/src}/Models/ItemModel.php | 0 {src => api/src}/Models/ListModel.php | 0 {src => api/src}/Router.php | 0 14 files changed, 209 insertions(+), 141 deletions(-) rename .env.example => api/.env.example (100%) create mode 100644 api/README.md rename {config => api/config}/config.php (100%) create mode 100644 api/db/.gitkeep rename {public => api/public}/index.php (100%) rename {src => api/src}/Autoloader.php (100%) rename {src => api/src}/Controllers/ItemController.php (100%) rename {src => api/src}/Controllers/ListController.php (100%) rename {src => api/src}/Database.php (100%) rename {src => api/src}/Env.php (100%) rename {src => api/src}/Models/ItemModel.php (100%) rename {src => api/src}/Models/ListModel.php (100%) rename {src => api/src}/Router.php (100%) diff --git a/README.md b/README.md index f614201..c1196e5 100644 --- a/README.md +++ b/README.md @@ -1,161 +1,68 @@ -# list thingy API +# List Thingy -A list thingy API using plain PHP for shopping, todos, or other lists. Users create a list instantly without any signup. -They will get a UUID and can share it with friends and collaborate on lists. This API will manage the list with API -calls and will also run a websocket the iOS and Android apps can connect to. +A collaborative list management platform for shopping, todos, and other lists. Create lists instantly without signup, share with friends via UUID, and collaborate in real-time. + +## Philosophy - No accounts - No ads - No bloat - Code that just works for 15 years -## API +## Project Structure + +This monorepo contains three components: + +### [API](./api) +Pure PHP REST API with SQLite database. Handles all list and item operations with WebSocket support for real-time collaboration. + +**Tech Stack:** +- Pure PHP 8.0+ (no frameworks) +- SQLite with PDO +- Custom PSR-4 autoloader +- .env configuration + +[See API documentation →](./api/README.md) + +## Quick Start + +### API Server + +```bash +cd api +cp .env.example .env +cd public +php -S localhost:8000 +``` + +### Mobile Apps + +Coming soon + +## Features + +- Create lists without signup +- Share lists via UUID +- Collaborative editing +- Real-time updates (WebSocket) +- Optimistic update and save +- Categorized items +- Quantity tracking +- Soft delete (items) + +## API Endpoints #### Lists - - POST /list - GET /list/{uuid} - PATCH /list/{uuid} - DELETE /list/{uuid} #### Items - - POST /list/{uuid}/item - PATCH /list/{uuid}/item/{id} - DELETE /list/{uuid}/item/{id} -## Setup +## License -### Requirements - -- PHP 8.0 or higher -- SQLite3 extension (usually included with PHP) - -### Installation - -1. Clone the repository -2. Copy `.env.example` to `.env`: - -```bash -cp .env.example .env -``` - -3. (Optional) Edit `.env` to customize configuration -4. Start the PHP development server: - -```bash -cd public -php -S localhost:8000 -``` - -The database will be automatically created on first request at `db/database.sqlite`. - -### Configuration - -All configuration is managed through the `.env` file: - -- `DB_PATH` - Path to SQLite database file (relative or absolute) -- `CORS_ALLOW_ORIGIN` - CORS allowed origins (default: `*`) -- `CORS_ALLOW_METHODS` - CORS allowed HTTP methods -- `CORS_ALLOW_HEADERS` - CORS allowed headers -- `ERROR_REPORTING` - Enable/disable error reporting (true/false) - -## Usage Examples - -### Create a List - -```bash -curl -X POST http://localhost:8000/list \ - -H "Content-Type: application/json" \ - -d '{"name":"Shopping List","sharable":true}' -``` - -Response: - -```json -{ - "success": true, - "data": { - "id": 1, - "uuid": "a1b2c3d4e5f6...", - "name": "Shopping List", - "sharable": true, - "created_at": "2025-12-12 12:00:00" - } -} -``` - -### Get a List with Items - -```bash -curl http://localhost:8000/list/{uuid} -``` - -### Update a List - -```bash -curl -X PATCH http://localhost:8000/list/{uuid} \ - -H "Content-Type: application/json" \ - -d '{"name":"Updated List Name"}' -``` - -### Delete a List - -```bash -curl -X DELETE http://localhost:8000/list/{uuid} -``` - -### Add Item to List - -```bash -curl -X POST http://localhost:8000/list/{uuid}/item \ - -H "Content-Type: application/json" \ - -d '{"name":"Milk","quantity":2.5,"category":"Dairy"}' -``` - -### Update Item - -```bash -curl -X PATCH http://localhost:8000/list/{uuid}/item/{id} \ - -H "Content-Type: application/json" \ - -d '{"quantity":3}' -``` - -### Delete Item (Soft Delete) - -```bash -curl -X DELETE http://localhost:8000/list/{uuid}/item/{id} -``` - -## Models - -#### List Model - -- id -- uuid -- name -- sharable (boolean) -- created_at - -#### Item Model - -- id -- list_id -- category -- quantity (double) -- name -- created_at -- deleted_at - -## Architecture - -Pure PHP with no dependencies: - -- **Database**: SQLite with PDO -- **Router**: Custom lightweight router -- **Structure**: Simple MVC pattern -- **CORS**: Enabled for mobile/web apps - -## WebSocket Server - -WebSocket support will be implemented separately for real-time collaboration features. \ No newline at end of file +See [LICENSE](./LICENSE) file for details. diff --git a/.env.example b/api/.env.example similarity index 100% rename from .env.example rename to api/.env.example diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..f614201 --- /dev/null +++ b/api/README.md @@ -0,0 +1,161 @@ +# list thingy API + +A list thingy API using plain PHP for shopping, todos, or other lists. Users create a list instantly without any signup. +They will get a UUID and can share it with friends and collaborate on lists. This API will manage the list with API +calls and will also run a websocket the iOS and Android apps can connect to. + +- No accounts +- No ads +- No bloat +- Code that just works for 15 years + +## API + +#### Lists + +- POST /list +- GET /list/{uuid} +- PATCH /list/{uuid} +- DELETE /list/{uuid} + +#### Items + +- POST /list/{uuid}/item +- PATCH /list/{uuid}/item/{id} +- DELETE /list/{uuid}/item/{id} + +## Setup + +### Requirements + +- PHP 8.0 or higher +- SQLite3 extension (usually included with PHP) + +### Installation + +1. Clone the repository +2. Copy `.env.example` to `.env`: + +```bash +cp .env.example .env +``` + +3. (Optional) Edit `.env` to customize configuration +4. Start the PHP development server: + +```bash +cd public +php -S localhost:8000 +``` + +The database will be automatically created on first request at `db/database.sqlite`. + +### Configuration + +All configuration is managed through the `.env` file: + +- `DB_PATH` - Path to SQLite database file (relative or absolute) +- `CORS_ALLOW_ORIGIN` - CORS allowed origins (default: `*`) +- `CORS_ALLOW_METHODS` - CORS allowed HTTP methods +- `CORS_ALLOW_HEADERS` - CORS allowed headers +- `ERROR_REPORTING` - Enable/disable error reporting (true/false) + +## Usage Examples + +### Create a List + +```bash +curl -X POST http://localhost:8000/list \ + -H "Content-Type: application/json" \ + -d '{"name":"Shopping List","sharable":true}' +``` + +Response: + +```json +{ + "success": true, + "data": { + "id": 1, + "uuid": "a1b2c3d4e5f6...", + "name": "Shopping List", + "sharable": true, + "created_at": "2025-12-12 12:00:00" + } +} +``` + +### Get a List with Items + +```bash +curl http://localhost:8000/list/{uuid} +``` + +### Update a List + +```bash +curl -X PATCH http://localhost:8000/list/{uuid} \ + -H "Content-Type: application/json" \ + -d '{"name":"Updated List Name"}' +``` + +### Delete a List + +```bash +curl -X DELETE http://localhost:8000/list/{uuid} +``` + +### Add Item to List + +```bash +curl -X POST http://localhost:8000/list/{uuid}/item \ + -H "Content-Type: application/json" \ + -d '{"name":"Milk","quantity":2.5,"category":"Dairy"}' +``` + +### Update Item + +```bash +curl -X PATCH http://localhost:8000/list/{uuid}/item/{id} \ + -H "Content-Type: application/json" \ + -d '{"quantity":3}' +``` + +### Delete Item (Soft Delete) + +```bash +curl -X DELETE http://localhost:8000/list/{uuid}/item/{id} +``` + +## Models + +#### List Model + +- id +- uuid +- name +- sharable (boolean) +- created_at + +#### Item Model + +- id +- list_id +- category +- quantity (double) +- name +- created_at +- deleted_at + +## Architecture + +Pure PHP with no dependencies: + +- **Database**: SQLite with PDO +- **Router**: Custom lightweight router +- **Structure**: Simple MVC pattern +- **CORS**: Enabled for mobile/web apps + +## WebSocket Server + +WebSocket support will be implemented separately for real-time collaboration features. \ No newline at end of file diff --git a/config/config.php b/api/config/config.php similarity index 100% rename from config/config.php rename to api/config/config.php diff --git a/api/db/.gitkeep b/api/db/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/public/index.php b/api/public/index.php similarity index 100% rename from public/index.php rename to api/public/index.php diff --git a/src/Autoloader.php b/api/src/Autoloader.php similarity index 100% rename from src/Autoloader.php rename to api/src/Autoloader.php diff --git a/src/Controllers/ItemController.php b/api/src/Controllers/ItemController.php similarity index 100% rename from src/Controllers/ItemController.php rename to api/src/Controllers/ItemController.php diff --git a/src/Controllers/ListController.php b/api/src/Controllers/ListController.php similarity index 100% rename from src/Controllers/ListController.php rename to api/src/Controllers/ListController.php diff --git a/src/Database.php b/api/src/Database.php similarity index 100% rename from src/Database.php rename to api/src/Database.php diff --git a/src/Env.php b/api/src/Env.php similarity index 100% rename from src/Env.php rename to api/src/Env.php diff --git a/src/Models/ItemModel.php b/api/src/Models/ItemModel.php similarity index 100% rename from src/Models/ItemModel.php rename to api/src/Models/ItemModel.php diff --git a/src/Models/ListModel.php b/api/src/Models/ListModel.php similarity index 100% rename from src/Models/ListModel.php rename to api/src/Models/ListModel.php diff --git a/src/Router.php b/api/src/Router.php similarity index 100% rename from src/Router.php rename to api/src/Router.php