Skip to content

lucasfdcampos/raspberry-awards-api

Repository files navigation

🎬 Raspberry Awards API

Issues License Last Commit

NestJS SQLite3 TypeORM fast-csv

🎯 About the Project

This project was built to provide a simple, modular and testable RESTful API using NestJS. The goal is to process Raspberry Awards data from a CSV file, identify producers with the shortest and longest intervals between wins, and expose this information through clean endpoints.

The application follows best practices with:

  • Modular structure via NestJS
  • In-memory database via SQLite + TypeORM
  • CSV parsing with fast-csv
  • High test coverage using Jest (unit + e2e)

⚙️ Technologies Used

  • NestJS — a progressive Node.js framework for scalable server-side applications
  • SQLite3 — lightweight database, ideal for testing and in-memory persistence
  • TypeORM — a powerful ORM supporting multiple databases
  • fast-csv — efficient streaming parser for CSV files
  • Jest — testing framework for unit and e2e tests

💡 Features

  • CSV loading and parsing with fast-csv
  • Automatic table creation using TypeORM's synchronize: true
  • Clean modular architecture with NestJS
  • Producer interval logic split into small and testable functions
  • Test coverage with Jest

TypeORM with synchronize: true

Quick and easy setup: the movies table is created automatically based on the Movie entity structure.

Setting synchronize: true shouldn't be used in production - otherwise you can lose production data. NestJS

TypeOrmModule.forRoot({
  type: 'sqlite',
  database: ':memory:',
  entities: [Movie],
  synchronize: true, // auto-creates the table
}),

CSV loading with fast-csv

fs.createReadStream(csvPath)
  .pipe(csv.parse({ headers: true, delimiter: ';' }))
  ...

📦 Project setup

This project was created using the NestJS CLI:

$ nest new raspberry-awards-api

Using the Nest CLI ensures a clean and organized architecture out of the box, following best practices for modularity, testing, and maintainability.

Then, the main module for handling movie data was generated using the CLI:

$ nest generate resource movie

This created the controller, service, module, DTOs, and entity structure following NestJS best practices for a RESTful resource.

🚀 Running the Project

  1. Clone the repository
❯  git clone git@github.com:lucasfdcampos/raspberry-awards-api.git
  1. Enter the directory
cd raspberry-awards-api/
  1. Start the application
# install dependencies
❯  make install

# starts the project (also creates .env if missing)
❯  make start

🧪 Run tests

# unit tests
❯  make test

# e2e tests
❯  make test-e2e

# test coverage
❯  make test-cov

🔗 Available end-points

  • GET /movie
    Returns all movies loaded from the CSV.

  • GET /awards/intervals
    Returns a JSON with two arrays (min and max) showing producers with the shortest and longest intervals between wins.

    Run in Insomnia}

🏗️ Project Structure

├── app.module.ts
├── main.ts
└── movie
    ├── awards.controller.spec.ts
    ├── awards.controller.ts
    ├── dto
    │   ├── award-interval.dto.ts
    │   └── producer-interval.dto.ts
    ├── entities
    │   └── movie.entity.ts
    ├── movie.controller.spec.ts
    ├── movie.controller.ts
    ├── movielist.csv
    ├── movie.module.ts
    ├── movie.service.spec.ts
    └── movie.service.ts

🧠 Notes

Link to extra documentation shows organization and formation of ideas for the project.

Notion

📄 License

This project is licensed under the MIT License - see the LICENSE file for details

About

NestJS API to analyze Raspberry Awards data and extract producer win intervals.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors