Lottie Server is the backend server for the Lottie Editor application. It handles real-time synchronization, GraphQL API requests, and websocket connections to facilitate collaboration and animation editing.
- Features
- Live
- Installation
- Database and Architecture
- Usage
- Scripts
- Project Structure
- GraphQL and Codegen
- Testing
- Deplopyment
- Open Issues
- Contributing
- License
- Built using
TypeScriptandFastify - Complete integration of
eslintandprettier - Integrates
graphql-codegenfor generating graphql schemas - Integrates
mongodbandmongooseto talk to db using models - Uses
graphql-yogafor handling GraphQL requests - Integrates
socket.iofor handling websockets
- Real-time synchronization of Lottie animations
- GraphQL API for CRUD operations on animations
- Websocket support for real-time updates
- Collaboration support with multiple users
https://lottie-editor.onrender.com/
Follow these steps to set up the project locally:
-
Clone the repository:
git clone https://github.com/karanhudia/lottie-server.git cd lottie-server -
Install dependencies:
yarn
-
Set up environment variables: Create a
.envfile in the root of the project and add the following environment variables:PORT= # Port on which you want to run your application (default is 4000) MONGODB_URI= # MongoDB URL along with /databasename MONGODB_COLLECTION_NAME= # Collection name for the database
This project is using MongoDB with only one collection at the moment to store the lottie animation json information. You can find the details below. The database is hosted on https://cloud.mongodb.com/
To start the development server, run:
yarn start
This will start your fastify application and start listening on http://localhost:4000. The app will reload automatically as you make changes to the code.
yarn start: Starts the development server.
yarn build: Builds the app for production.
yarn test: Runs tests with jest
yarn type-check: Runs tsc check
yarn lint: Runs linting with eslint
yarn codegen: Generates new GraphQL types (server should be running)
src/
├── controllers/ # Controllers for handling requests
├── graphql/ # GraphQL schema and generated types
├── models/ # Database models for mongoose
├── plugins/ # Fastify plugins to decorate the instance
├── routes/ # API and GraphQL routes
├── utils/ # Utility functions
└── index.ts # Entry point of the server
We are using graphql-codegen to generate GraphQL types for the schemas used. You can find the configuration file for the codegen here.
The script has to be run everytime you change the
schema.graphql file.
This will generate new types based on the updated schema.graphql file. The changes need to be pushed in the commit.
The test setup is using jest with TypeScript support. There are other several libraries being used to support the tests, for example-
mongodb-memory-serverto create mongodb database in memorysocket.io-clientto mock client socket connection
The app uses Render server to trigger deployment pipeline through main branch.
WebSocket address- https://lottie-editor.onrender.com/
GraphQL address- https://lottie-editor.onrender.com/graphql
- Creating rooms for websockets to limit sending updates to all connected clients (top priority)
- Testing GraphQL endpoint
- MongoDb Collection for authorization users for private editing
I welcome contributions to improve Lottie Server! Here’s how you can contribute:
- Fork the repository.
- Create a new branch with a descriptive name.
- Make your changes.
- Open a pull request describing your changes.
This project is licensed under the MIT License.
Feel free to reach out if you have any questions or need further assistance. Happy coding!
