Skip to content

Project implementing clean architecture consuming data from Github Api with NextJs

License

Notifications You must be signed in to change notification settings

whosramoss/clean-nextjs-github

Repository files navigation

clean-nextjs-github

Project implementing clean architecture consuming data from Github Api with NextJs

Website React Tailwind TypeScript Framer Motion Prettier eslint zod vitest zustand


How to install

  # Clone the project
  git clone https://github.com/whosramoss/clean-nextjs-github/

  # Go to the project directory
  cd clean-nextjs-github

  # Install dependencies
  npm install

  # Start the server 
  npm run dev

About GitHub API

The GitHub API (https://api.github.com), is a powerful RESTful web service that allows developers to interact programmatically with GitHub's platform. It provides a wide range of endpoints for accessing and manipulating data stored on GitHub, such as repositories, issues, pull requests, users, organizations, and more. With both REST and GraphQL options, the api allows developers to retrieve only the data they need, ensuring efficiency.

The following API endpoints are being used in the project. Each route corresponds to a specific action within the system :

Name Purpose Method Params
/events Get events GET No Params
/orgs Get information about a specific organization GET Organization Name (e.g.: /orgs/google)
/gists Get information about a specific gist GET Gist Id - (e.g.: /gists/public)
/search/topics Searh information about a specific topic GET Topic Name - (e.g.: /topics?q=google)
/users Get information about a specific user GET User Name - (e.g.: /users/whosramoss)

About Clean Architecture

Software design principle focused on organizing the code to improve maintainability, testability, and flexibility by clearly defining the responsibilities of different components. When applied to an application using the GitHub API, it ensures that the core business logic remains independent of external systems like the API.

This allows for easier updates, testing, and modifications, as changes to the API or other external dependencies do not directly impact the core logic. The approach promotes a modular and extensible design, making the application easier to maintain and scale over time.

Layers and Structs

Following the Clean Architecture principles, we separate our project into 4 layers inside the layers folder:

Name Contains Purpose
interface-adapters controllers The layer translates data between the core business logic and the UIs. It implements controllers to adapt data returned by the usecases into usable formats.
application interfaces & usecases Contains the usecases that define the application's business processes and workflows. Usecases may also need data from external sources, so they interact with repositories or services implemented in the infrastructure layer to fulfill specific requirements.
infrastructure repositories & services The layer provides the implementation details for external systems like databases, APIs, and file storage. It's responsible for managing communication with external services and ensuring the core logic remains decoupled from specific technologies.
domain errors & models Contains models, schemas and errors that drive the system's behavior.

You can explore the entire data search process, layer by layer, through the graph below:

clean-nextjs-github

Overhead Structure View

src/
├── app/
|     └── _components/
├── layers/
|     ├── application/
|     |     └── interfaces/
|     |     └── usecases/
|     ├── domain/
|     |     └── errors/
|     |     └── models/
|     ├── infrastructure/
|     |     └── repositories/
|     |     └── services/
|     └── interface-adapters/
|           └── controllers/
├── app/
|     ├── di/
|     ├── hooks/
|     ├── styles/
|     ├── ui/
|     └── utils/
└── tests/

Dependency injection (DI)

Using ioctopus

Framework and Packages

Screenshoots

Contributing

If you want to contribute to clean-nextjs-github, please make sure to review the contribution guidelines. This project makes use of GitHub issues for tracking requests and bugs.

License

MIT License. LICENSE

Author

Gabriel Ramos (@whosramoss)

About

Project implementing clean architecture consuming data from Github Api with NextJs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages