Spy Cat Management System
Overview
This project is a CRUD application for managing spy cats, their missions, and the targets they are assigned to. The application is built to demonstrate the creation of RESTful APIs, interaction with a SQL-like database, integration with third-party services, and optional user interface creation.
Features
Technical Details
- Framework: Go-Chi for routing.
- Database: SQLite for simplicity and ease of use. The project structure allows easy integration with other databases like PostgreSQL or MySQL.
- Validation: Go-Playground Validator for request validation.
- Logging: Custom logger using Go's built-in
slog
package.
Project Structure
The project is organized to separate concerns and allow easy extension:
cmd/spy-cat
: Entry point of the application.
internal/handlers
: Contains HTTP handlers for different entities.
internal/storage
: Database interactions.
internal/lib
: Common libraries and utilities.
config
: Configuration files.
migrations
: Database migration files.
Getting Started
Prerequisites
- Docker
- Go (if running without Docker)
Running the Application with Docker
-
Build the Docker image:
docker build -t spy-cat-app .
-
Run the Docker container:
docker run -d -p 8082:8082 --name spy-cat-container spy-cat-app
-
Make requests to the application:
- Base URL:
http://localhost:8082/api/v1
- Use the provided Postman collection to test the API.
Configuration
The application configuration is managed using YAML files. For Docker, ensure you use the dev.yml
configuration:
env: "dev"
storage_path: "./storage/storage.db"
http_server:
address: "0.0.0.0:8082"
timeout: 4s
idle_timeout: 30s
Endpoints
Refer to the Postman collection in the repository for detailed information about available endpoints and their usage.
Additional Improvements
- Implement tests.
- Add authentication.
- Improve error handling.
- Extend with more detailed logging and monitoring.