Skip to content
shecodesonlymannnPublic

About

a simple tmdb cli made for film lovers, made with js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TMDB JavaScript Backend(partially working)

This is a simple backend project that uses the TMDB API to search movies, get trending movies, and get movie details.

The project is written in pure JavaScript and uses the Node.js built-in HTTP server

What this project can do

  • Search movies by name
  • Show trending movies
  • Show details of one movie by movie id
  • Return JSON responses from HTTP routes
  • Keep the code in a clean beginner-friendly folder structure

Where to place your API key

Create a file named .env in the main project folder:

TMDB_API_KEY=your_real_tmdb_api_key_here
PORT=3000

You can also copy .env.example and rename the copy to .env.

Important: never upload your .env file to GitHub. It contains your private API key.

How to install and run

Install packages:

npm install

Start the backend:

npm start

The server will run here:

http://localhost:3000

API routes

Check if the backend is running:

GET /health

Search movies:

GET /movies/search?query=batman

Get trending movies:

GET /movies/trending

Get one movie by id:

GET /movies/550

Example browser URL:

http://localhost:3000/movies/search?query=batman

Project structure

src/
|
|-- app/
|   |-- server.js
|   |-- routes.js
|   `-- middleware/
|
|-- modules/
|   |
|   |-- movies/
|   |   |-- domain/
|   |   |   |-- Movie.js
|   |   |   `-- MovieRepository.js
|   |   |
|   |   |-- application/
|   |   |   |-- SearchMovies.js
|   |   |   |-- GetMovieDetails.js
|   |   |   `-- GetTrendingMovies.js
|   |   |
|   |   |-- infrastructure/
|   |   |   |-- TmdbMovieRepository.js
|   |   |   `-- movie.mapper.js
|   |   |
|   |   `-- presentation/
|   |       |-- movie.controller.js
|   |       `-- movie.routes.js
|   |
|   |-- tv/
|   |-- people/
|   |-- auth/
|   `-- favorites/
|
|-- shared/
|   |-- http/
|   |-- logger/
|   |-- cache/
|   |-- config/
|   |-- errors/
|   `-- utils/
|
|-- database/
|   |-- prisma/
|   `-- migrations/
|
|-- tests/
|   |-- integration/
|   `-- unit/
|
`-- index.js

random definations (smaller version , more detailed later on)

Route: a URL path that does something. Example: /movies/trending.

Controller: the file that receives a request and decides what response to send.

Module: a folder for one feature. In this project, movies is a module.

Domain: the core business rules and types. It should not care about HTTP or TMDB details.

Application: the use cases of the app. Example: SearchMovies.

Infrastructure: code that talks to outside things, like the TMDB API or a database.

Repository: a class or interface used to get data. Here, MovieRepository says what movie data methods must exist.

Mapper: code that changes data from one shape to another. TMDB data is converted into our own Movie shape.

Shared: code that can be used by many modules, like config, errors, logging, and HTTP helpers.

Environment variable: a value stored outside the code. Your API key is stored in .env as TMDB_API_KEY.

JavaScript: the programming language used in this project.

Node.js: the program that lets JavaScript run outside the browser.

Main flow

When you visit:

/movies/search?query=batman

The request goes through this path:

index.js
app/server.js
app/routes.js
movie.routes.js
movie.controller.js
SearchMovies.js
TmdbMovieRepository.js
TMDB API

Then the backend sends JSON back to the browser or API client.

Notes

  • some folder are just empty , are made for structural reasons only
  • The tv, people, auth, and favorites folders are placeholders for future features
  • readme is ai generated , so will definetly update it in the future

About

a simple tmdb cli made for film lovers, made with js

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages