SuperDoc provides document conversion services through its API endpoints (e.g., /convert
for converting documents between formats like DOCX to PDF, PDF to DOCX, DOCX to HTML). We need a system to track API usage and handle billing.
Design and implement a usage tracking and billing system that will:
- Track API calls to document conversion endpoints
- Manage usage quotas
- Calculate billing based on usage
Track essential metrics for document conversions:
{
"account_id": "string",
"endpoint": "string",
"timestamp": "datetime",
"status": "success|failure"
}
Implement simple tiered pricing:
- Free tier: 100 requests/month
- Pro tier: $0.10 per request
- Use Python with FastAPI
- Implement proper authentication
- Handle concurrent requests
- Include error handling
- Add logging
- Complete REST API with endpoints for:
- Usage tracking
- Usage statistics retrieval
- Quota checking
- Billing calculations
- Authentication mechanism
- Input validation
- Error handling
- Rate limiting (optional)
- Schema design
- Indexes for performance (optional)
- Unit tests
- Integration tests
- Test coverage report
- Performance tests (optional)
- API documentation (OpenAPI/Swagger)
- Setup instructions
- Architecture overview
- Design decisions explanation
- Future improvements
- Clean, maintainable code
- Proper error handling
- Logging
- Type hints
- Comments where necessary
- RESTful principles
- Authentication implementation
- Error handling
- Documentation quality
- Clean code practices
- Error handling
- Testing coverage
- Type safety
- Database schema
- Concurrency handling
- Performance considerations
- Scalability approach
- Setup instructions
- Architecture explanation
- Design decisions
- Future improvements
- Core requirements: 6-8 hours
- Additional features: 2-4 hours (optional)
- Provide source code in a Git repository
- Include comprehensive README.md
- Document all assumptions and decisions
- Note any shortcuts taken due to time constraints
- Suggest future improvements
If you need any clarification about the requirements, please don't hesitate to ask. We want to ensure you can showcase your skills effectively.