PrintSmith API (Lucky)
This repository contains a Lucky (Crystal) application scaffold and developer tooling to implement the PrintSmith Vision API described in spec.json.
Overview
- Lucky-based HTTP API scaffold (src/)
- PostgreSQL migrations (db/migrations/)
- Generator to create controller skeletons from spec.json (scripts/generate_from_swagger.cr)
- Seed helper for API user (scripts/seed_api_user.cr)
- Dockerfile and docker-compose.yml for a Linux build target and a dev Postgres service
Defaults
- DB: postgres://printsmith:printsmith@db/printsmith (docker-compose)
- App port: 3000
- Seeded API user (dev): username=apiadmin password=printsmith
- Token TTL: 24 hours
Usage (dev)
-
Build and start services docker-compose build docker-compose up -d
-
(If not auto-run) Run migrations inside the app container docker-compose exec app ./bin/migrate
-
Seed API user (if not auto-seeded) docker-compose exec app ./bin/seed_api_user --username apiadmin --password printsmith
-
Example: create token curl -X POST http://localhost:3000/api/v1/token
-H "Content-Type: application/json"
-d '{"apiUserName":"apiadmin","apiUserPassword":"printsmith"}'
Notes
- This is a scaffold and generator output. The Lucky app files are present as skeletons and the prioritized endpoints (token/account/contact/invoice/estimate) include initial implementations. The remainder of the swagger surface is generated as not-implemented skeletons.
Listing endpoints
- The full OpenAPI/Swagger spec is available at spec.json. A helper module at src/actions/api/v1/spec_endpoints.cr can list endpoints programmatically.
- Generated skeleton handlers are available in src/actions/api/v1/generated_skeletons.cr and expose operationId-based stubs that return 501 Not Implemented. These are ready to be wired into real HTTP routes.
Local server
- The project has been converted to a Lucky-compatible app. Lucky routing macros and Action classes are generated under src/actions/api/v1/.
- To build and run you need Crystal and Lucky available in the build environment (the Dockerfile installs Crystal in the builder stage and builds the app binary).
Build steps (dev): docker-compose build docker-compose up -d
Then test endpoints, e.g. POST /api/v1/token as shown above.