How manvirheer/shift_logger_api works
Main Components
• API Gateway / Entry Point:
• Represented by the NestJS application’s main entry point (src/main.ts). This acts as the interface to the outside world.
• User Management Module:
• Includes components such as User, Admin, and Staff.
• Involves authentication (using JWT strategies, local strategies) and role-based authorization (guards and decorators).
• Plant Module:
• Manages plant details and is associated with users.
• Record Modules:
• Multiple sub-modules exist under “record”, such as steam generation, ash, shipment, inventory, and core record management.
• Each record module contains controllers, services, DTOs, and entities which encapsulate business logic for data logging.
• Shift Modules:
• Cover aspects like shift schedules, shift assignments, shift templates, and shift end entries.
• Data Entry Period:
• A module dedicated to managing the period during which data entries are valid.
• External Systems / Database:
• MySQL is used as the relational database, along with TypeORM for ORM support.
Understand Relationships and Interactions
• The API endpoints (represented by controllers) handle incoming HTTP requests, pass them to services that encapsulate business logic, and then interact with the database via repositories (ORM) by managing entities.
• User entities are associated with various records and plant entries (illustrating many-to-many and many-to-one relationships).
• The various “record” modules, such as steam generation records, interact with both the Plant module and User module (to log who made which data entry).
Architectural Patterns & Technologies
• Follow an MVC-like pattern (Controllers for handling HTTP, Services for business logic, and Entities/Repositories for data access).
• Important frameworks and libraries include:
• NestJS – for the overall application structure.
• TypeORM – for interacting with the MySQL database.
• Passport.js and JWT – for implementing authentication and role-based security.
Detailed Recommendations
• Authentication workflow:
• Middleware/Guard intercepting the request, checking the JWT token, and then permitting access if the user’s role qualifies.
• Under the User module, show separation into authentication (JWT strategy, local strategy), authorization (row-based access using roles.decorator and roles.guard), and CRUD operations.
• For the Record section (including steam generation, ash, shipment, inventory):
• Detail that each record type has its own sub-module with corresponding controllers, services, and entities tied together.
• Use notes to illustrate that interactions between modules may occur through service calls or shared database relationships.
Key Note for the Principal Software Engineer: