This repository contains the code for the Marvel Web Challenge. It is a web application that consumes data from the Marvel API and displays information about different characters.
The project follows a hexagonal architecture, which means that the business logic is separated from the external dependencies. This allows for better maintainability and testability.
The project is structured as follows:
src/domain
: This folder contains the domain entities, use cases, and repositories. It is the core of the application and contains the business logic.src/infrastructure/repositories
: This folder contains the implementations of the repositories defined in the domain layer. It is responsible for interacting with external systems and data sources.src/infrastructure/controllers
: This folder contains the controllers, which are responsible for handling HTTP requests and responses.src/infrastructure/views
: This folder contains the frontend application. It is built using React with TypeScript and Vite.
The hexagonal architecture allows for better separation of concerns and makes it easier to test and maintain the code.
It's important to note that the backend and frontend are coupled through the API, but they are not directly dependent on each other. This allows for better flexibility and scalability.
- Node.js installed: https://nodejs.org/en/download/
- Git installed: https://git-scm.com/downloads
- npm (v6.x or higher)
- pnpm installed:
npm install -g pnpm
- Clone the repository:
git clone https://github.com/tonyl/marvel.git
- Install dependencies:
pnpm install
-
Create an Account on the Marvel Portal
- Visit the Marvel Developer Portal.
- Sign up or log in if you already have an account.
-
Obtain API Keys
- After logging in, navigate to the API Keys section.
- Create a new public and private key if you don't already have one.
- Copy your public and private key.
-
Set Up the Development Environment
- Create a
.env.development
file in the root of your Node.js project../app
- Create a
.env.development
file in the root of your frontend project../app/src/infrastructure/views/react/marvel-web-app
- Create an extra file for build command
.env.production.local
in frontend project with the API_KEY for prod (can be the same as.env.development
just for dev purposes).
- Create a
# .env.development
MARVEL_PUBLIC_KEY=your_public_key
MARVEL_PRIVATE_KEY=your_private_key
PORT=3000
# .env.development
//VITE_API_HOST=localhost:3000
VITE_API_HOST=your_backend_host
The backend is built using Node.js and Express. It provides a RESTful API for retrieving character and comic information.
GET /api/characters
: Get all Marvel characters.GET /api/characters/:characterId
: Get a specific Marvel character by ID.GET /api/characters/:characterId/comics
: Get all comics featuring a specific character by ID.
- Start the backend:
cd ./app && pnpm run dev
The frontend is built using React with TypeScript and Vite. It consumes data from the backend and displays information about different characters.
- Navigate to the frontend directory:
cd ./src/infrastructure/views/react/marvel-web-app
Note: You don't need to run this command if you have already run
pnpm install
in the root folder. - Install dependencies:
pnpm install
- Start the frontend:
pnpm run dev
- Open your browser and navigate to
http://localhost:5173/
To build the application, you can use the following commands inside the ./app
folder:
- Build app:
pnpm run build
- Build only frontend:
pnpm run build:frontend
- Build only backend:
pnpm run build:backend
This project is licensed under the MIT License. See the LICENSE file for details.