Project implementing clean architecture consuming data from Github Api with NextJs
# 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
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) |
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.
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:
src/
├── app/
| └── _components/
├── layers/
| ├── application/
| | └── interfaces/
| | └── usecases/
| ├── domain/
| | └── errors/
| | └── models/
| ├── infrastructure/
| | └── repositories/
| | └── services/
| └── interface-adapters/
| └── controllers/
├── app/
| ├── di/
| ├── hooks/
| ├── styles/
| ├── ui/
| └── utils/
└── tests/
Using ioctopus
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.
MIT License. LICENSE
Gabriel Ramos (@whosramoss)