GitHunt
ST

stevenmoraleszeta/novaera-saas-erp-db

Novaera SaaS ERP Database provides a dynamic PostgreSQL architecture with metadata-driven modules, tables, and JSONB records, enabling flexible ERP customization through robust stored procedures and comprehensive role-based permissions.

Novaera SaaS ERP - Database Repository

PostgreSQL
SQL
Database
License

Professional database schema and stored procedures for a modern SaaS ERP system

โœจ Introduction

Novaera SaaS ERP Database is a comprehensive PostgreSQL database repository designed for a flexible, modular Enterprise Resource Planning (ERP) system. This repository contains the complete database schema, stored procedures, and business logic for managing a dynamic SaaS platform that allows users to create custom modules, tables, and data structures on the fly.

The system features a metadata-driven architecture where modules, tables, columns, and records are stored as data, enabling dynamic schema creation and management without traditional database migrations.

Key Features

  • ๐Ÿ—๏ธ Dynamic Schema Management: Create modules, tables, and columns programmatically
  • ๐Ÿ‘ฅ User & Role Management: Comprehensive authentication and authorization system
  • ๐Ÿ” Permission System: Fine-grained CRUD permissions per role and table
  • ๐Ÿ“Š Custom Views: User-defined views with sorting and filtering capabilities
  • ๐Ÿ“ JSONB Records: Flexible data storage using PostgreSQL JSONB
  • ๐Ÿ”” Notification System: Real-time notifications and scheduled reminders
  • ๐Ÿ“ File Management: Built-in file storage and management
  • ๐Ÿงช Test Coverage: Comprehensive test stored procedures included

๐Ÿš€ Technologies Used

  • PostgreSQL - Advanced relational database with JSONB support
  • PL/pgSQL - Stored procedures and functions
  • SQL - Database schema and queries

โš™๏ธ Installation

Prerequisites

  • PostgreSQL 12+ installed and running
  • Database user with CREATE privileges
  • Access to a PostgreSQL database instance

Setup Instructions

  1. Clone the repository

    git clone https://github.com/yourusername/novaera-saas-erp-db.git
    cd novaera-saas-erp-db
  2. Configure environment variables

    cp .env.example .env
    # Edit .env with your database credentials
  3. Create the database

    CREATE DATABASE erp_api;
  4. Run the database creation script

    psql -U your_username -d erp_api -f Db_Creation.sql
  5. Load sample data (optional, for testing):

    psql -U your_username -d erp_api -f Db_Seed_SampleData.sql
  6. Install stored procedures (run in order):

    # Users module
    psql -U your_username -d erp_api -f Users/Users_Sp's.sql
    
    # Roles module
    psql -U your_username -d erp_api -f Roles/Roles_Sp's.sql
    
    # Permissions module
    psql -U your_username -d erp_api -f Permissions/Permissions_Sp's.sql
    
    # Modules module
    psql -U your_username -d erp_api -f Modules/Modules_Sp's.sql
    
    # Tables module
    psql -U your_username -d erp_api -f Tables/Tables_Sp's.sql
    
    # Columns module
    psql -U your_username -d erp_api -f Columns/Columns_Sp's.sql
    
    # Records module
    psql -U your_username -d erp_api -f Records/Records_Sp's.sql
    
    # Notifications module
    psql -U your_username -d erp_api -f Notifications/Notifications_Sp's.sql
    
    # Views module
    psql -U your_username -d erp_api -f Views/Views_Sp's.sql
    
    # View Sorts module
    psql -U your_username -d erp_api -f View_Sorts/View_Sorts_Ps's.sql
  7. Run test procedures (optional, for validation):

    psql -U your_username -d erp_api -f Users/Users_Sp's_TESTS.sql
    # Repeat for other modules...

๐Ÿงฉ Project Structure

novaera-saas-erp-db/
โ”‚
โ”œโ”€โ”€ Db_Creation.sql              # Main database schema creation script
โ”œโ”€โ”€ Db_Seed_SampleData.sql       # Sample data for testing and development
โ”‚
โ”œโ”€โ”€ Columns/                     # Column management stored procedures
โ”‚   โ”œโ”€โ”€ Columns_Sp's.sql
โ”‚   โ””โ”€โ”€ Columns_Sp's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Modules/                     # Module management stored procedures
โ”‚   โ”œโ”€โ”€ Modules_Sp's.sql
โ”‚   โ””โ”€โ”€ Modules_SP's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Notifications/               # Notification system stored procedures
โ”‚   โ”œโ”€โ”€ Notifications_Sp's.sql
โ”‚   โ””โ”€โ”€ Notifications_Sp's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Permissions/                 # Permission management stored procedures
โ”‚   โ”œโ”€โ”€ Permissions_Sp's.sql
โ”‚   โ””โ”€โ”€ Permissions_Sp's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Records/                     # Record (data) management stored procedures
โ”‚   โ”œโ”€โ”€ Records_Sp's.sql
โ”‚   โ”œโ”€โ”€ Record_Comments_Sp's.sql
โ”‚   โ””โ”€โ”€ Records_Sp's_tets.sql
โ”‚
โ”œโ”€โ”€ Roles/                       # Role management stored procedures
โ”‚   โ”œโ”€โ”€ Roles_Sp's.sql
โ”‚   โ””โ”€โ”€ Roles_Sp's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Tables/                      # Table management stored procedures
โ”‚   โ”œโ”€โ”€ Tables_Sp's.sql
โ”‚   โ””โ”€โ”€ Tables_Sp's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Users/                       # User management stored procedures
โ”‚   โ”œโ”€โ”€ Users_Sp's.sql
โ”‚   โ””โ”€โ”€ Users_Sp's_TESTS.sql
โ”‚
โ”œโ”€โ”€ Views/                       # View management stored procedures
โ”‚   โ””โ”€โ”€ Views_Sp's.sql
โ”‚
โ”œโ”€โ”€ View_Sorts/                  # View sorting stored procedures
โ”‚   โ””โ”€โ”€ View_Sorts_Ps's.sql
โ”‚
โ”œโ”€โ”€ .env.example                 # Environment variables template
โ”œโ”€โ”€ .gitignore                   # Git ignore rules
โ”œโ”€โ”€ LICENSE                      # Proprietary license
โ””โ”€โ”€ README.md                    # This file

