Skip to content

project tree

Azizul Hakim edited this page Jan 3, 2026 · 3 revisions

This document provides a comprehensive overview of the IMS Laravel API Starter project structure, explaining the purpose and organization of each directory and key files.

Directory Structure Overview

ims-laravel-api-starter/
β”œβ”€β”€ πŸ“ app/                     # Application core code
β”œβ”€β”€ πŸ“ bootstrap/               # Application bootstrapping
β”œβ”€β”€ πŸ“ config/                  # Configuration files
β”œβ”€β”€ πŸ“ database/                # Database migrations and seeders
β”œβ”€β”€ πŸ“ docs/                    # Project documentation
β”œβ”€β”€ πŸ“ public/                  # Public assets and index.php
β”œβ”€β”€ πŸ“ resources/               # Views, lang, and frontend assets
β”œβ”€β”€ πŸ“ routes/                  # Application routes
β”œβ”€β”€ πŸ“ storage/                 # Logs, cache, and app files
β”œβ”€β”€ πŸ“ tests/                   # Application tests
β”œβ”€β”€ πŸ“ vendor/                  # Composer dependencies
β”œβ”€β”€ 🐳 Dockerfile              # Production container definition
└── πŸ“„ README.md               # Main project documentation

Detailed Directory Breakdown

πŸ“ app/ - Application Core Code

Contains the application-specific code organized by domain.

app/
β”œβ”€β”€ Console/                    # Artisan commands
β”œβ”€β”€ DTOs/                      # Data Transfer Objects
β”œβ”€β”€ Enums/                     # Application enums
β”œβ”€β”€ Exceptions/                # Custom exceptions
β”œβ”€β”€ Http/
β”‚   β”œβ”€β”€ Controllers/           # HTTP controllers
β”‚   β”œβ”€β”€ Middleware/            # HTTP middleware
β”‚   └── Requests/              # Form requests
β”œβ”€β”€ Models/                    # Eloquent models
β”œβ”€β”€ Policies/                  # Authorization policies
β”œβ”€β”€ Providers/                 # Service providers
β”œβ”€β”€ Repositories/              # Repository pattern implementations
β”œβ”€β”€ Services/                  # Business logic services
└── Traits/                    # Reusable traits

Key Files:

  • Console/Commands/: Custom Artisan commands (CRUD generators, DTO generators)
  • DTOs/: Data Transfer Objects with readonly properties
  • Http/Controllers/Api/V1/: API controllers with resource responses
  • Models/: Eloquent models with relationships and scopes
  • Repositories/: Repository interfaces and implementations
  • Services/: Business logic services following single responsibility

πŸ“ config/ - Configuration Files

config/
β”œβ”€β”€ app.php                    # Application settings
β”œβ”€β”€ auth.php                   # Authentication configuration
β”œβ”€β”€ database.php               # Database connections
β”œβ”€β”€ permission.php             # Laravel Permission settings
β”œβ”€β”€ scribe.php                 # API documentation config
β”œβ”€β”€ telescope.php              # Laravel Telescope config
└── health.php                 # Health check configuration

Key Features:

  • Multi-database support (MySQL, PostgreSQL, SQLite)
  • Laravel Sanctum API authentication
  • Telescope monitoring with built-in auth
  • Health check endpoints configuration
  • API documentation generation settings

πŸ“ database/ - Database Structure

database/
β”œβ”€β”€ factories/                 # Model factories
β”œβ”€β”€ migrations/                # Database migrations
└── seeders/                   # Database seeders

Migration Categories:

  • Core: Users, roles, permissions, personal access tokens
  • System: Failed jobs, password resets, migrations
  • Monitoring: Telescope, Pulse, Health tables

πŸ“ tests/ - Test Suite

tests/
β”œβ”€β”€ Feature/                   # Feature tests
β”œβ”€β”€ Unit/                     # Unit tests
β”œβ”€β”€ Mock/                     # Mock data classes
└── TestCase.php             # Base test case

