Phantom API - Self-Generating Backend¶
A dynamic backend system that automatically creates API endpoints, database tables, and validation schemas based on JSON metadata definitions.
Features¶
- Dynamic API: Single route
/api/:resource/:action
handles all operations - Front-End as Model: Tables and schemas defined automaticaly by calling the backend.
- Advanced Relations: Foreign keys, cascading deletes, self-referencing tables
- Rich Field Types: String, text, integer, boolean, datetime, enum, JSON, email
- Zod Validation: Automatic schema generation and validation
- Role-based Auth: JWT authentication with
anon
,user
,admin
roles - Admin Interface: React-based admin panel with logs viewer
- Client Package: TypeScript NPM package for frontend integration
- Process Management: PM2 ecosystem for production deployment
- Structured Logging: Pino logger with file rotation and admin interface
- Docker: Containerized backend with persistent SQLite storage
Project Structure¶
Quick Start¶
1. Install Phantom Api¶
2. Environment Setup¶
Copy the example environment file and configure it:
Edit .env
with your configuration:
3. Start All Services with PM2¶
Services will run on: - Backend: http://localhost:3000 - API - Admin Interface: http://localhost:5173 - Admin Panel - Demo Frontend: http://localhost:5174 - Example application - Website: http://localhost:5175 - Landing Page - Documentation http://localhost:3000 - Docs
4. Alternative: Start Individual Services¶
5. Use Client Package¶
More at Client Package Doc
Docker Deployment¶
For detailed Docker configuration, see Docker Deployment.
How It Works¶
- Request: Frontend sends POST to
/api/Resource/action
- Validation: Zod schema auto-generated/validated
- Permissions: Checked against
meta/Resource.json
- Database: Table auto-created if needed
- Response: JSON with success/error status
The system use your frontend data structure and automatically: - Creates SQLite tables with appropriate column types - Generates Zod validation schemas - Sets up permission defaults - Provides admin interface for management
Perfect for rapid prototyping and dynamic applications!