Inkwell Backend is the server-side component of the Inkwell project. It handles user authentication, data storage, story and comic generation, and integrates AI-powered functionality through LLM services. Built in Go, the backend uses a modular architecture that cleanly separates configuration, database management, and business logic.
- User Authentication & Authorization: Secure login, registration, and token management.
- Story & Comic Generation: Create, update, and complete stories; generate comics based on stories.
- AI Integration: LLM and image generation using external services.
- Event-Driven Architecture: Internal event bus to trigger background processes.
- RESTful API: RESTful endpoints for client-side integrations.
- Cross-Platform Support: OS-specific commands to manage external services (e.g., starting/stopping Ollama).
The front-end repository is available at: Inkwell Frontend
.
├── cmd
│ └── app
│ ├── main.go # Application entry point
│ └── seed.go # Database seeding script
├── config-example.xml # Example configuration file
├── config.xml # Application configuration file
├── go.mod # Go module file
├── go.sum # Dependency checksum file
├── internal
│ ├── config
│ │ └── config.go # Configuration loader
│ ├── db
│ │ └── connection_manager.go # Database connection management
│ ├── llm
│ │ ├── ollama_client.go # LLM API client (Ollama)
│ │ └── stableDiffusion_wrapper.go # Stable Diffusion integration
│ ├── model
│ │ └── model.go # Data models
│ ├── repository # Data access layer
│ │ ├── assessment_repository.go
| | ├── question_repository.go
| | ├── story_repository.go
| | └── user_repository.go
│ └── service
│ ├── analysis_service.go # Analysis & writing skills
│ ├── assessment_service.go # Assessment logic
│ ├── auth_service.go # User authentication
│ ├── comic_service.go # Comic generation
│ ├── progress_service.go # Progress tracking
│ ├── story_service.go # Story management
│ └── user_service.go # User management
├── utilities
│ ├── auth_middleware.go # JWT authentication middleware
│ ├── CORS_middleware.go # CORS handling
│ ├── event_bus.go # Internal event bus
│ └── jwt_util.go # JWT utility functions
└── working
├── comics # Generated comic PDFs
└── storyImages # AI-generated story images
- Go: Install the latest version from Go Downloads.
- Database: Set up your preferred database (PostgreSQL, MySQL, SQLite, etc.) and configure it in
config.xml
. - External Services: Ensure any external services (e.g., Ollama, Stable Diffusion) are installed and accessible.
- Clone the Repository:
git clone https://github.com/Olooce/inkwell-backend-V2.0.git cd inkwell-backend-V2.0
- Download Dependencies:
go mod tidy
- Configure the Application:
- Edit
config.xml
with your database credentials, API tokens, and other settings.
- Edit
- Development Mode:
go run cmd/app/main.go
- Seeding the Database (if needed):
go run cmd/app/seed.go
- Build and Run Executable:
go build -o inkwell cmd/app/main.go ./inkwell
-
POST
/auth/register
Description: Register a new user.
Request Body Example:{ "name": "John Doe", "email": "john@example.com", "password": "secret" }
Response Example:
{ "message": "User registered successfully" }
-
POST
/auth/login
Description: Log in a user and receive a JWT token.
Request Body Example:{ "email": "john@example.com", "authhash": "hashed_password" }
Response Example:
{ "user_id": 1, "token": "jwt-token-here" }
-
POST
/auth/refresh
Description: Refresh JWT tokens.
Request Body Example:{ "refresh_token": "refresh-token-here" }
Response Example:
{ "access_token": "new-jwt-token", "refresh_token": "new-refresh-token" }
- GET
/user
Description: Retrieve all users.
Response Example:[ { "id": 1, "name": "John Doe", "email": "john@example.com", "": "" } ]
-
POST
/assessments/start
Description: Start a new assessment session with a randomly selected grammar topic.
Response Example:{ "session_id": "abc123", "topic": "Tenses", "questions": [ /* question objects */ ] }
-
POST
/assessments/submit
Description: Submit an answer for a question within an assessment.
Request Body Example:{ "session_id": "abc123", "question_id": 1, "answer": "Your answer here" }
Response Example:
{ "feedback": "Correct", "is_correct": true }
-
GET
/assessments/:session_id
Description: Retrieve a specific assessment session by session ID.
Response Example:{ "session_id": "abc123", "questions": [ /* question objects */ ], "answers": [ /* answer objects */ ] }
-
GET
/stories/
Description: Retrieve all stories.
Response Example:[ { "id": 1, "title": "A Great Story", "analysis": "Detailed analysis..." } ]
-
POST
/stories/start_story
Description: Start a new story.
Request Body Example:{ "title": "A New Adventure" }
Response Example:
{ "story_id": 1, "guidance": "Begin with an exciting sentence!", "max_sentences": 5 }
-
POST
/stories/:id/add_sentence
Description: Add a sentence to an existing story.
Request Body Example:{ "sentence": "Once upon a time..." }
Response Example:
{ "sentence": { "original_text": "Once upon a time...", "corrected_text": "Once upon a time...", "feedback": "Looks good!", "image_url": "http://example.com/image.png" } }
-
POST
/stories/:id/complete_story
Description: Mark a story as complete.
Response Example:{ "message": "Story completed successfully" }
-
GET
/stories/progress
Description: Get the progress of the current user's in-progress story.
Response Example:{ "story_id": 1, "progress": "3/5 sentences added" }
-
GET
/stories/comics
Description: Retrieve all generated comics for the authenticated user.
Response Example:[ { "comic_id": 10, "url": "http://example.com/comic_10.pdf" } ]
-
GET
/writing-skills/analysis/
Description: Get detailed analysis for completed stories along with writing tips.
Response Example:{ "stories": [ { "story_id": 1, "title": "A Great Story", "analysis": "Detailed analysis...", "tips": ["Tip 1", "Tip 2"] } ] }
-
GET
/writing-skills/analysis/overview
Description: Retrieve an overview of writing skills progress.
Response Example:{ "initial_progress": "Initial progress data", "current_progress": "Current progress data" }
-
GET
/writing-skills/analysis/download_report?type=initial
or?type=current
Description: Download a PDF report for initial or current progress.
Response: A PDF file is served with the appropriate download headers.
-
GET
/static
Description: Serve static files from theworking
directory. -
GET
/download/comics/:filename
Description: Download a comic PDF with proper headers.
Example: Accessing/download/comics/comic_10.pdf
initiates a download of that comic.
This project is licensed under the MIT License.