https://github.com/rpdevjesco/responsivebackendcli
https://github.com/rpdevjesco/responsivebackendcli
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/rpdevjesco/responsivebackendcli
- Owner: RPDevJesco
- Created: 2025-02-13T14:35:28.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-13T14:38:10.000Z (over 1 year ago)
- Last Synced: 2025-03-03T08:18:20.444Z (over 1 year ago)
- Language: C#
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**Responsive Backend CLI - Design Document**
## Overview
The **Responsive Backend CLI** is a **Documentation-First Development Framework** where APIs adapt to clients while **documentation drives development**. Instead of generating documentation from code, this framework **generates API scaffolding from documentation**, ensuring that documentation remains the **source of truth**.
## Key Features
### 1. **Documentation-Driven Code Generation**
- Developers write high-level API descriptions in **Markdown or YAML**.
- The framework **automatically generates**:
- API controllers
- Endpoint handlers
- Request validation
- Role-based authentication enforcement
**Example YAML API Definition:**
```yaml
title: User API
version: 1.0
endpoints:
- path: "/users/{id}"
method: GET
description: "Fetches user details by ID"
response:
200:
json:
id: int
name: string
email: string
auth:
enforce: true
roles: ["Admin", "User"]
```
**⬇️ Generates Controller (C# Example) ⬇️**
```csharp
[Authorize(Roles = "Admin,User")]
[HttpGet("/users/{id}")]
public IActionResult GetUser(int id)
{
return GetUserImplementation(id);
}
partial void GetUserImplementation(int id);
```
### 2. **Partial Class Structure for Custom Business Logic**
- Generated API code provides **scaffolding**.
- Business logic is implemented in **partner partial classes**, ensuring **safe regeneration**.
**Example Developer-Defined Partial Class:**
```csharp
public partial class UserController
{
partial void GetUserImplementation(int id)
{
var user = userService.GetUser(id);
Response = user != null ? Ok(user) : NotFound();
}
}
```
### 3. **Hybrid Authentication & Authorization**
- Authentication is **enforced at the controller level**.
- Supports **JWT tokens, API keys, OAuth2, and session-based authentication**.
- Uses **Role-Based Group Access Control (RBGAC)**.
- Basic auth rules can be **defined in the documentation**, but **developers can override/customize them** in partial classes.
### 4. **Standardized Response Format**
- **Auto-wrapping of responses** for consistency.
- Example Response Format:
```json
{
"success": true,
"data": { ... },
"error": null
}
```
### 5. **Global Exception Handling**
- The framework **enforces a global exception handler** that returns standardized error responses.
- Example Error Response:
```json
{
"success": false,
"error": {
"code": "USER_NOT_FOUND",
"message": "The requested user was not found."
}
}
```
### 6. **Logging & Monitoring**
- Automatically **logs API calls, authentication attempts, and authorization failures**.
- Includes **built-in rate-limiting and request throttling**.
### 7. **Configuration & Extensibility**
- Authentication, logging, and rate-limiting are **configurable via a settings file (YAML/JSON)**.
- Example Configuration:
```yaml
authentication:
method: "JWT"
secret: "supersecretkey"
logging:
enabled: true
log_level: "info"
rate_limiting:
requests_per_minute: 60
```
### 8. **Multi-Language Support**
- Uses **partial classes for C#**.
- Uses **mixins for Ruby**.
- Uses **decorators for JavaScript**.
### 9. **Explicit API Versioning**
- API versions require **explicit version changes** to avoid breaking changes.
### 10. **CLI Commands**
| Command | Description |
|-------------|-------------|
| ` .\ResponsiveBackendCLI.exe init` | Initializes a new project |
| ` .\ResponsiveBackendCLI.exe generate` | Generates API scaffolding from YAML/Markdown | --language
| ` .\ResponsiveBackendCLI.exe test` | Runs auto-generated tests |
| ` .\ResponsiveBackendCLI.exe serve` | Runs a mock server for API testing |
| ` .\ResponsiveBackendCLI.exe validate` | Ensures OpenAPI compliance |
### 11. **Deployment & Cloud Support**
- **No built-in deployment or cloud service support at this time**.
- Future enhancements may include **Docker configuration generation**.
## Conclusion
The **Responsive Backend CLI** provides a robust and scalable way to build backend APIs using a **Documentation-First** approach. With **partial class support, built-in authentication, logging, and rate-limiting**, developers can rapidly generate APIs while maintaining full control over business logic. The hybrid authentication model ensures security without sacrificing flexibility, and the CLI tools make development streamlined and efficient.