How afloresc/atutorgobknd works
Purpose and Entry Points
This is a Go backend for ATutor, managing course lessons and related learning data for an Android client. The executable entry point is domain/cmd/main.go; runtime configuration is represented by domain/cmd/app.yaml and environment files such as .env.
Application Composition
controller/application.go is the central application/controller assembly point. It likely binds HTTP transport, domain operations, configuration, and service dependencies into the running backend. domain/cmd/main.go starts that application, making the domain/cmd package the deployment boundary.
Domain Model
The domain package defines the backend’s core learning and identity model:
• Course and lesson hierarchy: domain/course.go, domain/lesson.go, domain/content.go.
• Learning structure and assessments: domain/concept.go, domain/question.go, domain/questionary.go.
• Student progress and outcomes: domain/user_lesson.go, domain/marks.go, domain/report.go.
• Users, clients, and roles: domain/user.go, domain/client.go, domain/roles.go.
These domain types form the primary data contract between controllers, authorization, and persistence/service integrations.
HTTP and Response Boundary
ahttp/responsemanager.go centralizes HTTP response handling, likely including consistent success/error serialization and status mapping. The controller layer in controller/application.go is the likely request-routing and use-case boundary; it should translate incoming HTTP requests into domain operations and return responses through ahttp.
Authentication and Authorization
JWT authentication and role-based access control are isolated under tapi/rbac:
• JWT middleware: tapi/rbac/jwtmiddleware.go.
• Token creation/validation: tapi/rbac/token.go.
• Authorization decisions and role definitions: tapi/rbac/rbac.go, tapi/rbac/roles.go.
This establishes a security boundary before protected course, lesson, user-progress, and assessment operations execute. domain/jwt.go and domain/roles.go provide related domain-level identity/security representations.
Configuration and Runtime Dependencies
Configuration is modeled in domain/config.go, loaded with environment support from utils/env.go, and supplied at startup from domain/cmd/main.go. The repository does not expose a distinct database adapter or external SaaS client in the provided tree; persistence and remote-service behavior, if present, is likely encapsulated behind domain/client abstractions such as domain/client.go.
Primary Flow
A client request enters the application assembled by controller/application.go; protected routes pass through tapi/rbac/jwtmiddleware.go, where JWT identity and RBAC permissions are evaluated. Authorized handlers operate on course/lesson/content, assessments, or user-progress domain entities. Results and failures cross the HTTP boundary through ahttp/responsemanager.go, with shared error behavior from utils/errors.go.
Main entry points: application.go Application assembly · main.go Backend entry point · jwtmiddleware.go JWT middleware · rbac.go Authorization rules
Components 17
Runtime
- Backend entry point · Starts the configured backend.
domain/cmd/main.go - Runtime configuration
domain/cmd/app.yaml - Configuration model
domain/config.go - Environment loader
utils/env.go
HTTP Application
- Application assembly · Composes transport, security, and domain dependencies.
controller/application.go - Response manager · Serializes success and error responses.
ahttp/responsemanager.go - Shared errors
utils/errors.go
Authentication & RBAC
- JWT middleware · Protects routes and establishes request identity.
tapi/rbac/jwtmiddleware.go - JWT tokens · Creates and validates JWTs.
tapi/rbac/token.go - Authorization rules · Evaluates role permissions.
tapi/rbac/rbac.go - RBAC roles
tapi/rbac/roles.go
Learning Domain
- Course learning model · Courses, lessons, content, and concepts.
domain/course.go - Assessment model · Questions and questionnaires.
domain/question.go - Progress and outcomes · User lessons, marks, and reports.
domain/user_lesson.go - Users and clients · Users, client abstractions, and roles.
domain/user.go - Domain JWT identity
domain/jwt.go - Domain roles
domain/roles.go
Connections 21
- Backend entry point → Runtime configuration: loads
- Backend entry point → Environment loader: reads
- Runtime configuration → Configuration model: populates
- Environment loader → Configuration model: overrides
- Backend entry point → Application assembly: starts
- Configuration model → Application assembly: supplies
- Application assembly → JWT middleware: protected requests
- JWT middleware → JWT tokens: validates
- JWT middleware → Authorization rules: authorizes via
- Authorization rules → RBAC roles: uses
- JWT tokens → Domain JWT identity: maps identity
- Authorization rules → Domain roles: maps roles
- Application assembly → Course learning model: handles
- Application assembly → Assessment model: handles
- Application assembly → Progress and outcomes: handles
- Application assembly → Users and clients: handles
- Application assembly → Response manager: returns via
- Response manager → Shared errors: maps
- Progress and outcomes → Course learning model: tracks
- Assessment model → Course learning model: belongs to
- Users and clients → Progress and outcomes: owns