tinyqc/docs/source-tree-analysis.md
mahdahar 14baa6b758 docs: add comprehensive documentation and refactor API structure
This commit introduces a complete documentation suite, refactors the API layer for
better consistency, and updates the database schema and seeding logic.

Key Changes:
- Documentation:
  - Added `CLAUDE.md` with development guidelines and architecture overview.
  - Created `docs/` directory with detailed guides for architecture, development,
    and source tree analysis.
- Database & Migrations:
  - Implemented `RenameMasterColumns` migration to standardize column naming
    (e.g., `name` -> `dept_name`, `name` -> `control_name`).
  - Added `CmodQcSeeder` to populate the system with realistic sample data
    for depts, controls, tests, and results.
- Backend API:
  - Created `DashboardApiController` with `getRecent()` for dashboard stats.
  - Created `ReportApiController` for managed reporting access.
  - Updated `app/Config/Routes.php` with new API groupings and documentation routes.
- Frontend & Views:
  - Refactored master data views (`dept`, `test`, `control`) to use Alpine.js
    and the updated API structure.
  - Modernized `dashboard.php` and `main_layout.php` with improved UI/UX.
- Infrastructure:
  - Updated `.gitignore` to exclude development-specific artifacts (`_bmad/`, `.claude/`).
2026-01-20 14:44:46 +07:00

6.0 KiB

Source Tree Analysis - TinyQC

Project Root Structure

tinyqc/
├── app/                          # Application source code (MVC)
│   ├── Config/                   # Framework and app configurations
│   ├── Controllers/              # HTTP request handlers
│   │   └── Api/                  # REST API controllers
│   ├── Database/                 # Database utilities
│   │   ├── Migrations/           # Database migrations
│   │   └── Seeds/                # Database seeders
│   ├── Filters/                  # Request filters
│   ├── Helpers/                  # Helper functions
│   ├── Language/                 # Language files
│   ├── Libraries/                # Custom libraries
│   ├── Models/                   # Data models
│   ├── ThirdParty/               # Third-party code
│   ├── Views/                    # View templates
│   ├── BaseController.php        # Controller base class
│   └── Common.php                # Common functions
├── public/                       # Web root directory
│   ├── index.php                 # Application entry point
│   ├── js/                       # JavaScript files
│   ├── css/                      # CSS files (if any)
│   ├── favicon.ico               # Site icon
│   └── .htaccess                 # Apache configuration
├── tests/                        # Unit tests
├── writable/                     # Writable files (logs, cache, debugbar)
├── _bmad/                        # BMAD development artifacts
├── vendor/                       # Composer dependencies
├── composer.json                 # Composer configuration
├── env                           # Environment template
├── phpunit.xml.dist              # PHPUnit configuration
└── spark                         # CodeIgniter CLI tool

Application Directory (app/)

Config Directory

File Purpose
App.php Main application configuration
Database.php Database connection settings (SQL Server)
Routes.php URL routing definitions
Autoload.php Class autoloading configuration
Boot/*.php Environment-specific boot configs
Filters.php Request filter configurations
Services.php Service container configurations
Session.php Session settings
Validation.php Form validation rules

Purpose: Contains all CodeIgniter 4 framework configurations and application-specific settings.


Controllers Directory

Controller Purpose
BaseController.php Base controller with common functionality
Dashboard.php Main dashboard controller
Dept.php Department management
Test.php Test/parameter management
Control.php Control standards management
Entry.php Daily/monthly entry management
Report.php Report generation
PageController.php Generic page controller

API Controllers:

Controller Purpose
Api/DeptApiController.php Department CRUD API
Api/TestApiController.php Test/parameter CRUD API
Api/ControlApiController.php Control CRUD API
Api/EntryApiController.php Entry data API

Purpose: Handle HTTP requests, process business logic, and return responses.


Models Directory

Model Purpose
BaseModel.php Base model with camel/snake case conversion
DictDeptModel.php Department dictionary
DictTestModel.php Test dictionary
DictControlModel.php Control dictionary
ControlModel.php Control management
ControlTestModel.php Control-test relationships
DeptModel.php Department operations
TestModel.php Test operations
ResultModel.php Result management
DailyResultModel.php Daily QC results
MonthlyCommentModel.php Monthly comments
ResultCommentModel.php Result comments

Purpose: Handle database operations, data validation, and business logic for each domain entity.


Views Directory

Directory/File Purpose
layout/ Layout templates
dashboard.php Dashboard view
dept/ Department views
test/ Test views
control/ Control views
entry/ Entry views (daily, monthly)
report/ Report views
errors/ Error page templates

Purpose: Presentation layer using PHP templates with TailwindCSS and DaisyUI styling.


Public Directory

File Purpose
index.php Application bootstrap and entry point
js/app.js Main JavaScript application
js/tables.js Table functionality
js/charts.js Chart/rendering functionality
.htaccess URL rewriting for Apache
favicon.ico Site icon
robots.txt Search engine rules

Purpose: Web root directory served by web server.


Writable Directory

Contains runtime-generated files:

  • debugbar/ - Debug toolbar data
  • logs/ - Application logs
  • cache/ - Application cache
  • session/ - Session files

Entry Points

Entry Point Type Description
public/index.php Web Main application entry point
spark CLI CodeIgniter 4 CLI tool

Integration Points

This is a monolith application - all components are contained within a single codebase. No external service integrations detected in quick scan.


Critical Folders Summary

Folder Critical Purpose
app/Config/ Yes All configuration
app/Controllers/ Yes Request handling
app/Models/ Yes Data access layer
app/Views/ Yes UI templates
public/ Yes Web entry point
writable/ Yes Runtime files
tests/ No Unit tests
_bmad/ No Development artifacts
vendor/ No Dependencies