Test Structure:

  • Feature Tests: API endpoint testing with Pest PHP
  • Unit Tests: Service and repository testing
  • Mock Classes: Reusable test data generators
  • Database Testing: Uses RefreshDatabase trait

πŸ“ routes/ - Application Routes

routes/
β”œβ”€β”€ api.php                    # API routes (v1)
β”œβ”€β”€ console.php                # Artisan commands
└── web.php                    # Web routes (health, docs)

API Versioning:

  • v1 Prefix: All API routes under /api/v1/
  • Resource Routes: RESTful resource controllers
  • Auth Routes: Login, logout, refresh, profile
  • Admin Routes: User, role, permission management

πŸ“ storage/ - Application Storage

storage/
β”œβ”€β”€ app/                       # Application files
β”‚   β”œβ”€β”€ backups/              # Laravel Backup files
β”‚   β”œβ”€β”€ media/                # Media library files
β”‚   └── public/               # Publicly accessible files
β”œβ”€β”€ framework/                 # Framework cache and sessions
β”œβ”€β”€ logs/                     # Application logs
└── telescope/                # Telescope monitoring data

πŸ“ resources/ - Frontend Resources

resources/
β”œβ”€β”€ lang/                      # Language files
β”‚   β”œβ”€β”€ bn/                   # Bangla translations
β”‚   └── en/                   # English translations
└── views/                     # Blade templates
    β”œβ”€β”€ docs/                  # Documentation templates
    └── health/                # Health check templates

Internationalization:

  • Bangla Support: Complete Bangla language pack
  • English Support: Default English translations
  • Custom Translations: Easy to add new languages

Key Configuration Files

Root Level Files

β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ composer.json             # PHP dependencies and scripts
β”œβ”€β”€ package.json              # Node.js dependencies
β”œβ”€β”€ phpunit.xml               # PHPUnit configuration
β”œβ”€β”€ pint.json                 # Laravel Pint code style
└── Dockerfile                # Docker development setup

Docker Configuration

Development Setup:

  • App Container: PHP 8.2 with required extensions
  • Database: MySQL 8.0 with health checks
  • Queue Worker: Separate queue processing container
  • Scheduler: Cron job scheduling container

Services:

  • Web Server: Nginx with PHP-FPM
  • Database: MySQL with optimized settings
  • Cache: Redis for session and cache storage
  • Queue: Redis queue driver

Architecture Patterns

Clean Architecture Implementation

Repository Pattern:

  • Interface definitions in app/Repositories/Interfaces/
  • Implementations in app/Repositories/
  • Dependency injection via service providers

Service Layer:

  • Business logic in app/Services/
  • Single responsibility principle
  • Repository integration

DTO Pattern:

  • Data transfer objects in app/DTOs/
  • Readonly properties for immutability
  • Type-safe data transformation

API Design

RESTful Resources:

  • Resource controllers for CRUD operations
  • Resource collections for data transformation
  • Form request validation

Authentication:

  • Laravel Sanctum for API authentication
  • Personal access tokens
  • Token-based session management

Response Standards:

  • Consistent JSON response format
  • Error handling with proper HTTP codes
  • Pagination support

Development Workflow

Code Generation

# Generate CRUD components
php artisan make:crud Product

# Generate DTO
php artisan make:dto ProductDTO

# Generate Service
php artisan make:service Product/ProductService

Code Quality

# Run code style fixer
php artisan pint

# Run tests
php artisan test

# Clear caches
php artisan optimize:clear

Database Operations

# Run migrations
php artisan migrate

# Seed database
php artisan db:seed

# Generate migration
php artisan make:migration create_products_table

For detailed documentation, see the Features Guide.

πŸ“š Documentation Structure

Home

  • Home - Documentation Overview

πŸš€ Getting Started

⚑ Core Features

πŸ“Š Monitoring & Testing

πŸ› οΈ Development

πŸ”— Quick Links

🀝 Community

Clone this wiki locally