### API Blueprint Generator
Stop writing APIs twice. Write the spec once, get the working code.
-----
### ๐ Quick Start
Transform this simple Markdown specification:
````markdown
# Todo API
## Data Models
### Todo
- id: integer (primary key)
- title: string (required)
- completed: boolean (default: false)
- created_at: datetime
## Endpoints
### GET /todos
**Description**: Get all todos
**Response**:
- 200: `{"todos": [...]}`
### POST /todos
**Description**: Create a new todo
**Request Body**:
```json
{
"title": "Buy groceries"
}
````
**Response**:
- 201: `{"id": 1, "title": "Buy groceries", "completed": false}`
<!-- end list -->
````
Into a production-ready API in seconds:
```bash
pip install api-blueprint-generator
blueprint generate todo-spec.md --output todo-api
cd todo-api && docker-compose up
````
**Result**: A working Flask API with a database, validation, tests, and documentation available at `http://localhost:5000`.
-----
### ๐ฏ Why API Blueprint Generator?
**The Problem**
- Writing API documentation, then implementing the same logic again.
- Manually keeping documentation and code in sync.
- Starting every API project from scratch.
- Inconsistent patterns across team projects.
**The Solution**
- **Single Source of Truth**: One Markdown file defines everything.
- **Production Ready**: The generated code includes tests, validation, and deployment configuration.
- **Time Savings**: A 70% reduction in API scaffolding time.
- **Best Practices**: Follows established patterns for security, validation, and structure.
**What You Get**
```
๐ your-api/
โโโ ๐ app/
โ โโโ __init__.py # Flask app factory
โ โโโ models.py # SQLAlchemy models
โ โโโ routes/ # Generated endpoints
โ โโโ schemas.py # Request/response validation
โ โโโ middleware.py # Auth & rate limiting
โโโ ๐๏ธ migrations/ # Database migrations
โโโ ๐งช tests/ # Comprehensive test suite
โโโ ๐ณ docker-compose.yml # Local development setup
โโโ ๐ requirements.txt # Project dependencies
โโโ ๐ docs/ # Interactive API documentation
```
-----
### ๐ Installation
**Using pip (Recommended)**
```bash
pip install api-blueprint-generator
```
**Using Docker**
```bash
docker pull blueprintgen/api-generator
docker run -v $(pwd):/workspace blueprintgen/api-generator generate spec.md
```
**From Source**
```bash
git clone https://github.com/yourusername/api-blueprint-generator.git
cd api-blueprint-generator
pip install -e .
```
-----
### ๐ง Usage
#### Basic Generation
```bash
# Generate API from a markdown spec
blueprint generate my-api-spec.md
# Specify the output directory
blueprint generate my-api-spec.md --output my-project
# Use a different backend
blueprint generate my-api-spec.md --backend fastapi
# Include PostgreSQL setup
blueprint generate my-api-spec.md --database postgresql
```
#### Configuration File
Create a `blueprint.yml` file for project defaults:
```yaml
backend: flask # flask, fastapi
database: postgresql # sqlite, postgresql, mysql
auth_type: jwt # jwt, session, oauth, none
include_tests: true
docker_setup: true
api_prefix: "/api/v1"
cors_enabled: true
rate_limiting: true
```
#### Development Workflow
1. **Generate your API**: `blueprint generate api-spec.md --output my-api`
2. **Run locally**: `cd my-api && docker-compose up --build`
3. **Regenerate**: `blueprint generate ../api-spec.md --output . --overwrite`
4. **Run tests**: `python -m pytest tests/`
5. **Deploy**: `docker build -t my-api .`
-----
### ๐ Specification Format
**Complete Example**
````markdown
# E-commerce API
## Authentication
JWT Bearer token required for protected endpoints.
## Configuration
- Base URL: `/api/v1`
- Rate Limit: 100 requests per minute
- CORS: Enabled for all origins
## Data Models
### User
- id: integer (primary key)
- email: string (unique, required, max_length=254)
- username: string (unique, required, max_length=50)
- password: string (required, min_length=8) [write-only]
- is_active: boolean (default: true)
- created_at: datetime (auto)
- updated_at: datetime (auto)
**Relationships**:
- orders: many Order
### Product
- id: integer (primary key)
- name: string (required, max_length=200)
- description: text (nullable)
- price: decimal (required, precision=10, scale=2)
- stock: integer (default: 0)
- category_id: integer (foreign_key: Category.id)
- created_at: datetime (auto)
**Relationships**:
- category: one Category
- order_items: many OrderItem
### Order
- id: integer (primary key)
- user_id: integer (foreign_key: User.id, required)
- status: string (choices: ['pending', 'confirmed', 'shipped', 'delivered'], default: 'pending')
- total: decimal (precision=10, scale=2)
- created_at: datetime (auto)
**Relationships**:
- user: one User
- order_items: many OrderItem
## Endpoints
### POST /auth/register
**Description**: Register a new user
**Public**: true
**Request Body**:
```json
{
"email": "user@example.com",
"username": "johndoe",
"password": "secretpassword"
}
````
**Response**:
- 201: `{"id": 1, "email": "user@example.com", "username": "johndoe"}`
- 400: `{"error": "Email already exists"}`
### POST /auth/login
**Description**: Authenticate user and return JWT token
**Public**: true
**Request Body**:
```json
{
"email": "user@example.com",
"password": "secretpassword"
}
```
**Response**:
- 200: `{"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...", "user": {...}}`
- 401: `{"error": "Invalid credentials"}`
### GET /users/me
**Description**: Get current user profile
**Authentication**: required
**Response**:
- 200: `{"id": 1, "email": "user@example.com", "username": "johndoe"}`
- 401: `{"error": "Authentication required"}`
### GET /products
**Description**: List products with filtering and pagination
**Public**: true
**Parameters**:
- page: integer (default: 1, min: 1)
- limit: integer (default: 20, min: 1, max: 100)
- category: string (optional)
- min\_price: decimal (optional)
- max\_price: decimal (optional)
- search: string (optional, searches name and description)
**Response**:
- 200: `{"products": [...], "total": 150, "page": 1, "pages": 8}`
### POST /products
**Description**: Create a new product (admin only)
**Authentication**: required
**Permissions**: admin
**Request Body**:
```json
{
"name": "Laptop",
"description": "High-performance laptop",
"price": 999.99,
"stock": 10,
"category_id": 1
}
```
**Response**:
- 201: `{"id": 1, "name": "Laptop", ...}`
- 400: `{"error": "Validation failed", "details": {...}}`
- 403: `{"error": "Admin access required"}`
### GET /products/{id}
**Description**: Get product by ID
**Public**: true
**Parameters**:
- id: integer (path parameter, required)
**Response**:
- 200: `{"id": 1, "name": "Laptop", ...}`
- 404: `{"error": "Product not found"}`
### PUT /products/{id}
**Description**: Update product (admin only)
**Authentication**: required
**Permissions**: admin
**Parameters**:
- id: integer (path parameter, required)
**Request Body**: Same as POST /products
**Response**:
- 200: `{"id": 1, "name": "Updated Laptop", ...}`
- 404: `{"error": "Product not found"}`
- 403: `{"error": "Admin access required"}`
### DELETE /products/{id}
**Description**: Delete product (admin only)
**Authentication**: required
**Permissions**: admin
**Parameters**:
- id: integer (path parameter, required)
**Response**:
- 204: No content
- 404: `{"error": "Product not found"}`
### POST /orders
**Description**: Create a new order
**Authentication**: required
**Request Body**:
```json
{
"items": [
{"product_id": 1, "quantity": 2},
{"product_id": 2, "quantity": 1}
]
}
```
**Response**:
- 201: `{"id": 1, "status": "pending", "total": 1999.98, "items": [...]}`
- 400: `{"error": "Invalid product or insufficient stock"}`
### GET /orders
**Description**: Get user's orders
**Authentication**: required
**Parameters**:
- page: integer (default: 1)
- limit: integer (default: 10, max: 50)
**Response**:
- 200: `{"orders": [...], "total": 5, "page": 1}`
<!-- end list -->
````
#### Supported Field Types
| Type | Description | Options |
|:---|:---|:---|
| `integer` | 32-bit integer | `min`, `max` |
| `bigint` | 64-bit integer | `min`, `max` |
| `string` | Variable length text | `min_length`, `max_length`, `pattern` |
| `text` | Long text field | - |
| `boolean` | True/false | - |
| `decimal` | Fixed-point decimal | `precision`, `scale`, `min`, `max` |
| `float` | Floating point | `min`, `max` |
| `datetime` | Date and time | `auto` (auto-populate) |
| `date` | Date only | - |
| `time` | Time only | - |
| `email` | Email address | - |
| `url` | URL | - |
| `uuid` | UUID string | - |
| `json` | JSON object/array | - |
#### Field Options
- `required`: Field must have a value.
- `nullable`: Field can be `null`/`None`.
- `unique`: Value must be unique across the table.
- `default`: Default value for the field.
- `choices`: List of allowed values.
- `primary key`: The primary key field.
- `foreign_key`: Reference to another table.
- `write-only`: Field only accepts input (e.g., passwords).
- `read-only`: Field only in responses (e.g., computed fields).
- `auto`: Auto-populate (e.g., timestamps, UUIDs).
---
### ๐ง Customization
#### Adding Custom Business Logic
Generated routes include clear customization points:
```python
# app/routes/products.py (generated)
@products_bp.route('/', methods=['POST'])
@require_auth
@validate_json(CreateProductSchema)
def create_product():
# Generated validation code
data = request.get_json()
# CUSTOMIZATION POINT: Add your business logic here
# Example: Check inventory, send notifications, etc.
# Generated persistence code
product = Product(**data)
db.session.add(product)
db.session.commit()
return jsonify(product.to_dict()), 201
````
#### Custom Templates
Override any generated file by creating a `templates` directory:
```bash
mkdir templates
cp ~/.api-blueprint/templates/routes.py.j2 templates/
# Edit templates/routes.py.j2 with your customizations
blueprint generate spec.md --template-dir templates
```
#### Middleware Customization
The `app/middleware.py` file is generated with customization points for authentication, logging, and more.
-----
### ๐งช Testing
Generated projects include comprehensive test suites:
```bash
# Run all tests
python -m pytest
# Run with coverage
python -m pytest --cov=app tests/
# Run a specific test file
python -m pytest tests/test_products.py
# Run integration tests only
python -m pytest tests/integration/
```
**Generated Test Types**:
- **Unit Tests**: Model validation and business logic.
- **Integration Tests**: Full API endpoint testing.
- **Database Tests**: Migration and constraint validation.
- **Authentication Tests**: Permission and token validation.
- **Performance Tests**: Response time benchmarks.
-----
### ๐ Deployment
#### Local Development
```bash
docker-compose up
```
- **API**: `http://localhost:5000`
- **Docs**: `http://localhost:5000/docs`
- **Database**: PostgreSQL on port `5432`
#### Production Deployment
**Docker Container**:
```bash
docker build -t my-api .
docker run -p 8000:8000 \
-e DATABASE_URL=postgresql://... \
-e JWT_SECRET_KEY=... \
my-api
```
**Environment Variables**:
- `DATABASE_URL`: Required connection string.
- `JWT_SECRET_KEY`: Required for JWT auth.
- Optional: `FLASK_ENV`, `CORS_ORIGINS`, `RATE_LIMIT_PER_MINUTE`, `LOG_LEVEL`.
**Kubernetes**:
- Generated k8s manifests are in `deploy/k8s/`.
- `kubectl apply -f deploy/k8s/`
**Railway/Heroku**:
- Generated `Procfile` and `runtime.txt` are included.
- `git push heroku main`
-----
### ๐ก๏ธ Security Features
**Built-in Security**:
- **Input Validation**: Pydantic schemas for all endpoints.
- **SQL Injection Prevention**: SQLAlchemy ORM with parameterized queries.
- **CORS Protection**: Configurable origin restrictions.
- **Rate Limiting**: Per-IP and per-user limits.
- **JWT Authentication**: Secure token-based auth.
- **Password Hashing**: `bcrypt` with salt rounds.
- **Security Headers**: HTTPS enforcement, CSP, etc.
-----
### ๐ Monitoring & Observability
Generated APIs include monitoring setup:
- `GET /health` (Health check)
- `GET /metrics` (Prometheus metrics)
- `GET /info` (API version and build info)
**Built-in metrics**:
- Request count and response times
- Error rates by endpoint
- Database connection pool status
- Authentication success/failure rates
-----
### ๐ค Contributing
We welcome contributions\! See `CONTRIBUTING.md` for guidelines.
**Development Setup**
```bash
git clone https://github.com/yourusername/api-blueprint-generator.git
cd api-blueprint-generator
pip install -e ".[dev]"
python -m pytest
```
-----
### ๐ Examples
**Real-World Examples**:
- Todo API - Simple CRUD operations
- E-commerce API - Complex relationships and auth
- Blog API - Content management with user roles
- Social Media API - Real-time features and file uploads
- IoT Data API - Time-series data and analytics
**Community Templates**:
- REST API Best Practices
- Microservice Template
- GraphQL Bridge
- Event-Driven Architecture
-----
### ๐ Support
- **Documentation**: Full Documentation, API Specification Guide, Deployment Guide, Customization Guide.
- **Getting Help**: GitHub Issues, Discord Community, Stack Overflow.
- **Commercial Support**: Patreon, Enterprise Support.
-----
### ๐ License
This project is licensed under the MIT License - see the `LICENSE` file for details.
-----
### ๐ Acknowledgments
- Thanks to all contributors.
- Inspired by the API-first development movement.
- Built with love for the developer community.
-----
### ๐บ๏ธ Roadmap
**Current Version (1.0)**
- โ
Flask backend generation
- โ
SQLite and PostgreSQL support
- โ
JWT authentication
- โ
Docker deployment
- โ
Comprehensive test generation
**Next Release (1.1)**
- ๐ FastAPI backend option
- ๐ File upload handling
- ๐ WebSocket endpoint support
- ๐ GraphQL schema generation
**Future Versions**
- ๐ฎ Django REST framework backend
- ๐ฎ Microservice architecture templates
- ๐ฎ OpenAPI 3.1 full compatibility
- ๐ฎ Auto-scaling deployment configs
- ๐ฎ AI-powered API optimization suggestions
-----
Ready to transform your API development workflow?
```bash
pip install api-blueprint-generator
echo "# My First API" > api.md
blueprint generate api.md
```
Join thousands of developers who've already made the switch to specification-first development.
Raw data
{
"_id": null,
"home_page": "https://github.com/your_username/Project-API-Blueprint-Strategy",
"name": "api-blueprint-generator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "James The Giblet",
"author_email": "your_email@example.com",
"download_url": "https://files.pythonhosted.org/packages/b0/51/f822a73d604c4ef1f97d4e08343823d3c5dcf5281c334003592331551473/api_blueprint_generator-1.0.0.tar.gz",
"platform": null,
"description": "### API Blueprint Generator\r\n\r\nStop writing APIs twice. Write the spec once, get the working code.\r\n\r\n-----\r\n\r\n### \ud83d\ude80 Quick Start\r\n\r\nTransform this simple Markdown specification:\r\n\r\n````markdown\r\n# Todo API\r\n\r\n## Data Models\r\n\r\n### Todo\r\n- id: integer (primary key)\r\n- title: string (required)\r\n- completed: boolean (default: false)\r\n- created_at: datetime\r\n\r\n## Endpoints\r\n\r\n### GET /todos\r\n**Description**: Get all todos\r\n**Response**: \r\n- 200: `{\"todos\": [...]}`\r\n\r\n### POST /todos\r\n**Description**: Create a new todo\r\n**Request Body**:\r\n```json\r\n{\r\n \"title\": \"Buy groceries\"\r\n}\r\n````\r\n\r\n**Response**:\r\n\r\n - 201: `{\"id\": 1, \"title\": \"Buy groceries\", \"completed\": false}`\r\n\r\n<!-- end list -->\r\n\r\n````\r\n\r\nInto a production-ready API in seconds:\r\n\r\n```bash\r\npip install api-blueprint-generator\r\nblueprint generate todo-spec.md --output todo-api\r\ncd todo-api && docker-compose up\r\n````\r\n\r\n**Result**: A working Flask API with a database, validation, tests, and documentation available at `http://localhost:5000`.\r\n\r\n-----\r\n\r\n### \ud83c\udfaf Why API Blueprint Generator?\r\n\r\n**The Problem**\r\n\r\n - Writing API documentation, then implementing the same logic again.\r\n - Manually keeping documentation and code in sync.\r\n - Starting every API project from scratch.\r\n - Inconsistent patterns across team projects.\r\n\r\n**The Solution**\r\n\r\n - **Single Source of Truth**: One Markdown file defines everything.\r\n - **Production Ready**: The generated code includes tests, validation, and deployment configuration.\r\n - **Time Savings**: A 70% reduction in API scaffolding time.\r\n - **Best Practices**: Follows established patterns for security, validation, and structure.\r\n\r\n**What You Get**\r\n\r\n```\r\n\ud83d\udcc1 your-api/\r\n\u251c\u2500\u2500 \ud83d\udc0d app/\r\n\u2502 \u251c\u2500\u2500 __init__.py # Flask app factory\r\n\u2502 \u251c\u2500\u2500 models.py # SQLAlchemy models\r\n\u2502 \u251c\u2500\u2500 routes/ # Generated endpoints\r\n\u2502 \u251c\u2500\u2500 schemas.py # Request/response validation\r\n\u2502 \u2514\u2500\u2500 middleware.py # Auth & rate limiting\r\n\u251c\u2500\u2500 \ud83d\uddc4\ufe0f migrations/ # Database migrations\r\n\u251c\u2500\u2500 \ud83e\uddea tests/ # Comprehensive test suite\r\n\u251c\u2500\u2500 \ud83d\udc33 docker-compose.yml # Local development setup\r\n\u251c\u2500\u2500 \ud83d\udccb requirements.txt # Project dependencies\r\n\u2514\u2500\u2500 \ud83d\udcd6 docs/ # Interactive API documentation\r\n```\r\n\r\n-----\r\n\r\n### \ud83d\udccb Installation\r\n\r\n**Using pip (Recommended)**\r\n\r\n```bash\r\npip install api-blueprint-generator\r\n```\r\n\r\n**Using Docker**\r\n\r\n```bash\r\ndocker pull blueprintgen/api-generator\r\ndocker run -v $(pwd):/workspace blueprintgen/api-generator generate spec.md\r\n```\r\n\r\n**From Source**\r\n\r\n```bash\r\ngit clone https://github.com/yourusername/api-blueprint-generator.git\r\ncd api-blueprint-generator\r\npip install -e .\r\n```\r\n\r\n-----\r\n\r\n### \ud83d\udd27 Usage\r\n\r\n#### Basic Generation\r\n\r\n```bash\r\n# Generate API from a markdown spec\r\nblueprint generate my-api-spec.md\r\n\r\n# Specify the output directory\r\nblueprint generate my-api-spec.md --output my-project\r\n\r\n# Use a different backend\r\nblueprint generate my-api-spec.md --backend fastapi\r\n\r\n# Include PostgreSQL setup\r\nblueprint generate my-api-spec.md --database postgresql\r\n```\r\n\r\n#### Configuration File\r\n\r\nCreate a `blueprint.yml` file for project defaults:\r\n\r\n```yaml\r\nbackend: flask # flask, fastapi\r\ndatabase: postgresql # sqlite, postgresql, mysql\r\nauth_type: jwt # jwt, session, oauth, none\r\ninclude_tests: true\r\ndocker_setup: true\r\napi_prefix: \"/api/v1\"\r\ncors_enabled: true\r\nrate_limiting: true\r\n```\r\n\r\n#### Development Workflow\r\n\r\n1. **Generate your API**: `blueprint generate api-spec.md --output my-api`\r\n2. **Run locally**: `cd my-api && docker-compose up --build`\r\n3. **Regenerate**: `blueprint generate ../api-spec.md --output . --overwrite`\r\n4. **Run tests**: `python -m pytest tests/`\r\n5. **Deploy**: `docker build -t my-api .`\r\n\r\n-----\r\n\r\n### \ud83d\udcdd Specification Format\r\n\r\n**Complete Example**\r\n\r\n````markdown\r\n# E-commerce API\r\n\r\n## Authentication\r\nJWT Bearer token required for protected endpoints.\r\n\r\n## Configuration\r\n- Base URL: `/api/v1`\r\n- Rate Limit: 100 requests per minute\r\n- CORS: Enabled for all origins\r\n\r\n## Data Models\r\n\r\n### User\r\n- id: integer (primary key)\r\n- email: string (unique, required, max_length=254)\r\n- username: string (unique, required, max_length=50)\r\n- password: string (required, min_length=8) [write-only]\r\n- is_active: boolean (default: true)\r\n- created_at: datetime (auto)\r\n- updated_at: datetime (auto)\r\n\r\n**Relationships**:\r\n- orders: many Order\r\n\r\n### Product\r\n- id: integer (primary key)\r\n- name: string (required, max_length=200)\r\n- description: text (nullable)\r\n- price: decimal (required, precision=10, scale=2)\r\n- stock: integer (default: 0)\r\n- category_id: integer (foreign_key: Category.id)\r\n- created_at: datetime (auto)\r\n\r\n**Relationships**:\r\n- category: one Category\r\n- order_items: many OrderItem\r\n\r\n### Order\r\n- id: integer (primary key)\r\n- user_id: integer (foreign_key: User.id, required)\r\n- status: string (choices: ['pending', 'confirmed', 'shipped', 'delivered'], default: 'pending')\r\n- total: decimal (precision=10, scale=2)\r\n- created_at: datetime (auto)\r\n\r\n**Relationships**:\r\n- user: one User\r\n- order_items: many OrderItem\r\n\r\n## Endpoints\r\n\r\n### POST /auth/register\r\n**Description**: Register a new user\r\n**Public**: true\r\n**Request Body**:\r\n```json\r\n{\r\n \"email\": \"user@example.com\",\r\n \"username\": \"johndoe\",\r\n \"password\": \"secretpassword\"\r\n}\r\n````\r\n\r\n**Response**:\r\n\r\n - 201: `{\"id\": 1, \"email\": \"user@example.com\", \"username\": \"johndoe\"}`\r\n - 400: `{\"error\": \"Email already exists\"}`\r\n\r\n### POST /auth/login\r\n\r\n**Description**: Authenticate user and return JWT token\r\n**Public**: true\r\n**Request Body**:\r\n\r\n```json\r\n{\r\n \"email\": \"user@example.com\",\r\n \"password\": \"secretpassword\"\r\n}\r\n```\r\n\r\n**Response**:\r\n\r\n - 200: `{\"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...\", \"user\": {...}}`\r\n - 401: `{\"error\": \"Invalid credentials\"}`\r\n\r\n### GET /users/me\r\n\r\n**Description**: Get current user profile\r\n**Authentication**: required\r\n**Response**:\r\n\r\n - 200: `{\"id\": 1, \"email\": \"user@example.com\", \"username\": \"johndoe\"}`\r\n - 401: `{\"error\": \"Authentication required\"}`\r\n\r\n### GET /products\r\n\r\n**Description**: List products with filtering and pagination\r\n**Public**: true\r\n**Parameters**:\r\n\r\n - page: integer (default: 1, min: 1)\r\n - limit: integer (default: 20, min: 1, max: 100)\r\n - category: string (optional)\r\n - min\\_price: decimal (optional)\r\n - max\\_price: decimal (optional)\r\n - search: string (optional, searches name and description)\r\n **Response**:\r\n - 200: `{\"products\": [...], \"total\": 150, \"page\": 1, \"pages\": 8}`\r\n\r\n### POST /products\r\n\r\n**Description**: Create a new product (admin only)\r\n**Authentication**: required\r\n**Permissions**: admin\r\n**Request Body**:\r\n\r\n```json\r\n{\r\n \"name\": \"Laptop\",\r\n \"description\": \"High-performance laptop\",\r\n \"price\": 999.99,\r\n \"stock\": 10,\r\n \"category_id\": 1\r\n}\r\n```\r\n\r\n**Response**:\r\n\r\n - 201: `{\"id\": 1, \"name\": \"Laptop\", ...}`\r\n - 400: `{\"error\": \"Validation failed\", \"details\": {...}}`\r\n - 403: `{\"error\": \"Admin access required\"}`\r\n\r\n### GET /products/{id}\r\n\r\n**Description**: Get product by ID\r\n**Public**: true\r\n**Parameters**:\r\n\r\n - id: integer (path parameter, required)\r\n **Response**:\r\n - 200: `{\"id\": 1, \"name\": \"Laptop\", ...}`\r\n - 404: `{\"error\": \"Product not found\"}`\r\n\r\n### PUT /products/{id}\r\n\r\n**Description**: Update product (admin only)\r\n**Authentication**: required\r\n**Permissions**: admin\r\n**Parameters**:\r\n\r\n - id: integer (path parameter, required)\r\n **Request Body**: Same as POST /products\r\n **Response**:\r\n - 200: `{\"id\": 1, \"name\": \"Updated Laptop\", ...}`\r\n - 404: `{\"error\": \"Product not found\"}`\r\n - 403: `{\"error\": \"Admin access required\"}`\r\n\r\n### DELETE /products/{id}\r\n\r\n**Description**: Delete product (admin only)\r\n**Authentication**: required\r\n**Permissions**: admin\r\n**Parameters**:\r\n\r\n - id: integer (path parameter, required)\r\n **Response**:\r\n - 204: No content\r\n - 404: `{\"error\": \"Product not found\"}`\r\n\r\n### POST /orders\r\n\r\n**Description**: Create a new order\r\n**Authentication**: required\r\n**Request Body**:\r\n\r\n```json\r\n{\r\n \"items\": [\r\n {\"product_id\": 1, \"quantity\": 2},\r\n {\"product_id\": 2, \"quantity\": 1}\r\n ]\r\n}\r\n```\r\n\r\n**Response**:\r\n\r\n - 201: `{\"id\": 1, \"status\": \"pending\", \"total\": 1999.98, \"items\": [...]}`\r\n - 400: `{\"error\": \"Invalid product or insufficient stock\"}`\r\n\r\n### GET /orders\r\n\r\n**Description**: Get user's orders\r\n**Authentication**: required\r\n**Parameters**:\r\n\r\n - page: integer (default: 1)\r\n - limit: integer (default: 10, max: 50)\r\n **Response**:\r\n - 200: `{\"orders\": [...], \"total\": 5, \"page\": 1}`\r\n\r\n<!-- end list -->\r\n\r\n````\r\n\r\n#### Supported Field Types\r\n| Type | Description | Options |\r\n|:---|:---|:---|\r\n| `integer` | 32-bit integer | `min`, `max` |\r\n| `bigint` | 64-bit integer | `min`, `max` |\r\n| `string` | Variable length text | `min_length`, `max_length`, `pattern` |\r\n| `text` | Long text field | - |\r\n| `boolean` | True/false | - |\r\n| `decimal` | Fixed-point decimal | `precision`, `scale`, `min`, `max` |\r\n| `float` | Floating point | `min`, `max` |\r\n| `datetime` | Date and time | `auto` (auto-populate) |\r\n| `date` | Date only | - |\r\n| `time` | Time only | - |\r\n| `email` | Email address | - |\r\n| `url` | URL | - |\r\n| `uuid` | UUID string | - |\r\n| `json` | JSON object/array | - |\r\n\r\n#### Field Options\r\n- `required`: Field must have a value.\r\n- `nullable`: Field can be `null`/`None`.\r\n- `unique`: Value must be unique across the table.\r\n- `default`: Default value for the field.\r\n- `choices`: List of allowed values.\r\n- `primary key`: The primary key field.\r\n- `foreign_key`: Reference to another table.\r\n- `write-only`: Field only accepts input (e.g., passwords).\r\n- `read-only`: Field only in responses (e.g., computed fields).\r\n- `auto`: Auto-populate (e.g., timestamps, UUIDs).\r\n\r\n---\r\n\r\n### \ud83d\udd27 Customization\r\n\r\n#### Adding Custom Business Logic\r\nGenerated routes include clear customization points:\r\n```python\r\n# app/routes/products.py (generated)\r\n@products_bp.route('/', methods=['POST'])\r\n@require_auth\r\n@validate_json(CreateProductSchema)\r\ndef create_product():\r\n # Generated validation code\r\n data = request.get_json()\r\n \r\n # CUSTOMIZATION POINT: Add your business logic here\r\n # Example: Check inventory, send notifications, etc.\r\n \r\n # Generated persistence code\r\n product = Product(**data)\r\n db.session.add(product)\r\n db.session.commit()\r\n \r\n return jsonify(product.to_dict()), 201\r\n````\r\n\r\n#### Custom Templates\r\n\r\nOverride any generated file by creating a `templates` directory:\r\n\r\n```bash\r\nmkdir templates\r\ncp ~/.api-blueprint/templates/routes.py.j2 templates/\r\n# Edit templates/routes.py.j2 with your customizations\r\nblueprint generate spec.md --template-dir templates\r\n```\r\n\r\n#### Middleware Customization\r\n\r\nThe `app/middleware.py` file is generated with customization points for authentication, logging, and more.\r\n\r\n-----\r\n\r\n### \ud83e\uddea Testing\r\n\r\nGenerated projects include comprehensive test suites:\r\n\r\n```bash\r\n# Run all tests\r\npython -m pytest\r\n\r\n# Run with coverage\r\npython -m pytest --cov=app tests/\r\n\r\n# Run a specific test file\r\npython -m pytest tests/test_products.py\r\n\r\n# Run integration tests only\r\npython -m pytest tests/integration/\r\n```\r\n\r\n**Generated Test Types**:\r\n\r\n - **Unit Tests**: Model validation and business logic.\r\n - **Integration Tests**: Full API endpoint testing.\r\n - **Database Tests**: Migration and constraint validation.\r\n - **Authentication Tests**: Permission and token validation.\r\n - **Performance Tests**: Response time benchmarks.\r\n\r\n-----\r\n\r\n### \ud83d\ude80 Deployment\r\n\r\n#### Local Development\r\n\r\n```bash\r\ndocker-compose up\r\n```\r\n\r\n - **API**: `http://localhost:5000`\r\n - **Docs**: `http://localhost:5000/docs`\r\n - **Database**: PostgreSQL on port `5432`\r\n\r\n#### Production Deployment\r\n\r\n**Docker Container**:\r\n\r\n```bash\r\ndocker build -t my-api .\r\ndocker run -p 8000:8000 \\\r\n -e DATABASE_URL=postgresql://... \\\r\n -e JWT_SECRET_KEY=... \\\r\n my-api\r\n```\r\n\r\n**Environment Variables**:\r\n\r\n - `DATABASE_URL`: Required connection string.\r\n - `JWT_SECRET_KEY`: Required for JWT auth.\r\n - Optional: `FLASK_ENV`, `CORS_ORIGINS`, `RATE_LIMIT_PER_MINUTE`, `LOG_LEVEL`.\r\n\r\n**Kubernetes**:\r\n\r\n - Generated k8s manifests are in `deploy/k8s/`.\r\n - `kubectl apply -f deploy/k8s/`\r\n\r\n**Railway/Heroku**:\r\n\r\n - Generated `Procfile` and `runtime.txt` are included.\r\n - `git push heroku main`\r\n\r\n-----\r\n\r\n### \ud83d\udee1\ufe0f Security Features\r\n\r\n**Built-in Security**:\r\n\r\n - **Input Validation**: Pydantic schemas for all endpoints.\r\n - **SQL Injection Prevention**: SQLAlchemy ORM with parameterized queries.\r\n - **CORS Protection**: Configurable origin restrictions.\r\n - **Rate Limiting**: Per-IP and per-user limits.\r\n - **JWT Authentication**: Secure token-based auth.\r\n - **Password Hashing**: `bcrypt` with salt rounds.\r\n - **Security Headers**: HTTPS enforcement, CSP, etc.\r\n\r\n-----\r\n\r\n### \ud83d\udcca Monitoring & Observability\r\n\r\nGenerated APIs include monitoring setup:\r\n\r\n - `GET /health` (Health check)\r\n - `GET /metrics` (Prometheus metrics)\r\n - `GET /info` (API version and build info)\r\n\r\n**Built-in metrics**:\r\n\r\n - Request count and response times\r\n - Error rates by endpoint\r\n - Database connection pool status\r\n - Authentication success/failure rates\r\n\r\n-----\r\n\r\n### \ud83e\udd1d Contributing\r\n\r\nWe welcome contributions\\! See `CONTRIBUTING.md` for guidelines.\r\n\r\n**Development Setup**\r\n\r\n```bash\r\ngit clone https://github.com/yourusername/api-blueprint-generator.git\r\ncd api-blueprint-generator\r\npip install -e \".[dev]\"\r\npython -m pytest\r\n```\r\n\r\n-----\r\n\r\n### \ud83d\udcda Examples\r\n\r\n**Real-World Examples**:\r\n\r\n - Todo API - Simple CRUD operations\r\n - E-commerce API - Complex relationships and auth\r\n - Blog API - Content management with user roles\r\n - Social Media API - Real-time features and file uploads\r\n - IoT Data API - Time-series data and analytics\r\n\r\n**Community Templates**:\r\n\r\n - REST API Best Practices\r\n - Microservice Template\r\n - GraphQL Bridge\r\n - Event-Driven Architecture\r\n\r\n-----\r\n\r\n### \ud83c\udd98 Support\r\n\r\n - **Documentation**: Full Documentation, API Specification Guide, Deployment Guide, Customization Guide.\r\n - **Getting Help**: GitHub Issues, Discord Community, Stack Overflow.\r\n - **Commercial Support**: Patreon, Enterprise Support.\r\n\r\n-----\r\n\r\n### \ud83d\udcc4 License\r\n\r\nThis project is licensed under the MIT License - see the `LICENSE` file for details.\r\n\r\n-----\r\n\r\n### \ud83d\ude4f Acknowledgments\r\n\r\n - Thanks to all contributors.\r\n - Inspired by the API-first development movement.\r\n - Built with love for the developer community.\r\n\r\n-----\r\n\r\n### \ud83d\uddfa\ufe0f Roadmap\r\n\r\n**Current Version (1.0)**\r\n\r\n - \u2705 Flask backend generation\r\n - \u2705 SQLite and PostgreSQL support\r\n - \u2705 JWT authentication\r\n - \u2705 Docker deployment\r\n - \u2705 Comprehensive test generation\r\n\r\n**Next Release (1.1)**\r\n\r\n - \ud83d\udd04 FastAPI backend option\r\n - \ud83d\udd04 File upload handling\r\n - \ud83d\udd04 WebSocket endpoint support\r\n - \ud83d\udd04 GraphQL schema generation\r\n\r\n**Future Versions**\r\n\r\n - \ud83d\udd2e Django REST framework backend\r\n - \ud83d\udd2e Microservice architecture templates\r\n - \ud83d\udd2e OpenAPI 3.1 full compatibility\r\n - \ud83d\udd2e Auto-scaling deployment configs\r\n - \ud83d\udd2e AI-powered API optimization suggestions\r\n\r\n-----\r\n\r\nReady to transform your API development workflow?\r\n\r\n```bash\r\npip install api-blueprint-generator\r\necho \"# My First API\" > api.md\r\nblueprint generate api.md\r\n```\r\n\r\nJoin thousands of developers who've already made the switch to specification-first development.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Generate production-ready APIs from a simple Markdown specification.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/your_username/Project-API-Blueprint-Strategy"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a0bf0fff25038ae094df9f0c63788df96c3134952f24ac24aa64609b816c02c8",
"md5": "a42bc50eabc62ebac02b941fb64317dd",
"sha256": "c8028a8ae6df3ec1eb50e1911bfe0ed2230ae26e26c389a4309cf9d527a39c25"
},
"downloads": -1,
"filename": "api_blueprint_generator-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a42bc50eabc62ebac02b941fb64317dd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 59354,
"upload_time": "2025-08-17T15:45:33",
"upload_time_iso_8601": "2025-08-17T15:45:33.382070Z",
"url": "https://files.pythonhosted.org/packages/a0/bf/0fff25038ae094df9f0c63788df96c3134952f24ac24aa64609b816c02c8/api_blueprint_generator-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b051f822a73d604c4ef1f97d4e08343823d3c5dcf5281c334003592331551473",
"md5": "0a97209c73f2333e24469193ed63f72c",
"sha256": "56f266d45de75aeb3c17c97dff588f69db4afeb4547b750f8c9ee01b59ef9f1a"
},
"downloads": -1,
"filename": "api_blueprint_generator-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "0a97209c73f2333e24469193ed63f72c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 48843,
"upload_time": "2025-08-17T15:45:34",
"upload_time_iso_8601": "2025-08-17T15:45:34.508591Z",
"url": "https://files.pythonhosted.org/packages/b0/51/f822a73d604c4ef1f97d4e08343823d3c5dcf5281c334003592331551473/api_blueprint_generator-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-17 15:45:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "your_username",
"github_project": "Project-API-Blueprint-Strategy",
"github_not_found": true,
"lcname": "api-blueprint-generator"
}