BonsAPI Overview #
BonsAPI is the core backend service that powers the BonsAI platform. It is built in Rust for optimal performance and reliability.
Architecture #
BonsAPI follows a modern, modular architecture with clear separation of concerns:
- API Layer: Handles HTTP requests and responses
- Service Layer: Implements business logic
- Repository Layer: Manages data persistence
- Domain Layer: Defines core entities and business rules
Technology Stack #
- Framework: Rust with Actix Web
- Database Access: SQLx for type-safe database operations
- Authentication: JWT-based authentication
- Documentation: OpenAPI specification
Key Features #
- Document Processing: Endpoint for document upload and processing
- Entity Management: CRUD operations for entities
- Invoice Processing: Specialized API for invoice data extraction
- Integration: Endpoints for third-party integration
- User Management: Authentication and authorization
API Documentation #
The API is documented using OpenAPI specification, available at:
- Development:
/docs/openapi - Production:
api.bonsai.com/docs/openapi
Development Setup #
To run the API locally:
- Clone the repository
- Copy
.env.sampleto.envand configure environment variables - Run with
cargo runor use the provideddocker-compose.yml
Deployment #
The API is containerized using Docker and deployed using our CI/CD pipeline.
Error Handling #
The API follows a consistent error handling pattern:
- HTTP status codes indicate the type of error
- Response bodies include detailed error information
- Errors are logged for monitoring and debugging