Skip to content

erdenebatt/erp-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ERP Platform

A modern, modular ERP (Enterprise Resource Planning) platform built with Go + Fiber, Next.js, and GraphQL.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        ERP Platform                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Frontend (Next.js)          β”‚  Backend (Go + Fiber)            β”‚
β”‚  β”œβ”€β”€ React Components        β”‚  β”œβ”€β”€ Core Platform               β”‚
β”‚  β”œβ”€β”€ Apollo Client           β”‚  β”‚   β”œβ”€β”€ Auth (JWT)              β”‚
β”‚  β”œβ”€β”€ Zustand State           β”‚  β”‚   β”œβ”€β”€ Database (PostgreSQL)   β”‚
β”‚  └── TailwindCSS            β”‚  β”‚   β”œβ”€β”€ Event Bus               β”‚
β”‚                              β”‚  β”‚   β”œβ”€β”€ Module Loader           β”‚
β”‚                              β”‚  β”‚   β”œβ”€β”€ Registry                β”‚
β”‚                              β”‚  β”‚   β”œβ”€β”€ RBAC Permissions        β”‚
β”‚                              β”‚  β”‚   └── Settings                β”‚
β”‚                              β”‚  └── GraphQL API                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                         Modules                                  β”‚
β”‚  β”œβ”€β”€ Sales (Customers, Products, Orders, Invoices)              β”‚
β”‚  β”œβ”€β”€ Inventory (Coming Soon)                                     β”‚
β”‚  β”œβ”€β”€ Accounting (Coming Soon)                                    β”‚
β”‚  └── Custom Modules...                                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Features

Core Platform

  • πŸ” Authentication: JWT-based auth with role support
  • πŸ‘₯ RBAC: Fine-grained role-based access control
  • 🧩 Modular Architecture: Install, enable, disable, uninstall modules
  • πŸ“Š GraphQL API: Flexible, type-safe API
  • πŸ”„ Event Bus: Inter-module communication
  • βš™οΈ Settings Management: Configurable per-module settings
  • πŸ“ Audit Logging: Track all changes

Module System

  • Module Discovery: Automatic discovery from /modules directory
  • Dependency Management: Modules can depend on other modules
  • Database Migrations: Per-module migration support
  • Permission Registration: Modules register their own permissions
  • Event Subscriptions: Subscribe to platform and other module events

πŸš€ Quick Start

Prerequisites

  • Go 1.22+
  • Node.js 20+
  • PostgreSQL 15+
  • Docker & Docker Compose (optional)

Using Docker Compose (Recommended)

# Clone the repository
git clone <repository-url>
cd erp-platform

# Copy environment file
cp .env.example .env

# Start all services
docker-compose up -d

# Access the application
# Frontend: http://localhost:3000
# Backend API: http://localhost:8080
# GraphQL Playground: http://localhost:8080/graphql

Manual Setup

Backend

cd backend

# Install dependencies
go mod download

# Copy and edit config
cp config/config.yaml.example config/config.yaml

# Run the server
make run

# Or with hot reload
make dev

Frontend

cd frontend

# Install dependencies
npm install

# Run development server
npm run dev

πŸ“ Project Structure

erp-platform/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ cmd/
β”‚   β”‚   └── server/          # Application entry point
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ auth/            # Authentication & JWT
β”‚   β”‚   β”œβ”€β”€ database/        # DB connection & migrations
β”‚   β”‚   β”œβ”€β”€ events/          # Event bus
β”‚   β”‚   β”œβ”€β”€ loader/          # Module loader
β”‚   β”‚   β”œβ”€β”€ logger/          # Structured logging
β”‚   β”‚   β”œβ”€β”€ permissions/     # RBAC system
β”‚   β”‚   β”œβ”€β”€ registry/        # Module registry
β”‚   β”‚   β”œβ”€β”€ settings/        # Settings storage
β”‚   β”‚   └── platform.go      # Main platform
β”‚   β”œβ”€β”€ graph/               # GraphQL schema & resolvers
β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   └── sales/           # Example module
β”‚   β”‚       β”œβ”€β”€ module.json  # Module metadata
β”‚   β”‚       β”œβ”€β”€ migrations/  # SQL migrations
β”‚   β”‚       β”œβ”€β”€ models/      # Data models
β”‚   β”‚       β”œβ”€β”€ services/    # Business logic
β”‚   β”‚       └── module.go    # Module entry point
β”‚   β”œβ”€β”€ config/
β”‚   └── go.mod
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/             # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”œβ”€β”€ hooks/           # Custom hooks
β”‚   β”‚   └── lib/             # Utilities & GraphQL
β”‚   β”œβ”€β”€ package.json
β”‚   └── next.config.js
β”œβ”€β”€ docker-compose.yml
└── README.md

🧩 Creating a Module

  1. Create a new directory in backend/modules/<module-name>/

  2. Create module.json:

{
  "id": "my-module",
  "name": "My Module",
  "version": "1.0.0",
  "description": "Description of my module",
  "author": "Your Name",
  "dependencies": [],
  "permissions": [
    "my-module.resource.view",
    "my-module.resource.create"
  ],
  "migrations": true
}
  1. Create migrations in migrations/:
-- 001_create_tables.sql
CREATE TABLE my_module_items (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(255) NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
  1. Implement the module in module.go:
package mymodule

import (
    "context"
    "erp-platform/core/database"
    "erp-platform/core/events"
    "erp-platform/core/registry"
)

type Module struct {
    db       *database.Database
    eventBus *events.EventBus
}

func NewModule(db *database.Database, eventBus *events.EventBus) *Module {
    return &Module{db: db, eventBus: eventBus}
}

func (m *Module) GetMetadata() *registry.ModuleMetadata {
    // Load from module.json
}

func (m *Module) Initialize(ctx context.Context) error {
    // Subscribe to events, initialize services
    return nil
}

func (m *Module) Shutdown(ctx context.Context) error {
    // Cleanup
    return nil
}

πŸ”§ API Reference

REST Endpoints

Method Endpoint Description
POST /api/v1/auth/register Register new user
POST /api/v1/auth/login Login
POST /api/v1/auth/refresh Refresh token
GET /api/v1/modules List modules
POST /api/v1/modules/:id/enable Enable module
POST /api/v1/modules/:id/disable Disable module

GraphQL

Access the GraphQL Playground at http://localhost:8080/graphql

Example queries:

# Login
mutation {
  login(input: { email: "[email protected]", password: "password" }) {
    accessToken
    user { id email }
  }
}

# Get modules
query {
  modules {
    id name version status
  }
}

πŸ” Default Credentials

After initial setup, create an admin user:

curl -X POST http://localhost:8080/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"admin123","first_name":"Admin","last_name":"User"}'

πŸ“ License

MIT License - see LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Built with ❀️ using Go, Next.js, and PostgreSQL

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published