An AI-powered compliance monitoring system for SaaS companies. Built with Next.js 14, TypeScript, TailwindCSS, shadcn/ui, Framer Motion, and Recharts.
cd ai-compliance-platform
npm install
npm run dev
/ — hero, features, how it works, footer. Use “Access Demo” or “Sign in” to go to login./login — any email/password works (demo). Choose role: Admin, Compliance Officer, or Viewer. After login you are redirected to /dashboard./dashboard, /upload, /rules, /policy-impact, /violations, /review, /reports — require login. Sidebar and header show based on role. Use header theme toggle (sun/moon) and notification bell. Sign out from the user dropdown; you get a toast and redirect to /.Stop the dev server (Ctrl+C) before building.
npm run build
npm start
npm run test # Lint + TypeScript check
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/
app/layout.tsx) — Server Component (no "use client"). Wraps children in <Providers>. No AnimatePresence on the whole tree.(app)/layout.tsx) — Client component owns collapsed state and provides it via SidebarContext. On pathname change, setCollapsed(true) so sidebar auto-collapses on nav. Structure: <Sidebar /> then <div className="flex-1"><Header /><main>{children}</main></div>. Sidebar does not re-mount on route change.w-64 / w-16, transition-[width] duration-200 ease-in-out. Role-based nav (admin: all + Settings; compliance: all except Settings; viewer: Dashboard, Profile, Reports). Links use <Link prefetch>; layout collapses on pathname change.<Link href="/profile"> and <Link href="/settings"> (Settings for admin only).<PageTransition> wraps content with motion.div (opacity + scale 0.98 → 1). No AnimatePresence wrapping the whole layout.loading.tsx with skeleton loaders.dynamic(..., { ssr: false }) in trend-chart-dynamic.tsx.Roles — admin |
compliance |
viewer. Login redirects with router.replace("/dashboard"). |
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).
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.
The backend needs to connect to your database (the one you want to run compliance rules against). Use the API or Swagger:
{
"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 |
src/data/ — analytics, policies, rules, violations (JSON). Used when NEXT_PUBLIC_API_URL is not set.