Database Schema Overview

The database consists of the following main tables:

Core Tables

  • modules - System modules (e.g., Sales, Inventory, HR)
  • tables - Logical tables within modules
  • columns - Column definitions for logical tables
  • column_options - Custom options for select-type columns
  • records - Actual data stored as JSONB

User & Authentication Tables

  • users - User accounts and authentication
  • user_login_history - Login history tracking
  • roles - User roles (Admin, Manager, etc.)
  • user_roles - Many-to-many relationship between users and roles

Permission & Access Control Tables

  • permissions - CRUD permissions per role and table

Notification Tables

  • notifications - User notifications and reminders
  • scheduled_notifications - Scheduled notification system

View & Display Tables

  • views - Custom views for data display
  • view_columns - Column visibility and filters per view
  • view_sorts - Sorting configuration for views

Collaboration Tables

  • record_assigned_users - Users assigned to records
  • record_comments - Comments on records
  • record_subscriptions - User subscriptions to record notifications
  • table_collaborators - Collaborators for tables

Audit & Tracking Tables

  • record_changes - Audit log for record changes

File Management Tables

  • files - File storage metadata and binary data

๐Ÿ“– Usage Examples

Creating a Module

SELECT sp_crear_modulo(
    'Sales',
    'Sales and customer management module',
    'https://example.com/icons/sales.svg',
    1  -- created_by user_id
);

Creating a Table within a Module

SELECT crear_tabla_logica(
    1,  -- module_id
    'Customers',
    'Customer information table',
    NULL,  -- original_table_id
    NULL,  -- foreign_table_id
    0      -- position_num
);

Registering a User

SELECT sp_registrar_usuario(
    'John Doe',
    'john.doe@example.com',
    '$2b$10$hashedpassword...'  -- bcrypt hash
);

๐Ÿšข Deployment

  • Render - PostgreSQL hosting (as seen in connection strings)
  • AWS RDS - Managed PostgreSQL service
  • Google Cloud SQL - Fully managed database service
  • Azure Database for PostgreSQL - Enterprise-grade hosting
  • DigitalOcean Managed Databases - Simple and scalable
  • Heroku Postgres - Easy deployment for development

Production Considerations

  1. Backup Strategy: Implement regular automated backups
  2. Connection Pooling: Use PgBouncer or similar for connection management
  3. Monitoring: Set up database monitoring and alerting
  4. Security: Use SSL connections and strong authentication
  5. Performance: Consider read replicas for scaling
  6. Migration Strategy: Use version control for schema changes

๐Ÿ”’ Security Best Practices

  • Always use parameterized queries (stored procedures handle this)
  • Hash passwords using bcrypt or similar
  • Implement rate limiting on authentication endpoints
  • Use SSL/TLS for database connections
  • Regularly audit permissions and roles
  • Keep PostgreSQL updated to the latest stable version

๐Ÿ“œ License

Proprietary License

Copyright (c) 2025 Steven Morales Fallas

All rights reserved. Redistribution, modification, reproduction, sublicensing, or any form of transaction (including commercial, educational, or promotional use) involving this repository, its source code, or derived works is strictly prohibited without the explicit and personal written authorization of the Lead Developer, Steven Morales Fallas.

Unauthorized commercial use, resale, or licensing of this repository or its contents is strictly forbidden and will be subject to applicable legal action.

For licensing inquiries, please contact: Steven Morales Fallas

๐Ÿ‘ค Author

Steven Morales Fallas

Full Stack Developer specializing in SaaS ERP systems, database architecture, and scalable backend solutions.

๐Ÿค Contributing

This is a proprietary project. Contributions are by invitation only. Please contact the author for collaboration opportunities.

๐Ÿ“ž Support

For questions, issues, or licensing inquiries, please contact the repository owner.


Note: This database repository is part of a larger SaaS ERP system. Ensure proper integration with the corresponding API and frontend applications.