A modern data intelligence platform built with Next.js 16, FastAPI, TypeScript, and Tailwind CSS. This full-stack application combines interactive data visualization with AI-powered document retrieval for comprehensive data analysis.
- Cycle metrics analysis with interactive Plotly charts
- Record/measurement data visualization and querying
- RAG-powered chatbot for document retrieval
- Save and load chart configurations
- User authentication with JWT and Google OAuth
- Todo task management
- Dark mode support
- Export data to Excel format
InsightHub/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI application entry
│ │ ├── api/
│ │ │ ├── deps.py # Dependency injection (DB, Auth)
│ │ │ └── v1/
│ │ │ ├── api.py # Router aggregation
│ │ │ └── endpoints/ # API route handlers
│ │ │ ├── auth.py # Authentication endpoints
│ │ │ ├── chat.py # RAG chatbot endpoints
│ │ │ ├── cycle.py # Cycle metrics
│ │ │ ├── record.py # Record data
│ │ │ ├── chart.py # Chart save/load
│ │ │ └── todos.py # Todo management
│ │ ├── core/
│ │ │ ├── config.py # Settings & environment
│ │ │ ├── security.py # JWT token handling
│ │ │ └── google_oauth.py # Google OAuth handler
│ │ ├── db/
│ │ │ ├── session.py # Database session
│ │ │ └── base.py # SQLAlchemy base
│ │ ├── models/ # SQLAlchemy ORM models
│ │ ├── schemas/ # Pydantic request/response schemas
│ │ └── crud/ # CRUD operations
│ ├── utils.py # Data loading utilities
│ ├── build_db.py # Database initialization
│ ├── get_embeddings.py # ChromaDB embeddings generation
│ └── requirements.txt # Python dependencies
│
├── frontend/
│ ├── app/ # Next.js app router
│ │ ├── layout.tsx # Root layout with AuthProvider
│ │ ├── page.tsx # Home page
│ │ ├── login/page.tsx # Login page
│ │ ├── register/page.tsx # Registration page
│ │ ├── chat/page.tsx # RAG chatbot interface
│ │ ├── cycle/page.tsx # Cycle analytics
│ │ ├── record/page.tsx # Record analysis
│ │ ├── data-query/page.tsx # Data query interface
│ │ ├── todos/page.tsx # Todo management
│ │ └── globals.css # Global styles
│ ├── components/
│ │ ├── layout/
│ │ │ └── Navbar.tsx # Navigation component
│ │ ├── auth/
│ │ │ ├── ProtectedRoute.tsx # Auth guard wrapper
│ │ │ └── GoogleSignInButton.tsx
│ │ ├── ui/
│ │ │ └── Modal.tsx # Reusable modal
│ │ └── todos/ # Todo components
│ │ ├── TodoList.tsx
│ │ ├── TodoItem.tsx
│ │ └── AddTodoForm.tsx
│ ├── services/ # API service layer
│ │ ├── authService.ts # Auth API calls
│ │ ├── chatService.ts # Chat & RAG API calls
│ │ ├── cycleService.ts # Cycle analytics API calls
│ │ ├── recordService.ts # Record analysis API calls
│ │ └── todoService.ts # Todo API calls
│ ├── contexts/
│ │ └── AuthContext.tsx # Global auth state
│ ├── types/ # TypeScript type definitions
│ │ ├── auth.ts
│ │ ├── todo.ts
│ │ └── cycle.ts
│ ├── lib/
│ │ └── api/
│ │ ├── config.ts # API configuration
│ │ └── client.ts # Fetch wrapper with auth
│ ├── package.json
│ └── .env.local.example # Environment template
│
└── README.md
- Node.js 20+
- Python 3.10+
- PostgreSQL database
- OpenAI API key (for RAG chatbot)
- Google OAuth credentials (optional, for social login)
- Navigate to the backend directory:
cd backend- Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- Copy the environment file and configure:
cp .env.example .env- Configure the
.envfile with your credentials:
DATABASE_URL=postgresql+psycopg2://user:password@localhost:5432/insighthub
SECRET_KEY=your-secret-key-here
OPENAI_API_KEY=your-openai-api-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret- Initialize the database:
python build_db.py- Generate embeddings for RAG (optional):
python get_embeddings.py- Run the backend server:
uvicorn app.main:app --reload --port 8000- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Copy the environment file and configure:
cp .env.local.example .env.local- Run the development server:
npm run dev- Open http://localhost:3031 with your browser to see the result.
POST /register- User registrationPOST /login- Email/password loginGET /me- Get current user infoGET /google- Initiate Google OAuthGET /google/callback- OAuth callback
POST /ask- Send message to RAG chatbotPOST /sessions- Save chat sessionGET /sessions- List saved chatsGET /sessions/{session_id}- Get specific chatDELETE /sessions/{session_id}- Delete chat
GET /experiments- List available experimentsGET /cell_ids- Get cell IDs by experimentGET /metrics- Available metrics for visualizationPOST /datapoints- Query cycle data for charting
GET /experiments- List record experimentsGET /cell_ids- Get cell IDsGET /step_types- Available step typesPOST /datapoints- Query record datapoints
POST /- Save chart configurationGET /- List user's chartsGET /my- List user's and public chartsGET /{chart_id}- Get chart by ID
GET /- Get all todosPOST /- Create a new todoGET /{todo_id}- Get a specific todoPUT /{todo_id}- Update a todoDELETE /{todo_id}- Delete a todo
All API calls are centralized in the services/ directory, providing:
- Consistent error handling
- Authentication token injection
- Easy mocking for testing
Components are organized by feature:
components/auth/- Authentication componentscomponents/layout/- Layout componentscomponents/todos/- Todo feature componentscomponents/ui/- Reusable UI components
TypeScript interfaces in types/ ensure type safety across the frontend and provide excellent IDE support.
A custom fetchApi wrapper in lib/api/client.ts provides:
- Automatic JWT token injection
- Consistent error handling
- Type-safe responses
The chatbot uses LangChain with ChromaDB for retrieval-augmented generation:
- Document embeddings stored in ChromaDB
- GPT-4o-mini for response generation
- Context-aware document retrieval
- Framework: Next.js 16 (App Router)
- Language: TypeScript 5
- UI Library: React 19
- Styling: Tailwind CSS 4
- Charts: Plotly.js (react-plotly.js)
- State: React Context
- Framework: FastAPI
- Language: Python 3
- Database: PostgreSQL
- ORM: SQLAlchemy
- Validation: Pydantic
- Auth: JWT + Google OAuth
- AI/ML: LangChain + ChromaDB + OpenAI
- Analytics: DuckDB
- Data Format: Parquet files
- Processing: Pandas, PyArrow