Anime Catalog Clojure is a full-stack (that can be quoted :-) ) project built with Clojure. It provides a RESTful API to manage and display anime information using a MariaDB database and a simple web frontend that consumes this API. This project is an excellent example for beginners to learn about backend development with Clojure, handling database connections, and creating basic web interfaces.
- Features
- Requirements
- Installation
- Running the Project
- API Endpoints
- Project Structure
- Example Requests
- License
- Contributing
- Contact
- RESTful API built using Compojure and Ring.
- Database connectivity using next.jdbc to interact with a MariaDB database.
- Basic CRUD operations for managing anime records.
- A simple web frontend (HTML/JavaScript) to display the titles in catalog of animes.
- Configured with Clojure CLI tools using a
deps.ednfile.
- Java (JDK 8 or higher)
- Clojure (see Clojure Getting Started)
- MariaDB (or any compatible database; adjust connection settings in the code)
- Optionally, a tool for serving static files (e.g., Python's
http.server)
git clone https://github.com/yourusername/anime-catalog-clojure.git
cd anime-catalog-clojureEdit the file src/animeapp/dbconn.clj to match your database credentials.
Create a MariaDB database named (for example) mylist and a table named anime. Here is a simple SQL example (adjust as needed):
CREATE DATABASE mylist;
USE mylist;
CREATE TABLE anime (
anime_id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
jp_title VARCHAR(255),
genero VARCHAR(100),
descripcion TEXT
);The backend is configured with a run alias in the deps.edn file.
Run the API server:
clojure -M:run-mThe server will start on port 3000. You can access the API at:
http://localhost:3000/anime
The frontend files are located in src/animeapp/web.
Open the Frontend:
- Simply open
src/animeapp/web/index.htmlin your web browser.
Here are the primary API endpoints provided by the backend:
-
GET /anime
Retrieves all anime records. -
GET /anime/search/:title
Searches for anime records by title (or Japanese title). -
POST /anime
Creates a new anime record. Expects a JSON body with keys:title,jp_title,genero, anddescripcion. -
PUT /anime/:id
Updates an anime record by its ID. Expects a JSON body with keys liketitleandjp_title. -
DELETE /anime/:id
Deletes an anime record by its ID.
anime-catalog-clojure/
├── deps.edn ; Dependency configuration and aliases
├── src/
│ └── animeapp/
│ ├── core.clj ; API routes, web server setup, JSON response helper, and CORS middleware
│ ├── dbconn.clj ; Database connection configuration using next.jdbc
│ ├── queries.clj ; CRUD SQL queries
│ └── services.clj ; Service layer wrapping the query functions
│ └── web/ ; Frontend folder
│ ├── index.html ; Basic HTML page consuming the API
│ └── some.js ; JavaScript code to fetch and display anime data
└── README.md ; This file
-
Get all animes:
curl http://localhost:3000/anime
-
Search anime by title:
curl http://localhost:3000/anime/search/One
-
Create a new anime:
curl -X POST http://localhost:3000/anime \ -H "Content-Type: application/json" \ -d '{"title": "Naruto", "jp_title": "ナルト", "genero": "Shonen", "descripcion": "A popular anime series."}' -
Update an anime (replace
:idwith the actual anime ID):curl -X PUT http://localhost:3000/anime/1 \ -H "Content-Type: application/json" \ -d '{"title": "Naruto Shippuden", "jp_title": "ナルト 疾風伝"}' -
Delete an anime (replace
:idwith the actual anime ID):curl -X DELETE http://localhost:3000/anime/1
This project is licensed under the terms of the Eclipse Public License v2.0. See the LICENSE file for details.
Contributions are welcome! Feel free to fork the repository and submit pull requests. For any issues or questions, please open an issue on GitHub.
For questions or suggestions, please contact:
Isaac Narváez Email: isaac.rkt@proton.me