Skip to content

Latest commit

 

History

History
79 lines (61 loc) · 2.6 KB

File metadata and controls

79 lines (61 loc) · 2.6 KB

Backend Documentation

Architecture and Implementation

The backend follows a service-oriented architecture built with .NET. The key components include:

Controllers

  • RESTful API endpoints organized by domain entity
  • Handle HTTP requests and delegate business logic to services
  • Return standardized responses

Services

  • Implement business logic independent of HTTP concerns
  • Interact with repositories for data access
  • Handle error cases and validation

Data Access

  • Repository pattern for database operations
  • Entity models with navigation properties for relationships
  • Uses Entity Framework Core for ORM capabilities

Storage Services

  • AzureBlobStorageService for handling file uploads
  • Secure access to stored files
  • File metadata management

Key Design Decisions

Service Layer Pattern

  • What: Business logic lives in dedicated service classes
  • Why: Separation of concerns, enables unit testing
  • Example: MaterialService implements operations on materials

Cloud Storage Integration

  • What: Azure Blob Storage for file storage
  • Why: Scalable solution for storing user-uploaded content
  • Example: Methods for generating URLs and managing storage containers

Authentication

  • What: JWT-based authentication
  • Why: Stateless authentication suitable for API services
  • Example: Token validation in request pipeline

Resource Hierarchy

  • What: Resources organized hierarchically (courses contain materials, assignments)
  • Why: Reflects real-world relationships and simplifies access control
  • Example: Endpoints like /course/{id}/materials

Areas for Improvement

Error Handling

  • Inconsistent null handling in several services
  • Consider using Result pattern or nullable reference types more effectively
  • Implement global exception handling middleware

Field Validation

  • Add comprehensive input validation
  • Use data annotations or FluentValidation for consistent validation rules
  • Ensure client receives clear validation error messages

API Documentation

  • Implement Swagger/OpenAPI documentation
  • Document expected request/response formats
  • Generate client SDKs for frontend consumption

Performance

  • Add caching layer for frequently accessed data
  • Optimize database queries (missing indexes, N+1 query problems)
  • Consider implementing batch operations for bulk changes

Security

  • Audit authorization logic
  • Implement resource-based permissions
  • Add rate limiting to prevent abuse

Testing

  • Expand unit test coverage
  • Add integration tests for API endpoints
  • Implement automated testing for critical workflows