How augustomelara-dev/sistema-gestion-inventario works
1. Repository shape
- This is a single-file C application: all application logic lives in main.c.
- There are no separate libraries, services, or modules in the repo; the architecture is intentionally monolithic.
2. Primary runtime
- The output is a console executable compiled with C99/GCC.
- The app is designed for Windows-style terminal usage, using commands like cls and pause for screen control and flow.
3. Core domain boundary: inventory management
- The main business object is a product/inventory record with fields implied by the README: code, name, quantity, price, and computed total value.
- The in-memory inventory acts as the working set for all CRUD and reporting operations.
4. User interaction layer
- All input and output are handled through the command-line interface.
- The UI boundary is interactive and menu-driven, with user actions triggering add, modify, show, and search operations.
5. CRUD subsystem
- The app supports the standard inventory lifecycle:
- Add new products with unique code checks
- Modify existing products
- Display the full inventory in tabular form
- Search by product code
- These operations all update the same in-memory dataset.
6. Reporting and analytics subsystem
- The program derives operational metrics from inventory data:
- Low-stock alerts for items under 10 units
- Total inventory value as a financial metric
- Counts and stock totals for overall status
- These are read-only views over the same central inventory state.
7. Persistence boundary
- Data is persisted to a flat file named inventario.txt using CSV-like comma-separated records.
- On startup, the program loads existing data if the file exists; otherwise it initializes an empty inventory.
- On exit, it auto-saves the current state back to disk.
8. Data integrity and file safety
- Names are sanitized before persistence by replacing commas with spaces so the file structure is not broken.
- The README indicates the calculated total is recomputed dynamically, so stored and displayed values stay consistent.
9. Input validation / defensive behavior
- The app includes explicit protections against bad user input:
- bounded string reads
- return-value checks on numeric input
- buffer cleanup after invalid input
- This makes the UI loop resilient to malformed keyboard input rather than crashing or hanging.
10. External dependencies and infrastructure
- There are no network services, databases, or background daemons.
- The only external dependency is the local filesystem, which serves as the persistence layer.
11. Diagramming takeaway
- The clean architecture view is: Console user → input validation/UI logic → inventory operations in memory → reporting and persistence → inventario.txt.
- Everything is contained in one process, with the file as the only durable boundary outside memory.
12. Repository artifacts
- .gitignore likely excludes generated build artifacts and the runtime data file.
- README.md documents behavior but does not add architectural components beyond what main.c already implements.
Main entry points: main.c Menu flow
Components 12
Monolithic app
Single-file console application in main.c
- Console UI · Menu-driven terminal interaction for user commands
main.c - Input guard · Bounds checks, numeric parsing, and buffer cleanup for malformed input
main.c - Menu flow · Main command loop that routes user actions
main.c - CRUD ops · Add, modify, display, and search products
main.c - Reports · Low-stock alerts, totals, counts, and inventory value
main.c - Inventory state · Working set of product records used by all operations
main.c - Product record · Code, name, quantity, price, and computed total value
main.c - Persistence · Loads and saves inventory data as comma-separated records
main.c - Startup load · Reads existing inventory state if the data file exists
main.c - Auto-save · Writes current inventory state back on exit
main.c - Sanitize names · Replaces commas in names before persistence
main.c - inventario.txt · On-disk inventory data file
Connections 13
- Console UI → Input guard: accepts · Terminal input is validated before use
- Input guard → Menu flow: drives · Validated commands enter the main loop
- Menu flow → CRUD ops: routes · Menu selections trigger inventory actions
- Menu flow → Reports: routes · Menu selections trigger read-only reports
- CRUD ops → Inventory state: updates · Mutating operations change the shared working set
- Reports → Inventory state: reads · Analytics are derived from current inventory state
- CRUD ops → Product record: manages · Operations create and update product records
- Inventory state → Persistence: persists via · Current state is serialized to disk
- Persistence → Startup load: includes · Startup path restores prior state
- Persistence → Auto-save: includes · Exit path stores current state
- Startup load → inventario.txt: reads · Loads data from the inventory file
- Auto-save → Sanitize names: uses · Names are cleaned before writing records
- Sanitize names → inventario.txt: writes · Sanitized records are written to disk