How msrks/vihub works
Project Type and Purpose
• VIHub is a full-stack web application built using Next.js. It has a sophisticated, multi-faceted UI (with areas for image uploading, annotation, insights, training jobs, etc.) and a robust backend built with API endpoints, TRPC routers, and database integration.
• The README shows an ERD image (./public/erd.png) and includes setup instructions for GCS authentication, confirming that the system interacts with cloud storage. The application also integrates with external services (evident from directories such as server/gcs, server/pinecone, server/replicate, and server/vertexai), likely for AI/ML functionalities and image/data processing.
File Structure
• Frontend/UI: The majority of the UI-related code is in the “src/app” directory. Notice subdirectories for workspaces and image stores (like annotate, dataset, insights, llm-playground, monitoring, etc.). Additionally, “src/components” provide reusable UI components.
• Backend/API: API endpoint definitions are found under “src/app/api” and “src/server/api”, with TRPC routers (in “src/trpc” and “src/server/api/routers”) that hint at remote procedure call patterns.
• Database & Migrations: The “drizzle” directory (with its SQL migration files) and “drizzle.config.ts” indicate that the project is using Drizzle ORM for database management. Additionally, “src/server/db” holds schema definitions and database functionality.
• External Integrations: Folders such as “src/server/gcs”, “src/server/pinecone”, “src/server/replicate”, and “src/server/vertexai” signal integration with cloud storage, vector search, image replication/processing, and Vertex AI services respectively.
• Other Configuration/Tooling: The presence of configuration files (next.config.js, tailwind.config.ts, tsconfig.json, etc.) and linters (eslintrc, prettier) support an organized development environment.
a. Main Components:
• Frontend (Next.js UI):
• Pages and sub-pages (organized under src/app) for various features such as image store management, annotation, dataset management, insights, monitoring, etc.
• Common/shared components (in src/components) that support UI consistency and theming.
• Backend / API Layer:
• API Routes: Authentication (using NextAuth in src/app/api/auth), image upload endpoints, workspace management, etc.
• TRPC Routers and centralized endpoints (src/server/api/routers and src/trpc) that handle business logic.
• Database Layer:
• Drizzle ORM migrations (drizzle folder) and schema definitions (src/server/db) defining the persistent store.
• External Services:
• GCS: For cloud storage (instructions in README and code in src/server/gcs).
• Other AI/ML components: Pinecone for vector search; Replicate and Vertex AI for processing, model inference, pipelines, and dataset handling.
b. Relationships and Interactions:
• The UI interacts with the API layer (via Next.js API routes and TRPC) for authentication, data requests, and actions like image upload.
• The API layer, in turn, communicates with the database to perform CRUD operations as defined by the schema.
• Certain API endpoints (like those in server/cron and integrations directories) interact with external services (e.g., GCS, Pinecone, Vertex AI) to manage storage, perform AI predictions, or process images.
• The ERD (referenced in the README) further connects the data model to the application’s flows.
c. Architectural Patterns / Design Principles:
• Separation of Concerns: The project clearly divides responsibilities among the UI (presentation), API/business logic (controllers/routers), data access (Drizzle ORM and database), and external integrations.
• Modular Design: With features organized into distinct subdirectories (e.g., image store features, training, monitoring, etc.), the design supports maintainability and scalability.
• API Abstraction: Use of TRPC and Next.js API routes abstracts the back-end services, making it easy to evolve the application.
d. Key Technologies & Frameworks:
• Next.js for UI and routing.
• Drizzle ORM for database migrations and schema.
• TRPC for API endpoints.
• External services and integrations (GCS, Pinecone, Replicate, Vertex AI).
• Tailwind CSS for styling (inferred from tailwind.config.ts) and additional UI tooling.