ai-compliance-platform

AI Compliance Intelligence Platform

An AI-powered compliance monitoring system for SaaS companies. Built with Next.js 14, TypeScript, TailwindCSS, shadcn/ui, Framer Motion, and Recharts.

Features

Tech Stack

How to Run

Prerequisites

Installation

  1. Navigate to the project directory:
    cd ai-compliance-platform
    
  2. Install dependencies:
    npm install
    
  3. Run the development server:
    npm run dev
    
  4. Open in browser: http://localhost:3000

Build for Production

Stop the dev server (Ctrl+C) before building.

npm run build
npm start

Verify (No Errors)

npm run test    # Lint + TypeScript check

Project Structure

src/
├── app/
│   ├── (app)/              # Protected app routes (auth required)
│   │   ├── layout.tsx      # Auth guard, AppLayout, page transitions
│   │   ├── dashboard/
│   │   ├── upload/
│   │   ├── rules/
│   │   ├── policy-impact/
│   │   ├── violations/
│   │   ├── review/
│   │   └── reports/
│   ├── login/              # Login page
│   ├── page.tsx            # Landing page
│   ├── layout.tsx          # Root layout (Providers only)
│   └── globals.css
├── components/
│   ├── dashboard/
│   ├── layout/
│   │   ├── header.tsx      # Search, theme toggle, notifications, user dropdown (logout)
│   │   ├── sidebar.tsx    # Role-based nav
│   │   ├── notification-dropdown.tsx
│   │   ├── page-transition.tsx
│   │   ├── providers.tsx  # Auth, Theme, Toast
│   │   └── ...
│   └── ui/
├── contexts/
│   ├── auth-context.tsx    # User, login(), logout(), role helpers
│   ├── theme-context.tsx   # Dark/light, localStorage
│   └── toast-context.tsx  # Toast on logout
├── data/
└── lib/

Architecture (Performance & Layout)

Design

Connecting Backend & Database

1. Run the backend

From the project root:

cd backend
pip install -r requirements.txt
# Ensure .env exists (copy from .env.example) with DATABASE_URL and OPENAI_API_KEY
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Backend will be at http://localhost:8000 (API docs: http://localhost:8000/docs).

2. Connect the frontend to the backend

In the project root (not inside backend/), create or edit .env.local:

NEXT_PUBLIC_API_URL=http://localhost:8000

Then start the frontend (from project root):

npm run dev

Open http://localhost:3000. The dashboard will load real data from the backend (policies, violations, scan status). CORS is enabled on the backend for http://localhost:3000 and http://127.0.0.1:3000.

3. Connect an external database (for compliance scans)

The backend needs to connect to your database (the one you want to run compliance rules against). Use the API or Swagger:

  1. Open http://localhost:8000/docs.
  2. Find POST /database/connect.
  3. Send a JSON body with your DB credentials, for example:
{
  "host": "localhost",
  "username": "your_db_user",
  "password": "your_db_password",
  "db_name": "your_database_name"
}

After a successful connect, you can upload policies (POST /policy/upload) and run scans (POST /scan/run). The scan runs the extracted rules against the connected external database and stores violations.

Summary

Step What Where
Backend uvicorn app.main:app --reload --port 8000 backend/
Frontend env NEXT_PUBLIC_API_URL=http://localhost:8000 .env.local in project root
Frontend npm run dev project root
External DB POST /database/connect with host, username, password, db_name API or Swagger UI

Mock Data