System Architecture¶
The Stratpoint Timesheet Application follows a modern, scalable architecture designed to support enterprise-level operations while maintaining flexibility for future enhancements. This section provides a comprehensive overview of the system's architectural design, components, and interactions.
High-Level Architecture¶
graph TB
subgraph "Client Layer"
A[Web Browser<br/>AngularJS SPA]
B[Mobile Interface<br/>Responsive Web]
C[External APIs<br/>Third-party Integrations]
end
subgraph "Load Balancer"
D[Application Load Balancer]
end
subgraph "Application Layer"
E[Laravel API Server 1]
F[Laravel API Server 2]
G[Laravel API Server N]
end
subgraph "Service Layer"
H[AuthService]
I[ProjectService]
J[UtilizationService]
K[FileUploadService]
end
subgraph "Data Layer"
L[MySQL Primary]
M[MySQL Replica]
N[Redis Cache]
O[AWS S3 Storage]
end
subgraph "External Systems"
P[NetSuite ERP]
Q[Google Drive]
R[Email Services]
S[AWS S3]
end
A --> D
B --> D
C --> D
D --> E
D --> F
D --> G
E --> H
E --> I
E --> J
E --> K
F --> H
F --> I
F --> J
F --> K
G --> H
G --> I
G --> J
G --> K
E --> L
F --> L
G --> L
E --> M
F --> M
G --> M
E --> N
F --> N
G --> N
E --> O
F --> O
G --> O
H --> P
H --> Q
I --> R
J --> P
K --> Q
Note: The above diagram represents the system's scalable architecture design. The current deployment may use a single Laravel application server, but the architecture supports horizontal scaling to multiple servers with load balancing as business needs grow.
Architectural Patterns¶
Model-View-Controller (MVC)¶
The application follows the MVC pattern with clear separation of concerns:
- Models
- Eloquent ORM models representing business entities and database interactions
- Views
- AngularJS templates and components for user interface presentation
- Controllers
- Laravel controllers handling HTTP requests and business logic coordination
Active Record Pattern¶
Data access follows Laravel's Active Record pattern using Eloquent ORM:
graph LR
A[Controller] --> B[Service Layer]
B --> C[Eloquent Model]
C --> D[MySQL Database]
A --> C
Service-Oriented Architecture (SOA)¶
Business logic is encapsulated in service classes:
- AuthService: Handles user authentication and JWT token management
- ProjectService: Manages project-related business logic
- UtilizationService: Handles resource utilization calculations
- ProjectResourceService: Manages project resource assignments
- PaymentMilestoneService: Handles payment milestone processing
- FileUploadService: Manages file upload operations
- BrewerySsoService: Handles SSO authentication integration
Component Architecture¶
Frontend Architecture¶
graph TB
subgraph "AngularJS Application"
A[App Module]
B[Route Configuration]
C[Controllers]
D[Services]
E[Directives]
F[Filters]
G[Templates]
end
subgraph "UI Components"
H[Navigation Menu]
I[Data Tables]
J[Forms]
K[Charts]
L[Modals]
end
subgraph "External Libraries"
M[Angular UI Bootstrap]
N[FullCalendar]
O[Chart.js with Day.js]
P[Moment.js]
end
A --> B
A --> C
A --> D
A --> E
A --> F
B --> G
C --> H
C --> I
C --> J
D --> K
E --> L
C --> M
C --> N
C --> O
D --> P
Backend Architecture¶
graph TB
subgraph "HTTP Layer"
A[Route Definitions]
B[Middleware Stack]
C[Request Validation]
end
subgraph "Application Layer"
D[Controllers]
E[Form Requests]
F[Resources/Transformers]
end
subgraph "Business Logic Layer"
G[Service Classes]
H[Business Rules]
I[Event Handlers]
end
subgraph "Data Access Layer"
J[Eloquent Models]
K[Query Builders]
L[Database Migrations]
end
subgraph "Infrastructure Layer"
M[Cache Management]
N[File Storage]
O[Queue System]
P[External APIs]
end
A --> B
B --> C
C --> D
D --> E
D --> F
E --> G
F --> G
G --> H
G --> I
H --> J
I --> J
J --> K
J --> L
G --> M
G --> N
G --> O
G --> P
Data Architecture¶
Database Design¶
The system uses a normalized relational database design with the following key entity relationships:
erDiagram
USERS ||--o{ TIMELOGS : creates
USERS ||--o{ PROJECT_USERS : assigned_to
USERS ||--o{ LEAVES : requests
PROJECTS ||--o{ PROJECT_USERS : contains
PROJECTS ||--o{ TIMELOGS : tracks_time_for
PROJECTS ||--o{ PAYMENT_MILESTONES : has
CLIENTS ||--o{ PROJECTS : owns
TASKTYPES ||--o{ TIMELOGS : categorizes
ROLES ||--o{ USERS : assigned_to
PERMISSIONS ||--o{ ROLES : granted_to
USERS {
int id PK
string email UK
string firstname
string lastname
int role_id FK
datetime start_date
datetime end_date
boolean is_active
}
PROJECTS {
int id PK
string name
int client_id FK
datetime start_date
datetime end_date
int status_id FK
decimal budget
}
TIMELOGS {
int id PK
int user_id FK
int project_user_id FK
int tasktype_id FK
datetime start_time
datetime stop_time
decimal spent_hours
string description
string status
}
Caching Strategy¶
The application implements a multi-layer caching strategy:
- Application Cache (Redis)
- Frequently accessed data, session storage, and temporary data
- Database Query Cache
- MySQL query result caching for improved performance
- HTTP Cache
- Browser caching for static assets and API responses
- CDN Cache
- Content delivery network for global asset distribution
Data Flow¶
sequenceDiagram
participant U as User
participant F as Frontend
participant A as API
participant S as Service
participant D as Database
participant C as Cache
U->>F: User Action
F->>A: HTTP Request
A->>A: Authentication
A->>A: Authorization
A->>S: Business Logic
S->>C: Check Cache
alt Cache Hit
C->>S: Return Cached Data
else Cache Miss
S->>D: Query Database
D->>S: Return Data
S->>C: Store in Cache
end
S->>A: Return Result
A->>F: JSON Response
F->>U: Update UI
Security Architecture¶
Authentication Flow¶
sequenceDiagram
participant U as User
participant F as Frontend
participant A as Auth Service
participant D as Database
U->>F: Login Request (Email/Password)
F->>A: Authentication Request
A->>D: Validate Credentials
D->>A: User Data
A->>A: Generate JWT Token
A->>F: Return Token + User Data
F->>F: Store Token in LocalStorage
F->>U: Login Success
Note over U,D: All subsequent API calls include JWT token in Authorization header
Current Implementation: The system currently uses JWT-based authentication with email/password credentials.
Future Development: SSO infrastructure (BrewerySsoService) exists in the codebase but is not currently implemented or active. This provides a foundation for future SSO integration when business requirements demand it.
Authorization Model¶
The system implements a role-based access control (RBAC) model:
- Roles: Define sets of permissions (Admin, Manager, Employee, etc.)
- Permissions: Granular access controls for specific features
- Hierarchical Approvers: Support for organizational approval hierarchies
- Resource-Level Security: Project and data-level access controls
Integration Architecture¶
External System Integration¶
graph LR
subgraph "Stratpoint Timesheet"
A[Laravel Controllers]
B[Service Classes]
C[Queue System]
D[HTTP Client]
end
subgraph "External Systems"
E[NetSuite ERP<br/>Database Refs]
F[Google Drive]
G[Email Services]
H[AWS S3]
I[F1 API]
J[SINOP API]
K[CSAT API]
end
A --> B
B --> D
D --> F
D --> G
D --> H
D --> I
D --> J
D --> K
B --> E
C --> B
API Integration Patterns¶
- Synchronous Integration
- Real-time API calls for immediate data exchange
- Asynchronous Integration
- Queue-based processing for non-critical operations
- Event-Driven Integration
- Event-based triggers for automated workflows
- Batch Integration
- Scheduled batch processes for bulk data operations
Scalability and Performance¶
Horizontal Scaling¶
The architecture supports horizontal scaling through:
- Load Balancing: Multiple application server instances
- Database Replication: Read replicas for improved performance
- Microservices: Modular services that can be scaled independently
- CDN Integration: Global content distribution
Performance Optimization¶
- Database Optimization
- Indexed queries, optimized table structures, and query optimization
- Caching Layers
- Multi-level caching for improved response times
- Asynchronous Processing
- Background job processing for heavy operations
- Code Optimization
- Efficient algorithms and optimized code paths
Deployment Architecture¶
Environment Structure¶
graph TB
subgraph "Production Environment"
A[Load Balancer]
B[App Server 1]
C[App Server 2]
D[Database Primary]
E[Database Replica]
F[Redis Cluster]
end
subgraph "Staging Environment"
G[Staging Server]
H[Staging Database]
I[Staging Cache]
end
subgraph "Development Environment"
J[Dev Server]
K[Dev Database]
L[Local Cache]
end
A --> B
A --> C
B --> D
C --> D
B --> E
C --> E
B --> F
C --> F
Containerization¶
The application is containerized using Docker:
- Application Containers: Laravel application instances
- Database Containers: MySQL database instances
- Cache Containers: Redis cache instances
- Web Server Containers: Apache/Nginx web servers
This architectural design ensures the Stratpoint Timesheet Application can scale effectively, maintain high performance, and adapt to changing business requirements while providing a secure and reliable platform for enterprise operations.