insforge 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +58 -0
- package/.env.example +49 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +83 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +79 -0
- package/.github/copilot-instructions.md +147 -0
- package/.github/workflows/build-image.yml +65 -0
- package/.github/workflows/ci-premerge-check.yml +24 -0
- package/.github/workflows/deploy-aws.yml +130 -0
- package/.github/workflows/lint-and-format.yml +33 -0
- package/.prettierignore +65 -0
- package/.prettierrc +9 -0
- package/CHANGELOG.md +3 -0
- package/CONTRIBUTING.md +126 -0
- package/Dockerfile +27 -0
- package/GITHUB_OAUTH_SETUP.md +49 -0
- package/GOOGLE_OAUTH_SETUP.md +148 -0
- package/LICENSE +201 -0
- package/README.md +134 -0
- package/assets/Dark.svg +23 -0
- package/assets/archDiagram.png +0 -0
- package/assets/banner.png +0 -0
- package/assets/mcpInstallv2.png +0 -0
- package/assets/sampleResponse.png +0 -0
- package/assets/signin.png +0 -0
- package/assets/userflow.png +0 -0
- package/backend/migrations/000_create-base-tables.sql +142 -0
- package/backend/migrations/001_create-helper-functions.sql +41 -0
- package/backend/migrations/002_rename-auth-tables.sql +30 -0
- package/backend/migrations/003_create-users-table.sql +56 -0
- package/backend/migrations/004_add-reload-postgrest-func.sql +24 -0
- package/backend/migrations/005_enable-project-admin-modify-users.sql +30 -0
- package/backend/migrations/006_modify-ai-usage-table.sql +25 -0
- package/backend/migrations/007_drop-metadata-table.sql +2 -0
- package/backend/migrations/008_add-system-tables.sql +77 -0
- package/backend/migrations/009_add-function-secrets.sql +24 -0
- package/backend/migrations/010_modify-ai-config-modalities.sql +93 -0
- package/backend/migrations/011_refactor-secrets-table.sql +15 -0
- package/backend/migrations/012_add-storage-uploaded-by.sql +8 -0
- package/backend/package.json +75 -0
- package/backend/src/api/middleware/auth.ts +240 -0
- package/backend/src/api/middleware/error.ts +231 -0
- package/backend/src/api/middleware/upload.ts +59 -0
- package/backend/src/api/routes/agent.ts +29 -0
- package/backend/src/api/routes/ai.ts +472 -0
- package/backend/src/api/routes/auth.oauth.ts +482 -0
- package/backend/src/api/routes/auth.ts +386 -0
- package/backend/src/api/routes/database.advance.ts +275 -0
- package/backend/src/api/routes/database.records.ts +246 -0
- package/backend/src/api/routes/database.tables.ts +161 -0
- package/backend/src/api/routes/docs.ts +66 -0
- package/backend/src/api/routes/functions.ts +183 -0
- package/backend/src/api/routes/logs.ts +150 -0
- package/backend/src/api/routes/metadata.ts +160 -0
- package/backend/src/api/routes/openapi.ts +82 -0
- package/backend/src/api/routes/secrets.ts +199 -0
- package/backend/src/api/routes/storage.ts +547 -0
- package/backend/src/api/routes/usage.ts +96 -0
- package/backend/src/core/ai/chat.ts +207 -0
- package/backend/src/core/ai/client.ts +242 -0
- package/backend/src/core/ai/config.ts +187 -0
- package/backend/src/core/ai/image.ts +156 -0
- package/backend/src/core/ai/model.ts +117 -0
- package/backend/src/core/ai/usage.ts +290 -0
- package/backend/src/core/auth/auth.ts +781 -0
- package/backend/src/core/auth/oauth.ts +398 -0
- package/backend/src/core/database/advance.ts +1074 -0
- package/backend/src/core/database/manager.ts +178 -0
- package/backend/src/core/database/table.ts +772 -0
- package/backend/src/core/documentation/agent.ts +689 -0
- package/backend/src/core/documentation/openapi.ts +856 -0
- package/backend/src/core/functions/functions.ts +310 -0
- package/backend/src/core/logs/analytics.ts +76 -0
- package/backend/src/core/logs/audit.ts +255 -0
- package/backend/src/core/logs/providers/base.provider.ts +83 -0
- package/backend/src/core/logs/providers/cloudwatch.provider.ts +510 -0
- package/backend/src/core/logs/providers/localdb.provider.ts +246 -0
- package/backend/src/core/secrets/encryption.ts +58 -0
- package/backend/src/core/secrets/secrets.ts +410 -0
- package/backend/src/core/socket/socket.ts +388 -0
- package/backend/src/core/socket/types.ts +79 -0
- package/backend/src/core/storage/storage.ts +923 -0
- package/backend/src/server.ts +288 -0
- package/backend/src/types/ai.ts +46 -0
- package/backend/src/types/auth.ts +90 -0
- package/backend/src/types/database.ts +136 -0
- package/backend/src/types/error-constants.ts +86 -0
- package/backend/src/types/logs.ts +47 -0
- package/backend/src/types/profile.ts +55 -0
- package/backend/src/types/storage.ts +23 -0
- package/backend/src/utils/cloud-token.ts +39 -0
- package/backend/src/utils/constants.ts +1 -0
- package/backend/src/utils/environment.ts +35 -0
- package/backend/src/utils/helpers.ts +49 -0
- package/backend/src/utils/logger.ts +13 -0
- package/backend/src/utils/response.ts +62 -0
- package/backend/src/utils/seed.ts +205 -0
- package/backend/src/utils/sql-parser.ts +63 -0
- package/backend/src/utils/uuid.ts +9 -0
- package/backend/src/utils/validations.ts +129 -0
- package/backend/tests/README.md +134 -0
- package/backend/tests/cleanup-all-test-data.sh +231 -0
- package/backend/tests/cloud/test-s3-multitenant.sh +132 -0
- package/backend/tests/local/comprehensive-curl-tests.sh +156 -0
- package/backend/tests/local/test-auth-router.sh +144 -0
- package/backend/tests/local/test-database-router.sh +222 -0
- package/backend/tests/local/test-e2e.sh +241 -0
- package/backend/tests/local/test-fk-errors.sh +97 -0
- package/backend/tests/local/test-id-field.sh +201 -0
- package/backend/tests/local/test-public-bucket.sh +265 -0
- package/backend/tests/local/test-secrets.sh +248 -0
- package/backend/tests/local/test-serverless-functions.sh.disabled +325 -0
- package/backend/tests/local/test-traditional-rest.sh +209 -0
- package/backend/tests/manual/README.md +51 -0
- package/backend/tests/manual/create-large-table-simple.sql +11 -0
- package/backend/tests/manual/seed-large-table.sql +101 -0
- package/backend/tests/manual/setup-large-table-extras.sql +34 -0
- package/backend/tests/manual/test-better-auth.sh +303 -0
- package/backend/tests/manual/test-bulk-upsert.sh +410 -0
- package/backend/tests/manual/test-database-advance.sh +297 -0
- package/backend/tests/manual/test-postgrest-stability.sh +192 -0
- package/backend/tests/manual/test-rawsql-export-import.sh +412 -0
- package/backend/tests/manual/test-universal-storage.sh +264 -0
- package/backend/tests/manual/test-users.sql +18 -0
- package/backend/tests/run-all-tests.sh +140 -0
- package/backend/tests/setup.ts +22 -0
- package/backend/tests/test-config.sh +303 -0
- package/backend/tsconfig.json +23 -0
- package/backend/tsup.config.ts +18 -0
- package/backend/vitest.config.ts +22 -0
- package/docker-compose.prod.yml +145 -0
- package/docker-compose.yml +167 -0
- package/docker-init/db/db-init.sql +125 -0
- package/docker-init/db/jwt.sql +5 -0
- package/docker-init/db/logs.sql +9 -0
- package/docker-init/db/postgresql.conf +17 -0
- package/docs/deprecated/insforge-auth-api.md +215 -0
- package/docs/deprecated/insforge-auth-sdk.md +100 -0
- package/docs/deprecated/insforge-db-api.md +359 -0
- package/docs/deprecated/insforge-db-sdk.md +140 -0
- package/docs/deprecated/insforge-debug-sdk.md +157 -0
- package/docs/deprecated/insforge-debug.md +65 -0
- package/docs/deprecated/insforge-instructions.md +124 -0
- package/docs/deprecated/insforge-project.md +118 -0
- package/docs/deprecated/insforge-storage-api.md +279 -0
- package/docs/deprecated/insforge-storage-sdk.md +159 -0
- package/docs/insforge-instructions-sdk.md +407 -0
- package/eslint.config.js +317 -0
- package/examples/oauth/frontend-oauth-example.html +251 -0
- package/examples/response-examples.md +444 -0
- package/frontend/README.md +112 -0
- package/frontend/components.json +17 -0
- package/frontend/index.html +13 -0
- package/frontend/package.json +63 -0
- package/frontend/public/favicon.ico +0 -0
- package/frontend/src/App.tsx +106 -0
- package/frontend/src/assets/icons/checkbox_checked.svg +6 -0
- package/frontend/src/assets/icons/checkbox_undetermined.svg +6 -0
- package/frontend/src/assets/icons/checked.svg +3 -0
- package/frontend/src/assets/icons/error.svg +3 -0
- package/frontend/src/assets/icons/pencil.svg +4 -0
- package/frontend/src/assets/icons/refresh.svg +4 -0
- package/frontend/src/assets/icons/step_active.svg +3 -0
- package/frontend/src/assets/icons/step_inactive.svg +11 -0
- package/frontend/src/assets/icons/warning.svg +3 -0
- package/frontend/src/assets/logos/amazon.svg +1 -0
- package/frontend/src/assets/logos/claude_code.svg +3 -0
- package/frontend/src/assets/logos/cline.svg +6 -0
- package/frontend/src/assets/logos/cursor.svg +20 -0
- package/frontend/src/assets/logos/discord.svg +9 -0
- package/frontend/src/assets/logos/gemini.svg +19 -0
- package/frontend/src/assets/logos/github.svg +5 -0
- package/frontend/src/assets/logos/google.svg +13 -0
- package/frontend/src/assets/logos/grok.svg +10 -0
- package/frontend/src/assets/logos/insforge_dark.svg +15 -0
- package/frontend/src/assets/logos/insforge_light.svg +15 -0
- package/frontend/src/assets/logos/openai.svg +10 -0
- package/frontend/src/assets/logos/roo_code.svg +9 -0
- package/frontend/src/assets/logos/trae.svg +3 -0
- package/frontend/src/assets/logos/windsurf.svg +10 -0
- package/frontend/src/components/ButtonWithLoading.tsx +27 -0
- package/frontend/src/components/Checkbox.tsx +61 -0
- package/frontend/src/components/CodeBlock.tsx +32 -0
- package/frontend/src/components/ConfirmDialog.tsx +96 -0
- package/frontend/src/components/CopyButton.tsx +69 -0
- package/frontend/src/components/DeleteActionButton.tsx +42 -0
- package/frontend/src/components/EmptyState.tsx +41 -0
- package/frontend/src/components/ErrorState.tsx +35 -0
- package/frontend/src/components/FeatureSidebar.tsx +126 -0
- package/frontend/src/components/FeatureSidebarItem.tsx +101 -0
- package/frontend/src/components/JsonHighlight.tsx +61 -0
- package/frontend/src/components/LoadingState.tsx +16 -0
- package/frontend/src/components/PaginationControls.tsx +54 -0
- package/frontend/src/components/PromptDialog.tsx +68 -0
- package/frontend/src/components/SearchInput.tsx +90 -0
- package/frontend/src/components/SelectionClearButton.tsx +26 -0
- package/frontend/src/components/Stepper.tsx +139 -0
- package/frontend/src/components/ThemeToggle.tsx +58 -0
- package/frontend/src/components/TypeBadge.tsx +20 -0
- package/frontend/src/components/datagrid/DataGrid.tsx +264 -0
- package/frontend/src/components/datagrid/DefaultCellRenderer.tsx +114 -0
- package/frontend/src/components/datagrid/IdCell.tsx +44 -0
- package/frontend/src/components/datagrid/SortableHeader.tsx +74 -0
- package/frontend/src/components/datagrid/cell-editors/BooleanCellEditor.tsx +54 -0
- package/frontend/src/components/datagrid/cell-editors/DateCellEditor.tsx +483 -0
- package/frontend/src/components/datagrid/cell-editors/JsonCellEditor.tsx +362 -0
- package/frontend/src/components/datagrid/cell-editors/TextCellEditor.tsx +38 -0
- package/frontend/src/components/datagrid/cell-editors/index.ts +14 -0
- package/frontend/src/components/datagrid/cell-editors/types.ts +43 -0
- package/frontend/src/components/datagrid/datagridTypes.tsx +72 -0
- package/frontend/src/components/datagrid/index.tsx +20 -0
- package/frontend/src/components/index.ts +39 -0
- package/frontend/src/components/layout/AppHeader.tsx +146 -0
- package/frontend/src/components/layout/AppSidebar.tsx +190 -0
- package/frontend/src/components/layout/CloudLayout.tsx +95 -0
- package/frontend/src/components/layout/Layout.tsx +43 -0
- package/frontend/src/components/radix/Alert.tsx +45 -0
- package/frontend/src/components/radix/AlertDialog.tsx +115 -0
- package/frontend/src/components/radix/Avatar.tsx +45 -0
- package/frontend/src/components/radix/Badge.tsx +33 -0
- package/frontend/src/components/radix/Button.tsx +50 -0
- package/frontend/src/components/radix/Card.tsx +58 -0
- package/frontend/src/components/radix/Dialog.tsx +98 -0
- package/frontend/src/components/radix/DropdownMenu.tsx +185 -0
- package/frontend/src/components/radix/Form.tsx +167 -0
- package/frontend/src/components/radix/Input.tsx +22 -0
- package/frontend/src/components/radix/Label.tsx +19 -0
- package/frontend/src/components/radix/Popover.tsx +29 -0
- package/frontend/src/components/radix/ScrollArea.tsx +44 -0
- package/frontend/src/components/radix/Select.tsx +151 -0
- package/frontend/src/components/radix/Separator.tsx +26 -0
- package/frontend/src/components/radix/Sheet.tsx +119 -0
- package/frontend/src/components/radix/Skeleton.tsx +7 -0
- package/frontend/src/components/radix/Switch.tsx +29 -0
- package/frontend/src/components/radix/Tabs.tsx +50 -0
- package/frontend/src/components/radix/Textarea.tsx +21 -0
- package/frontend/src/components/radix/Tooltip.tsx +28 -0
- package/frontend/src/features/ai/components/AIConfigCard.tsx +154 -0
- package/frontend/src/features/ai/components/AIConfigDialog.tsx +76 -0
- package/frontend/src/features/ai/components/AIConfigForm.tsx +222 -0
- package/frontend/src/features/ai/components/AIEmptyState.tsx +18 -0
- package/frontend/src/features/ai/components/fields/ModalityField.tsx +87 -0
- package/frontend/src/features/ai/components/fields/ModelSelectionField.tsx +134 -0
- package/frontend/src/features/ai/components/fields/SystemPromptField.tsx +33 -0
- package/frontend/src/features/ai/helpers.ts +155 -0
- package/frontend/src/features/ai/hooks/useAIConfigs.ts +221 -0
- package/frontend/src/features/ai/hooks/useAIUsage.ts +77 -0
- package/frontend/src/features/ai/page/AIPage.tsx +178 -0
- package/frontend/src/features/ai/services/ai.service.ts +148 -0
- package/frontend/src/features/auth/components/AddOAuthDialog.tsx +106 -0
- package/frontend/src/features/auth/components/AuthMethodTab.tsx +238 -0
- package/frontend/src/features/auth/components/OAuthConfigDialog.tsx +303 -0
- package/frontend/src/features/auth/components/OAuthEmptyState.tsx +15 -0
- package/frontend/src/features/auth/components/UserFormDialog.tsx +248 -0
- package/frontend/src/features/auth/components/UsersDataGrid.tsx +183 -0
- package/frontend/src/features/auth/components/UsersTab.tsx +114 -0
- package/frontend/src/features/auth/hooks/useOAuthConfig.ts +129 -0
- package/frontend/src/features/auth/hooks/useUsers.ts +57 -0
- package/frontend/src/features/auth/index.ts +9 -0
- package/frontend/src/features/auth/page/AuthenticationPage.tsx +169 -0
- package/frontend/src/features/auth/services/auth.service.ts +112 -0
- package/frontend/src/features/auth/services/oauth.service.ts +49 -0
- package/frontend/src/features/dashboard/page/DashboardPage.tsx +194 -0
- package/frontend/src/features/database/components/ColumnTypeSelect.tsx +64 -0
- package/frontend/src/features/database/components/DatabaseDataGrid.tsx +282 -0
- package/frontend/src/features/database/components/ForeignKeyCell.tsx +187 -0
- package/frontend/src/features/database/components/ForeignKeyPopover.tsx +378 -0
- package/frontend/src/features/database/components/LinkRecordModal.tsx +288 -0
- package/frontend/src/features/database/components/RecordFormDialog.tsx +164 -0
- package/frontend/src/features/database/components/RecordFormField.tsx +568 -0
- package/frontend/src/features/database/components/TableEmptyState.tsx +21 -0
- package/frontend/src/features/database/components/TableForm.tsx +656 -0
- package/frontend/src/features/database/components/TableFormColumn.tsx +137 -0
- package/frontend/src/features/database/components/TableListSkeleton.tsx +9 -0
- package/frontend/src/features/database/components/TableSidebar.tsx +47 -0
- package/frontend/src/features/database/constants.ts +26 -0
- package/frontend/src/features/database/helpers.ts +125 -0
- package/frontend/src/features/database/hooks/UseLinkModal.tsx +78 -0
- package/frontend/src/features/database/index.ts +12 -0
- package/frontend/src/features/database/page/DatabasePage.tsx +626 -0
- package/frontend/src/features/database/schema.ts +25 -0
- package/frontend/src/features/database/services/database.service.ts +216 -0
- package/frontend/src/features/functions/components/FunctionEmptyState.tsx +15 -0
- package/frontend/src/features/functions/components/FunctionRow.tsx +71 -0
- package/frontend/src/features/functions/components/FunctionViewer.tsx +46 -0
- package/frontend/src/features/functions/components/FunctionsContent.tsx +88 -0
- package/frontend/src/features/functions/components/FunctionsSidebar.tsx +56 -0
- package/frontend/src/features/functions/components/SecretEmptyState.tsx +23 -0
- package/frontend/src/features/functions/components/SecretRow.tsx +68 -0
- package/frontend/src/features/functions/components/SecretsContent.tsx +120 -0
- package/frontend/src/features/functions/hooks/useFunctions.ts +106 -0
- package/frontend/src/features/functions/page/FunctionsPage.tsx +28 -0
- package/frontend/src/features/functions/services/functions.service.ts +48 -0
- package/frontend/src/features/login/components/AuthErrorBoundary.tsx +87 -0
- package/frontend/src/features/login/components/PrivateRoute.tsx +24 -0
- package/frontend/src/features/login/page/CloudLoginPage.tsx +93 -0
- package/frontend/src/features/login/page/LoginPage.tsx +174 -0
- package/frontend/src/features/logs/components/AnalyticsLogsTable.tsx +313 -0
- package/frontend/src/features/logs/components/LogsTable.tsx +199 -0
- package/frontend/src/features/logs/hooks/useAuditLogs.ts +39 -0
- package/frontend/src/features/logs/index.ts +5 -0
- package/frontend/src/features/logs/page/AnalyticsLogsPage.tsx +530 -0
- package/frontend/src/features/logs/page/AuditsPage.tsx +192 -0
- package/frontend/src/features/logs/services/log.service.ts +171 -0
- package/frontend/src/features/metadata/hooks/useMetadata.ts +53 -0
- package/frontend/src/features/metadata/index.ts +0 -0
- package/frontend/src/features/metadata/page/MetadataPage.tsx +136 -0
- package/frontend/src/features/metadata/services/metadata.service.ts +17 -0
- package/frontend/src/features/onboard/components/CompletionCard.tsx +41 -0
- package/frontend/src/features/onboard/components/OnboardButton.tsx +84 -0
- package/frontend/src/features/onboard/components/StepContent.tsx +91 -0
- package/frontend/src/features/onboard/components/TestConnectionStep.tsx +53 -0
- package/frontend/src/features/onboard/components/mcp/CursorDeeplinkGenerator.tsx +35 -0
- package/frontend/src/features/onboard/components/mcp/McpInstallation.tsx +144 -0
- package/frontend/src/features/onboard/components/mcp/index.ts +4 -0
- package/frontend/src/features/onboard/components/mcp/mcp-helper.tsx +98 -0
- package/frontend/src/features/onboard/index.ts +3 -0
- package/frontend/src/features/onboard/page/OnBoardPage.tsx +104 -0
- package/frontend/src/features/onboard/types.ts +8 -0
- package/frontend/src/features/secrets/hooks/useSecrets.ts +139 -0
- package/frontend/src/features/secrets/services/secrets.service.ts +57 -0
- package/frontend/src/features/storage/components/BucketEmptyState.tsx +19 -0
- package/frontend/src/features/storage/components/BucketFormDialog.tsx +194 -0
- package/frontend/src/features/storage/components/BucketListSkeleton.tsx +17 -0
- package/frontend/src/features/storage/components/FilePreviewDialog.tsx +287 -0
- package/frontend/src/features/storage/components/StorageDataGrid.tsx +239 -0
- package/frontend/src/features/storage/components/StorageManager.tsx +236 -0
- package/frontend/src/features/storage/components/StorageSidebar.tsx +44 -0
- package/frontend/src/features/storage/components/UploadToast.tsx +46 -0
- package/frontend/src/features/storage/index.ts +3 -0
- package/frontend/src/features/storage/page/StoragePage.tsx +553 -0
- package/frontend/src/features/storage/services/storage.service.ts +144 -0
- package/frontend/src/features/visualizer/components/AuthNode.tsx +107 -0
- package/frontend/src/features/visualizer/components/BucketNode.tsx +34 -0
- package/frontend/src/features/visualizer/components/SchemaVisualizer.tsx +359 -0
- package/frontend/src/features/visualizer/components/TableNode.tsx +152 -0
- package/frontend/src/features/visualizer/components/VisualizerSkeleton.tsx +24 -0
- package/frontend/src/features/visualizer/components/index.ts +5 -0
- package/frontend/src/features/visualizer/page/VisualizerPage.tsx +127 -0
- package/frontend/src/index.css +248 -0
- package/frontend/src/lib/api/client.ts +163 -0
- package/frontend/src/lib/contexts/AuthContext.tsx +157 -0
- package/frontend/src/lib/contexts/OnboardStepContext.tsx +68 -0
- package/frontend/src/lib/contexts/SocketContext.tsx +303 -0
- package/frontend/src/lib/contexts/ThemeContext.tsx +125 -0
- package/frontend/src/lib/hooks/useAuth.ts +4 -0
- package/frontend/src/lib/hooks/useConfirm.ts +55 -0
- package/frontend/src/lib/hooks/useInterval.ts +27 -0
- package/frontend/src/lib/hooks/useMediaQuery.ts +59 -0
- package/frontend/src/lib/hooks/useOnboardingCompletion.ts +29 -0
- package/frontend/src/lib/hooks/usePagination.ts +27 -0
- package/frontend/src/lib/hooks/useTimeout.ts +27 -0
- package/frontend/src/lib/hooks/useToast.tsx +229 -0
- package/frontend/src/lib/utils/constants.ts +38 -0
- package/frontend/src/lib/utils/utils.ts +165 -0
- package/frontend/src/lib/utils/validation-schemas.ts +126 -0
- package/frontend/src/main.tsx +16 -0
- package/frontend/src/rdg.css +194 -0
- package/frontend/src/vite-env.d.ts +12 -0
- package/frontend/tailwind.config.js +97 -0
- package/frontend/tsconfig.json +26 -0
- package/frontend/tsconfig.node.json +10 -0
- package/frontend/vite.config.ts +37 -0
- package/frontend/vitest.config.ts +36 -0
- package/functions/deno.json +25 -0
- package/functions/server.ts +290 -0
- package/functions/worker-template.js +126 -0
- package/openapi/ai.yaml +689 -0
- package/openapi/auth.yaml +563 -0
- package/openapi/functions.yaml +476 -0
- package/openapi/health.yaml +30 -0
- package/openapi/logs.yaml +224 -0
- package/openapi/metadata.yaml +178 -0
- package/openapi/records.yaml +382 -0
- package/openapi/secrets.yaml +371 -0
- package/openapi/storage.yaml +876 -0
- package/openapi/tables.yaml +464 -0
- package/package.json +88 -0
- package/shared-schemas/package.json +31 -0
- package/shared-schemas/src/ai-api.schema.ts +167 -0
- package/shared-schemas/src/ai.schema.ts +54 -0
- package/shared-schemas/src/auth-api.schema.ts +193 -0
- package/shared-schemas/src/auth.schema.ts +94 -0
- package/shared-schemas/src/database-api.schema.ts +259 -0
- package/shared-schemas/src/database.schema.ts +69 -0
- package/shared-schemas/src/functions-api.schema.ts +25 -0
- package/shared-schemas/src/functions.schema.ts +16 -0
- package/shared-schemas/src/index.ts +13 -0
- package/shared-schemas/src/logs-api.schema.ts +49 -0
- package/shared-schemas/src/logs.schema.ts +14 -0
- package/shared-schemas/src/metadata.schema.ts +56 -0
- package/shared-schemas/src/storage-api.schema.ts +65 -0
- package/shared-schemas/src/storage.schema.ts +19 -0
- package/shared-schemas/tsconfig.json +21 -0
- package/tsconfig.json +8 -0
package/.dockerignore
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
frontend/node_modules/
|
|
4
|
+
|
|
5
|
+
# Build outputs
|
|
6
|
+
dist/
|
|
7
|
+
frontend/dist/
|
|
8
|
+
*.tsbuildinfo
|
|
9
|
+
|
|
10
|
+
# Data and logs
|
|
11
|
+
data/
|
|
12
|
+
*.log
|
|
13
|
+
npm-debug.log*
|
|
14
|
+
|
|
15
|
+
# Environment files
|
|
16
|
+
.env
|
|
17
|
+
.env.local
|
|
18
|
+
.env.*.local
|
|
19
|
+
|
|
20
|
+
# Development files
|
|
21
|
+
.git/
|
|
22
|
+
.gitignore
|
|
23
|
+
*.md
|
|
24
|
+
!docs/** # Include all files in docs folder
|
|
25
|
+
tests/
|
|
26
|
+
*.test.ts
|
|
27
|
+
*.test.tsx
|
|
28
|
+
coverage/
|
|
29
|
+
.nyc_output/
|
|
30
|
+
|
|
31
|
+
# IDE
|
|
32
|
+
.vscode/
|
|
33
|
+
.idea/
|
|
34
|
+
*.swp
|
|
35
|
+
*.swo
|
|
36
|
+
.DS_Store
|
|
37
|
+
|
|
38
|
+
# Docker files (prevent recursion)
|
|
39
|
+
Dockerfile
|
|
40
|
+
docker-compose*.yml
|
|
41
|
+
.dockerignore
|
|
42
|
+
|
|
43
|
+
# Development configs
|
|
44
|
+
vitest.config.ts
|
|
45
|
+
# tsconfig.json files are needed for build - DO NOT IGNORE
|
|
46
|
+
# frontend/tsconfig.json is needed for @ alias resolution - DO NOT IGNORE
|
|
47
|
+
# frontend/vite.config.ts is needed for build - DO NOT IGNORE
|
|
48
|
+
.eslintrc.json
|
|
49
|
+
frontend/.eslintrc.cjs
|
|
50
|
+
|
|
51
|
+
# CI/CD
|
|
52
|
+
.github/
|
|
53
|
+
.gitlab-ci.yml
|
|
54
|
+
|
|
55
|
+
# Temporary files
|
|
56
|
+
tmp/
|
|
57
|
+
temp/
|
|
58
|
+
*.tmp
|
package/.env.example
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Server Configuration
|
|
2
|
+
PORT=7130
|
|
3
|
+
|
|
4
|
+
# PostgreSQL Configuration (optional - defaults shown)
|
|
5
|
+
POSTGRES_USER=postgres
|
|
6
|
+
POSTGRES_PASSWORD=postgres
|
|
7
|
+
POSTGRES_DB=insforge
|
|
8
|
+
|
|
9
|
+
API_BASE_URL=http://localhost:7130
|
|
10
|
+
VITE_API_BASE_URL=http://localhost:7130
|
|
11
|
+
|
|
12
|
+
# Authentication
|
|
13
|
+
JWT_SECRET=your-secret-key-here-must-be-32-char-or-above
|
|
14
|
+
ADMIN_EMAIL=admin@example.com
|
|
15
|
+
ADMIN_PASSWORD=change-this-password
|
|
16
|
+
|
|
17
|
+
# Encryption key for secret manager (will use JWT_SECRET if not provided)
|
|
18
|
+
ENCRYPTION_KEY=
|
|
19
|
+
|
|
20
|
+
# API Key (must start with ik_ )
|
|
21
|
+
# optional - will be auto-generated if not provided)
|
|
22
|
+
ACCESS_API_KEY=ik_your-api-key-here-32-chars-minimum
|
|
23
|
+
|
|
24
|
+
# Cloud API Host (Optional)
|
|
25
|
+
CLOUD_API_HOST=https://api.insforge.dev
|
|
26
|
+
|
|
27
|
+
# Storage Configuration
|
|
28
|
+
# For S3 storage (optional - if not set, will use local filesystem)
|
|
29
|
+
AWS_S3_BUCKET=
|
|
30
|
+
AWS_REGION=us-east-2
|
|
31
|
+
|
|
32
|
+
# OpenRouter Configuration
|
|
33
|
+
# Get your API key from https://openrouter.ai/keys
|
|
34
|
+
OPENROUTER_API_KEY=
|
|
35
|
+
|
|
36
|
+
# OAuth Configuration (Optional)
|
|
37
|
+
# Google OAuth - Get credentials from https://console.cloud.google.com/
|
|
38
|
+
GOOGLE_CLIENT_ID=
|
|
39
|
+
GOOGLE_CLIENT_SECRET=
|
|
40
|
+
|
|
41
|
+
# GitHub OAuth - Get credentials from https://github.com/settings/developers
|
|
42
|
+
GITHUB_CLIENT_ID=
|
|
43
|
+
GITHUB_CLIENT_SECRET=
|
|
44
|
+
|
|
45
|
+
# Multi-tenant Cloud Configuration
|
|
46
|
+
# Below only used through cloud available solution
|
|
47
|
+
DEPLOYMENT_ID=
|
|
48
|
+
PROJECT_ID=
|
|
49
|
+
APP_KEY=
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: 🐛 Bug Report
|
|
2
|
+
description: Create a bug report to help us improve
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: ["bug", "needs-triage"]
|
|
5
|
+
assignees: []
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Thanks for taking the time to fill out this bug report! Please provide as much detail as possible.
|
|
11
|
+
|
|
12
|
+
**Note**: This template is for bug reports only. For feature requests, questions, or other issues, please use the appropriate template.
|
|
13
|
+
|
|
14
|
+
- type: checkboxes
|
|
15
|
+
id: checks
|
|
16
|
+
attributes:
|
|
17
|
+
label: Pre-submission Checklist
|
|
18
|
+
description: Please complete these checks before submitting
|
|
19
|
+
options:
|
|
20
|
+
- label: I have searched existing issues and confirmed this is not a duplicate
|
|
21
|
+
required: true
|
|
22
|
+
- label: I have read the contributing guidelines
|
|
23
|
+
required: true
|
|
24
|
+
- label: This is a legitimate bug report and not spam or promotional content
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
- type: textarea
|
|
28
|
+
id: what-happened
|
|
29
|
+
attributes:
|
|
30
|
+
label: What happened?
|
|
31
|
+
description: Describe the bug clearly and concisely
|
|
32
|
+
placeholder: A clear description of what the bug is
|
|
33
|
+
validations:
|
|
34
|
+
required: true
|
|
35
|
+
|
|
36
|
+
- type: textarea
|
|
37
|
+
id: expected-behavior
|
|
38
|
+
attributes:
|
|
39
|
+
label: Expected Behavior
|
|
40
|
+
description: What did you expect to happen?
|
|
41
|
+
placeholder: A clear description of what you expected to happen
|
|
42
|
+
validations:
|
|
43
|
+
required: true
|
|
44
|
+
|
|
45
|
+
- type: textarea
|
|
46
|
+
id: steps-reproduce
|
|
47
|
+
attributes:
|
|
48
|
+
label: Steps to Reproduce
|
|
49
|
+
description: Please provide detailed steps to reproduce the issue
|
|
50
|
+
placeholder: |
|
|
51
|
+
1. Go to '...'
|
|
52
|
+
2. Click on '...'
|
|
53
|
+
3. Scroll down to '...'
|
|
54
|
+
4. See error
|
|
55
|
+
validations:
|
|
56
|
+
required: true
|
|
57
|
+
|
|
58
|
+
- type: textarea
|
|
59
|
+
id: environment
|
|
60
|
+
attributes:
|
|
61
|
+
label: Environment
|
|
62
|
+
description: Please provide information about your environment
|
|
63
|
+
placeholder: |
|
|
64
|
+
- OS: [e.g. Windows 10, macOS 12.0, Ubuntu 20.04]
|
|
65
|
+
- Browser: [e.g. Chrome 96, Firefox 95, Safari 15]
|
|
66
|
+
- Version: [e.g. v1.2.3]
|
|
67
|
+
- Node.js: [e.g. 16.13.0]
|
|
68
|
+
validations:
|
|
69
|
+
required: true
|
|
70
|
+
|
|
71
|
+
- type: textarea
|
|
72
|
+
id: screenshots
|
|
73
|
+
attributes:
|
|
74
|
+
label: Screenshots/Logs
|
|
75
|
+
description: If applicable, add screenshots or error logs to help explain your problem
|
|
76
|
+
placeholder: Paste screenshots or logs here
|
|
77
|
+
|
|
78
|
+
- type: textarea
|
|
79
|
+
id: additional-context
|
|
80
|
+
attributes:
|
|
81
|
+
label: Additional Context
|
|
82
|
+
description: Add any other context about the problem here
|
|
83
|
+
placeholder: Any additional information that might be helpful
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: 📚 Documentation
|
|
4
|
+
url: https://docs.insforge.dev
|
|
5
|
+
about: Check our documentation for common questions and setup guides
|
|
6
|
+
- name: 💬 Discussions
|
|
7
|
+
url: https://discord.gg/DvBtaEc9Jz
|
|
8
|
+
about: Ask questions and discuss ideas with the community
|
|
9
|
+
- name: 🆘 Support
|
|
10
|
+
url: https://discord.gg/DvBtaEc9Jz
|
|
11
|
+
about: Get help with installation, configuration, and usage
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
name: ✨ Feature Request
|
|
2
|
+
description: Suggest an idea or enhancement for this project
|
|
3
|
+
title: "[Feature]: "
|
|
4
|
+
labels: ["enhancement", "needs-triage"]
|
|
5
|
+
assignees: []
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Thank you for suggesting a new feature! Please provide as much detail as possible.
|
|
11
|
+
|
|
12
|
+
**Note**: This template is for feature requests only. For bug reports, please use the Bug Report template.
|
|
13
|
+
|
|
14
|
+
- type: checkboxes
|
|
15
|
+
id: checks
|
|
16
|
+
attributes:
|
|
17
|
+
label: Pre-submission Checklist
|
|
18
|
+
description: Please complete these checks before submitting
|
|
19
|
+
options:
|
|
20
|
+
- label: I have searched existing issues and confirmed this feature hasn't been requested
|
|
21
|
+
required: true
|
|
22
|
+
- label: I have read the contributing guidelines
|
|
23
|
+
required: true
|
|
24
|
+
- label: This is a legitimate feature request and not spam or promotional content
|
|
25
|
+
required: true
|
|
26
|
+
|
|
27
|
+
- type: textarea
|
|
28
|
+
id: problem-description
|
|
29
|
+
attributes:
|
|
30
|
+
label: Problem Description
|
|
31
|
+
description: Is your feature request related to a problem? Please describe.
|
|
32
|
+
placeholder: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
33
|
+
validations:
|
|
34
|
+
required: true
|
|
35
|
+
|
|
36
|
+
- type: textarea
|
|
37
|
+
id: proposed-solution
|
|
38
|
+
attributes:
|
|
39
|
+
label: Proposed Solution
|
|
40
|
+
description: Describe the solution you'd like
|
|
41
|
+
placeholder: A clear and concise description of what you want to happen
|
|
42
|
+
validations:
|
|
43
|
+
required: true
|
|
44
|
+
|
|
45
|
+
- type: textarea
|
|
46
|
+
id: alternatives
|
|
47
|
+
attributes:
|
|
48
|
+
label: Alternatives Considered
|
|
49
|
+
description: Describe alternatives you've considered
|
|
50
|
+
placeholder: A clear and concise description of any alternative solutions or features you've considered
|
|
51
|
+
|
|
52
|
+
- type: dropdown
|
|
53
|
+
id: priority
|
|
54
|
+
attributes:
|
|
55
|
+
label: Priority
|
|
56
|
+
description: How important is this feature to you?
|
|
57
|
+
options:
|
|
58
|
+
- Low - Nice to have
|
|
59
|
+
- Medium - Would be helpful
|
|
60
|
+
- High - Important for my use case
|
|
61
|
+
- Critical - Blocking my usage
|
|
62
|
+
validations:
|
|
63
|
+
required: true
|
|
64
|
+
|
|
65
|
+
- type: textarea
|
|
66
|
+
id: use-cases
|
|
67
|
+
attributes:
|
|
68
|
+
label: Use Cases
|
|
69
|
+
description: Describe specific use cases for this feature
|
|
70
|
+
placeholder: |
|
|
71
|
+
1. As a [user type], I want [goal] so that [benefit]
|
|
72
|
+
2. When [situation], I need [functionality] because [reason]
|
|
73
|
+
|
|
74
|
+
- type: textarea
|
|
75
|
+
id: additional-context
|
|
76
|
+
attributes:
|
|
77
|
+
label: Additional Context
|
|
78
|
+
description: Add any other context, mockups, or examples about the feature request here
|
|
79
|
+
placeholder: Any additional information, screenshots, mockups, or examples that would help
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Project Overview
|
|
2
|
+
|
|
3
|
+
InsForge is an open-source Backend-as-a-Service (BaaS) platform designed specifically for AI agents. It provides a comprehensive solution for managing backend services including authentication, database operations, storage, and serverless functions, all accessible through REST APIs with PostgreSQL as the primary database.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
This is a monorepo containing:
|
|
8
|
+
- **Backend**: Node.js with Express.js, providing RESTful APIs
|
|
9
|
+
- **Frontend**: React with Vite, offering an admin dashboard
|
|
10
|
+
- **Functions**: Serverless function runtime using Deno
|
|
11
|
+
- **Shared-schemas**: Common TypeScript schemas shared across modules
|
|
12
|
+
|
|
13
|
+
## Folder Structure
|
|
14
|
+
|
|
15
|
+
- `/backend`: Node.js backend server
|
|
16
|
+
- `/src/api`: API routes and middleware
|
|
17
|
+
- `/src/controllers`: Business logic controllers
|
|
18
|
+
- `/src/core`: Core services (auth, database, storage, metadata)
|
|
19
|
+
- `/src/types`: TypeScript type definitions
|
|
20
|
+
- `/src/utils`: Utility functions and helpers
|
|
21
|
+
- `/frontend`: React dashboard application
|
|
22
|
+
- `/src/components`: Reusable UI components
|
|
23
|
+
- `/src/features`: Feature-specific modules (auth, database, storage, logs)
|
|
24
|
+
- `/src/lib`: Shared libraries, hooks, and utilities
|
|
25
|
+
- `/functions`: Serverless function runtime
|
|
26
|
+
- `/shared-schemas`: Shared TypeScript schemas
|
|
27
|
+
- `/docker-init`: Docker initialization scripts
|
|
28
|
+
- `/openapi`: API documentation in OpenAPI format
|
|
29
|
+
- `/tests`: Comprehensive test suites
|
|
30
|
+
|
|
31
|
+
## Libraries and Frameworks
|
|
32
|
+
|
|
33
|
+
### Backend
|
|
34
|
+
- Express.js for REST API framework
|
|
35
|
+
- PostgreSQL with pg driver for database
|
|
36
|
+
- Better-auth for authentication
|
|
37
|
+
- AWS SDK for S3-compatible storage
|
|
38
|
+
- Zod for schema validation
|
|
39
|
+
- JWT for token management
|
|
40
|
+
- TypeScript for type safety
|
|
41
|
+
|
|
42
|
+
### Frontend
|
|
43
|
+
- React 19 with functional components
|
|
44
|
+
- Vite for build tooling
|
|
45
|
+
- TanStack Query for data fetching
|
|
46
|
+
- React Hook Form with Zod validation
|
|
47
|
+
- Tailwind CSS for styling
|
|
48
|
+
- Radix UI for accessible component primitives
|
|
49
|
+
- React Router for navigation
|
|
50
|
+
- TypeScript for type safety
|
|
51
|
+
|
|
52
|
+
## Coding Standards
|
|
53
|
+
|
|
54
|
+
### General
|
|
55
|
+
- Use TypeScript for all code files
|
|
56
|
+
- Prefer descriptive, unabbreviated variable and function names
|
|
57
|
+
- Follow consistent file naming: kebab-case for files, PascalCase for components
|
|
58
|
+
- Maintain clear folder structure with feature-based organization
|
|
59
|
+
- Use ES modules (import/export syntax)
|
|
60
|
+
- Implement proper error handling with try-catch blocks
|
|
61
|
+
- Add appropriate logging for debugging
|
|
62
|
+
|
|
63
|
+
### Backend Specific
|
|
64
|
+
- Use async/await for asynchronous operations
|
|
65
|
+
- Implement proper middleware for authentication and error handling
|
|
66
|
+
- Follow RESTful conventions for API endpoints
|
|
67
|
+
- Use Zod schemas for request/response validation
|
|
68
|
+
- Return consistent API responses using utility functions
|
|
69
|
+
- Implement proper database transaction handling
|
|
70
|
+
|
|
71
|
+
### Frontend Specific
|
|
72
|
+
- Use functional components with hooks exclusively
|
|
73
|
+
- Implement proper TypeScript interfaces for all props
|
|
74
|
+
- Use React Hook Form for form handling
|
|
75
|
+
- Follow component composition patterns
|
|
76
|
+
- Implement proper loading and error states
|
|
77
|
+
- Use TanStack Query for server state management
|
|
78
|
+
- Keep components focused and single-purpose
|
|
79
|
+
|
|
80
|
+
#### Naming Conventions
|
|
81
|
+
- **Variables, parameters, properties, and functions**: Use camelCase
|
|
82
|
+
- Examples: `userName`, `getUserData()`, `isLoading`
|
|
83
|
+
- **React components and TypeScript types/interfaces**: Use PascalCase
|
|
84
|
+
- Examples: `UserProfileDialog`, `interface User`, `type TableSchema`
|
|
85
|
+
- **Constants and Enum members**: Use UPPER_CASE
|
|
86
|
+
- Examples: `const API_BASE_URL`, `enum Status { ACTIVE, INACTIVE }`
|
|
87
|
+
- **File naming**:
|
|
88
|
+
- Components: `PascalCase.tsx` (e.g., `DataGrid.tsx`)
|
|
89
|
+
- Hooks: `use` + `PascalCase.ts` (e.g., `useAuth.ts`)
|
|
90
|
+
- Services: `camelCase.service.ts` (e.g., `auth.service.ts`)
|
|
91
|
+
- Utils: `kebab-case.ts` or `camelCase.ts` (e.g., `database-utils.ts`)
|
|
92
|
+
- **No snake_case**: Avoid snake_case except in SQL queries and external APIs
|
|
93
|
+
|
|
94
|
+
### Code Style
|
|
95
|
+
- Use single quotes for strings
|
|
96
|
+
- Include semicolons at the end of statements
|
|
97
|
+
- Use arrow functions for callbacks and inline functions
|
|
98
|
+
- Prefer const over let, avoid var
|
|
99
|
+
- Use template literals for string interpolation
|
|
100
|
+
- Maintain consistent indentation (2 spaces)
|
|
101
|
+
- Format code with Prettier configuration
|
|
102
|
+
|
|
103
|
+
## UI Guidelines
|
|
104
|
+
|
|
105
|
+
- Follow a clean, modern design with consistent spacing
|
|
106
|
+
- Use Radix UI primitives for accessibility
|
|
107
|
+
- Maintain consistent color scheme using CSS variables
|
|
108
|
+
- Use appropriate loading skeletons for data fetching
|
|
109
|
+
- Display clear error messages with actionable feedback
|
|
110
|
+
- Implement proper form validation with inline errors
|
|
111
|
+
- Use consistent icon set from lucide-react
|
|
112
|
+
|
|
113
|
+
## Testing Standards
|
|
114
|
+
|
|
115
|
+
- Implement integration tests for API endpoints
|
|
116
|
+
- Maintain test coverage above 70%
|
|
117
|
+
- Mock external dependencies appropriately
|
|
118
|
+
|
|
119
|
+
## Security Considerations
|
|
120
|
+
|
|
121
|
+
- Never commit secrets or API keys
|
|
122
|
+
- Use environment variables for configuration
|
|
123
|
+
- Implement proper authentication and authorization
|
|
124
|
+
- Validate all user inputs
|
|
125
|
+
- Sanitize data before database operations
|
|
126
|
+
- Use prepared statements for SQL queries
|
|
127
|
+
- Implement rate limiting for API endpoints
|
|
128
|
+
- Follow OWASP security best practices
|
|
129
|
+
|
|
130
|
+
## Performance Guidelines
|
|
131
|
+
|
|
132
|
+
- Implement proper database indexing
|
|
133
|
+
- Use pagination for large data sets
|
|
134
|
+
- Optimize React component re-renders
|
|
135
|
+
- Implement proper caching strategies
|
|
136
|
+
- Use lazy loading for code splitting
|
|
137
|
+
- Optimize bundle size with proper imports
|
|
138
|
+
- Monitor and log performance metrics
|
|
139
|
+
|
|
140
|
+
## Documentation
|
|
141
|
+
|
|
142
|
+
- Document all API endpoints with clear descriptions
|
|
143
|
+
- Include JSDoc comments for complex functions
|
|
144
|
+
- Maintain up-to-date README files
|
|
145
|
+
- Document environment variables and configuration
|
|
146
|
+
- Provide clear setup instructions
|
|
147
|
+
- Include examples for common use cases
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Build and Push Docker Image on github container registry
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
test_tag:
|
|
10
|
+
description: 'Test tag name (e.g., v0.1.1-test)'
|
|
11
|
+
required: false
|
|
12
|
+
default: 'v0.1.1-test'
|
|
13
|
+
|
|
14
|
+
env:
|
|
15
|
+
REGISTRY: ghcr.io
|
|
16
|
+
IMAGE_NAME: ${{ github.repository_owner }}/insforge-oss
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build-and-push:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
packages: write
|
|
24
|
+
id-token: write
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- name: Checkout repository
|
|
28
|
+
uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Set up QEMU
|
|
31
|
+
uses: docker/setup-qemu-action@v3
|
|
32
|
+
|
|
33
|
+
- name: Set up Docker Buildx
|
|
34
|
+
uses: docker/setup-buildx-action@v3
|
|
35
|
+
|
|
36
|
+
- name: Log in to GitHub Container Registry
|
|
37
|
+
uses: docker/login-action@v3
|
|
38
|
+
with:
|
|
39
|
+
registry: ${{ env.REGISTRY }}
|
|
40
|
+
username: ${{ github.actor }}
|
|
41
|
+
password: ${{ secrets.GHCR_PAT }}
|
|
42
|
+
|
|
43
|
+
- name: Extract metadata
|
|
44
|
+
id: meta
|
|
45
|
+
uses: docker/metadata-action@v5
|
|
46
|
+
with:
|
|
47
|
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
48
|
+
tags: |
|
|
49
|
+
type=ref,event=tag
|
|
50
|
+
type=raw,value=${{ github.event.inputs.test_tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
|
51
|
+
|
|
52
|
+
- name: Build and push Docker image
|
|
53
|
+
uses: docker/build-push-action@v5
|
|
54
|
+
with:
|
|
55
|
+
context: .
|
|
56
|
+
platforms: linux/amd64,linux/arm64
|
|
57
|
+
push: true
|
|
58
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
59
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
60
|
+
cache-from: type=gha
|
|
61
|
+
cache-to: type=gha,mode=max
|
|
62
|
+
build-args: |
|
|
63
|
+
VERSION=${{ github.ref_name }}
|
|
64
|
+
BUILD_DATE=${{ github.event.head_commit.timestamp }}
|
|
65
|
+
COMMIT_SHA=${{ github.sha }}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI Pre-merge Check
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ main, master, develop ]
|
|
6
|
+
push:
|
|
7
|
+
branches: [ main, master, develop ]
|
|
8
|
+
workflow_dispatch: # Allows manual triggering for testing
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
docker-build:
|
|
12
|
+
name: CI Pre-merge Check
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Build Docker image
|
|
20
|
+
uses: docker/build-push-action@v5
|
|
21
|
+
with:
|
|
22
|
+
context: .
|
|
23
|
+
push: false
|
|
24
|
+
tags: insforge:test
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
name: Deploy to AWS EC2
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
deploy:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout code
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Deploy to EC2
|
|
17
|
+
uses: appleboy/ssh-action@v1.0.0
|
|
18
|
+
with:
|
|
19
|
+
host: ${{ secrets.EC2_HOST }}
|
|
20
|
+
username: ec2-user
|
|
21
|
+
key: ${{ secrets.EC2_SSH_KEY }}
|
|
22
|
+
port: 22
|
|
23
|
+
script: |
|
|
24
|
+
# Install required dependencies if not present
|
|
25
|
+
if ! command -v git &> /dev/null; then
|
|
26
|
+
echo "Installing git..."
|
|
27
|
+
sudo yum update -y
|
|
28
|
+
sudo yum install -y git
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
if ! command -v docker &> /dev/null; then
|
|
32
|
+
echo "Installing Docker..."
|
|
33
|
+
sudo yum update -y
|
|
34
|
+
sudo yum install -y docker
|
|
35
|
+
sudo systemctl start docker
|
|
36
|
+
sudo systemctl enable docker
|
|
37
|
+
sudo usermod -aG docker ec2-user
|
|
38
|
+
|
|
39
|
+
# Install docker-compose plugin
|
|
40
|
+
sudo mkdir -p /usr/local/lib/docker/cli-plugins
|
|
41
|
+
sudo curl -SL https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
|
|
42
|
+
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
|
|
43
|
+
|
|
44
|
+
# Also install standalone docker-compose for compatibility
|
|
45
|
+
sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
46
|
+
sudo chmod +x /usr/local/bin/docker-compose
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Navigate to application directory
|
|
50
|
+
mkdir -p ~/insforge
|
|
51
|
+
cd ~/insforge
|
|
52
|
+
|
|
53
|
+
# Pull latest code or fresh clone
|
|
54
|
+
if [ -d ".git" ]; then
|
|
55
|
+
# Clean up old branches and reset to latest
|
|
56
|
+
git remote prune origin
|
|
57
|
+
git fetch --all --prune
|
|
58
|
+
# Use the branch that triggered the workflow
|
|
59
|
+
git checkout ${{ github.ref_name }} || git checkout main || git checkout master
|
|
60
|
+
git reset --hard origin/${{ github.ref_name }} || git reset --hard origin/main || git reset --hard origin/master
|
|
61
|
+
else
|
|
62
|
+
# Remove existing non-git directory if it exists
|
|
63
|
+
if [ -d ~/insforge ] && [ ! -d ~/insforge/.git ]; then
|
|
64
|
+
rm -rf ~/insforge/*
|
|
65
|
+
rm -rf ~/insforge/.*
|
|
66
|
+
fi
|
|
67
|
+
# Clone using SSH (since we set up SSH key)
|
|
68
|
+
git clone git@github.com:InsForge/insforge.git ~/insforge
|
|
69
|
+
cd ~/insforge
|
|
70
|
+
# Stay on default branch instead of detached HEAD
|
|
71
|
+
# git checkout ${{ github.sha }} # Commented out to avoid detached HEAD
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Create .env file matching .env.example structure
|
|
75
|
+
cat > .env << EOF
|
|
76
|
+
# Server Configuration
|
|
77
|
+
PORT=7130
|
|
78
|
+
|
|
79
|
+
# PostgreSQL Configuration
|
|
80
|
+
POSTGRES_USER=postgres
|
|
81
|
+
POSTGRES_PASSWORD=postgres
|
|
82
|
+
POSTGRES_DB=insforge
|
|
83
|
+
|
|
84
|
+
API_BASE_URL=http://localhost:7130
|
|
85
|
+
VITE_API_BASE_URL=http://localhost:7130
|
|
86
|
+
|
|
87
|
+
# Authentication
|
|
88
|
+
JWT_SECRET=your-secret-jwt-key-must-be-32-characters-minimum
|
|
89
|
+
ADMIN_EMAIL=admin@example.com
|
|
90
|
+
ADMIN_PASSWORD=change-this-password
|
|
91
|
+
|
|
92
|
+
# Logflare
|
|
93
|
+
LOGFLARE_PUBLIC_ACCESS_TOKEN=your-super-secret-and-long-logflare-key-public
|
|
94
|
+
LOGFLARE_PRIVATE_ACCESS_TOKEN=your-super-secret-and-long-logflare-key-private
|
|
95
|
+
|
|
96
|
+
# Docker
|
|
97
|
+
DOCKER_SOCKET_LOCATION=/var/run/docker.sock
|
|
98
|
+
|
|
99
|
+
EOF
|
|
100
|
+
|
|
101
|
+
# Ensure we're in the right directory with docker-compose.yml
|
|
102
|
+
cd ~/insforge
|
|
103
|
+
|
|
104
|
+
# Stop ALL containers regardless of which compose file started them
|
|
105
|
+
# This ensures clean slate even if previous deploy used different compose file
|
|
106
|
+
sudo docker stop $(sudo docker ps -aq) || true
|
|
107
|
+
sudo docker rm $(sudo docker ps -aq) || true
|
|
108
|
+
|
|
109
|
+
# Also try to stop using both compose files (in case either was used)
|
|
110
|
+
# IMPORTANT: Specify -f for dev file too, to avoid default file selection
|
|
111
|
+
sudo /usr/local/bin/docker-compose -f docker-compose.yml down -v || true
|
|
112
|
+
sudo /usr/local/bin/docker-compose -f docker-compose.prod.yml down -v || true
|
|
113
|
+
|
|
114
|
+
# Clean up any orphaned volumes and networks
|
|
115
|
+
sudo docker volume prune -f || true
|
|
116
|
+
sudo docker network prune -f || true
|
|
117
|
+
|
|
118
|
+
# Build fresh image with no cache and latest base images
|
|
119
|
+
sudo /usr/local/bin/docker-compose -f docker-compose.prod.yml build --no-cache --pull
|
|
120
|
+
|
|
121
|
+
# Now start fresh with production compose
|
|
122
|
+
sudo /usr/local/bin/docker-compose -f docker-compose.prod.yml up -d
|
|
123
|
+
|
|
124
|
+
# Clean up old images
|
|
125
|
+
sudo docker image prune -af
|
|
126
|
+
|
|
127
|
+
# Check deployment status
|
|
128
|
+
sleep 10
|
|
129
|
+
sudo /usr/local/bin/docker-compose -f docker-compose.prod.yml ps
|
|
130
|
+
sudo /usr/local/bin/docker-compose -f docker-compose.prod.yml logs --tail=50
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Lint and Format Check
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ '*' ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint-and-format:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout repository
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup Node.js
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: '20'
|
|
21
|
+
cache: 'npm'
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: npm ci
|
|
25
|
+
|
|
26
|
+
- name: Run ESLint
|
|
27
|
+
run: npm run lint
|
|
28
|
+
|
|
29
|
+
- name: Check Prettier formatting
|
|
30
|
+
run: npx prettier --check .
|
|
31
|
+
|
|
32
|
+
- name: Run TypeScript type checking
|
|
33
|
+
run: npm run typecheck
|