Lecca.io LogoLecca.io
Directory structure

Server Package

The server runs on a Node.js framework, NestJS, and is written in Typescript. It is structured using modules, controllers, and services. Modules contain controllers and services. Controllers contain the api endpoints or routes that the client uses to interact with the server. Controllers do not contain any logic besides validation logic. Then they call a service to handle the request. Services interface with the database and perform the actual logic requested by the user.

The server directories you will most likely be working with are the following

  • packages/server/src/config/server.config.ts - We do not directly use process.env anywhere in the server besides this file. This is so that in the future, we can support config files to override and customize the behavior of the server.

  • packages/server/src/modules/ai-provider/ai-provider.service.ts - We manually add new ai providers. If they match the openai specification we can use createOpenAI to create a provider instance. The reason we have to manually add them is because we have to calculate the cost in the ai-provider-defaults.ts file. But since we're open sourcing and a lot of people won't be using credits anyways when they run locally, we may be able to figure out a way to determine which providers support credits, which require api keys, and which ones are running locally or have a custom baseUrl.

  • packages/server/prisma/schema.prisma - Defines the database schema using Prisma. Run pnpm prisma migrate dev to migrate your database with any changes you've made in the prisma schema. You can read more about prisma at prisma.io