/home/techb158/balavpn.abdallabala.com
Edit: /home/techb158/balavpn.abdallabala.com/README.md (2150B)
# COSMIC AI-Risk SaaS
This folder is the commercial SaaS rebuild of the frozen academic prototype in the parent directory.
The prototype remains the source reference for COSMIC risk logic and documentation. This app introduces production SaaS boundaries: multi-tenancy, PostgreSQL, Prisma, invite-only onboarding, subscriptions, entitlements, tenant-scoped APIs, Docker deployment, and enterprise extension points.
## Local Setup
```bash
cp .env.example .env
docker compose up -d postgres
npm install
npm run db:push
npm run db:seed
npm run dev
```
Open:
```text
http://localhost:8090
```
## Architecture
- `app/` contains Next.js pages and API route handlers.
- `src/domain/` contains dependency-free COSMIC rules that are unit tested.
- `src/services/` contains tenant-aware application services.
- `src/lib/` contains infrastructure helpers such as Prisma, request context, and tenant guards.
- `prisma/schema.prisma` defines the SaaS PostgreSQL model.
- `prisma/seed.js` imports the frozen prototype sample data into a demo organization and workspace.
## Current Implementation Stage
This is the Phase 1 and Phase 2 foundation:
- Organization and workspace tenancy.
- Role and membership model.
- Invite-only auth contracts.
- Project/risk/mitigation/gate/report schemas.
- Manual billing and Stripe-ready subscription tables.
- COSMIC scoring, dashboard aggregation, gate logic, permission checks, and entitlement rules.
- Tenant-scoped API routes for the public interfaces in the SaaS plan.
- Docker Compose for VPS deployment.
Stripe checkout, SAML/OIDC, and live PM sync are wired as explicit boundaries and database models, but should be completed with real provider credentials before production launch.
## Local fallback mode
If npm registry access is slow or blocked, use the dependency-free local fallback harness:
```bash
npm run test:local
npm run local:fallback
```
Open:
```text
http://localhost:8090
```
This mode uses the SaaS domain modules and imports the frozen prototype seed data into memory. It is for local workflow testing only; the full SaaS app still requires `npm install`, PostgreSQL, and Prisma.