Skip to content

Overview

Welcome to the backend server documentation. This guide serves as a comprehensive reference for understanding, developing, and contributing to the application. The documentation is structured to provide not only the foundational knowledge required to get started with the codebase but also in-depth insights into the architecture, workflows, and best practices.

Intended Audience

This documentation is primarily aimed at experienced Rails developers who have a strong grasp of building and deploying Rails-based API applications on the internet. A solid understanding of Rails conventions, API design, background job processing, authentication & authorization mechanisms, and database management is assumed.

Pre requisites

Before diving into the specifics of the backend implementation, it is highly recommended to first familiarize yourself with the following core sections of the application:

  • Content Library – Learn about the structure, management, and retrieval of library-related resources.
  • School LMS – Understand the school-related functionalities, including student and teacher management.
  • Access Management – Gain insight into authentication, authorization, and security layers within the system.

Additionally, having a broad understanding of the various features of the application will provide better context when navigating through the implementation details.


With this foundation in place, you’ll be well-equipped to explore, extend, and enhance the backend server efficiently.

Rails Monolith

The backend server is a monolithic Ruby on Rails application designed for scalability and maintainability. PostgreSQL serves as the primary database, Sidekiq handles background job processing for tasks like emails and scheduled jobs, and Active Storage manages file uploads with support for cloud storage. By leveraging these components and adhering to Rails' convention over configuration philosophy, the system ensures efficiency, performance, and ease of development.

Namespaces

Namespaces provide a way to organize different modules and features into logical separations within the Rails application. This separation helps maintain code clarity, reduces naming conflicts, and improves overall maintainability.

1. Library Namespace

The Library namespace encompasses all functionality related to library resource management and operations.

Key Components:

  • Curriculum
  • Material (Flashcard)
  • Worksheets
  • Assessment / Performance measurement

Example Structure:

class Library::Domain < ApplicationRecord
end

2. School Namespace

The School namespace handles all school lms features.

Key Components:

  • Student administration
  • Teacher administration
  • Classroom management
  • IEP preparation
  • Daily assessments
  • Attendance tracking
  • Casestudies
  • Student/Classroom Worksheets
  • Reporting

Example Structure:

class School::Student < ApplicationRecord
end

3. License Namespace

The License namespace manages all aspects of curriculum license management.

Key Components: - License management

Example Structure:

class License::Access < ApplicationRecord
end

Best Practices

When working with these namespaces:

  1. Keep models, controllers, and related files within their respective namespace directories
  2. Maintain clear separation of concerns between namespaces
  3. Follow consistent naming conventions within each namespace

Directory Structure

app/
├── controllers/
│   ├── library/
│   ├── school/
│   └── license/
├── models/
│   ├── library/
│   ├── school/
│   └── license/

Authentication and Authorization

Security is a fundamental aspect of the application, and it includes robust authentication and authorization mechanisms:

Authentication

  • Devise: Manages user authentication, handling registrations, logins, and password recovery.
  • Doorkeeper: Implements OAuth-based authentication, allowing API clients to securely access system resources.

Authorization

  • Pundit: Provides fine-grained authorization by defining policies to control user access to different resources.

Administrative Dashboard

During the early development phase, Active Admin was utilized to quickly set up a dashboard for managing and reviewing data. This dashboard provided an interface for administrators to oversee various aspects of the application, including:

  • Viewing and managing users.
  • Monitoring system data.

Although primarily used during development, Active Admin may still be leveraged for administrative functionalities as needed.