LLM Tracker is a platform for analyzing and visualizing LLM usage and costs across your projects. It provides a simple interface to monitor your expenses and understand how your different models are being used.
- Multi-tenant: Organize your work into different organizations and projects.
- Usage Tracking: Log and monitor usage data from various LLM providers and models.
- Cost Analysis: Keep track of token usage and associated costs for each project.
- Dashboard: Visualize usage trends and key metrics with interactive charts.
- Authentication: Secure user authentication handled by NextAuth.js.
- API: A simple RESTful API to manage your resources.
- Next.js - React framework for building the user interface.
- Prisma - Type-safe ORM for PostgreSQL database access.
- NextAuth.js - Authentication for Next.js applications.
- PostgreSQL - Open source relational database (Dockerized).
- Tailwind CSS - Utility-first CSS framework for styling.
- shadcn/ui - Re-usable components built using Radix UI and Tailwind CSS.
- Recharts - A composable charting library built on React components.
- TypeScript - Static-typed superset of JavaScript.
Follow these instructions to get the project up and running on your local machine.
- Node.js (v18 or later)
- npm or yarn
- Docker (for PostgreSQL database)
-
Clone the repository:
git clone https://github.com/your-username/llm-tracker.git cd llm-tracker -
Install dependencies:
npm install # or yarn install -
Start the PostgreSQL database using Docker:
docker-compose up -d
This will start a local PostgreSQL instance on port 5432 with the credentials defined in
docker-compose.yml. -
Set up environment variables:
Create a
.env.localfile in the root of the project and add the following:DATABASE_URL="postgresql://postgres:postgres@localhost:5432/llmtracker_db" NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_SECRET=your-random-secret # Add any other NextAuth provider secrets if needed
- You can generate a random secret for
NEXTAUTH_SECRETwith:openssl rand -base64 32
- You can generate a random secret for
-
Run Prisma migrations to set up the database schema:
npx prisma migrate deploy # or, for development with a new migration npx prisma migrate dev --name initThis will create all necessary tables in your local Postgres database.
-
Generate the Prisma client:
npx prisma generate
-
(Optional) Seed the database: If you have a seed script, run:
npx prisma db seed
-
Run the development server:
npm run dev # or yarn dev
Open http://localhost:3000 with your browser to see the result.
The application exposes a set of RESTful endpoints to manage organizations, projects, and track usage. You can explore the available routes in app/api/v1/.
- Authentication is handled by NextAuth.js. You can configure providers in the NextAuth options.
- All data is stored in your local Dockerized PostgreSQL instance via Prisma ORM.
- For production, update your
DATABASE_URLandNEXTAUTH_URLaccordingly.