20plots is an open-source web application designed to help users generate and manage creative writing plots based on personal elements. It combines artificial intelligence with user input to inspire and assist in the creative process. The application is built using a Java backend with Spring Boot and a React frontend, deployed on AWS with infrastructure managed via Terraform.
20plots is provided as-is, primarily for reference and inspiration. It was successfully deployed and operational at the time of its creation but is no longer under active development or maintenance.
This project is not supported, and no guarantees are made about its functionality, security, or compatibility with future technologies. Contributions are welcome but will be reviewed at my discretion, and new features or enhancements are unlikely to be accepted.
- Personalized Plot Generation: Use AI to generate story plots tailored to your unique interests and experiences.
- Interactive Plot Management: Curate and manage your top 20 story plots, create new versions, or manually add your own ideas.
- Creative Pool Builder: Develop lists of interesting people, personal anecdotes, story concepts, locations, and dreams to fuel your creativity.
- Genre Selection: Choose from 44 different genres to match your mood and writing style.
- Format Preview: Preview your stories in 15 different formats, such as screenplay, prose, or monologue, to see how your ideas come to life.
- Sample Scripts: Get inspired by sample scripts generated from your plots to spark your imagination.
AI-assist, not AI-replace: 20plots is designed to assist and inspire human creativity, not to replace it.
Explore a detailed walkthrough of 20plots, complete with screenshots, features, and functionality: ➡️ 20plots Walkthrough
To set up and run 20plots, ensure you have the following installed:
- Java Development Kit (JDK) 17 or later
- Node.js and npm
- Terraform
- Docker (optional, for containerized deployment)
- PostgreSQL database
- AWS CLI (optional, for deploying to AWS ECR)
20plots uses environment variables for configuration. You can set these in your shell or by creating a .env
file in the project's root directory.
General Configuration:
TWENTYPLOTS_POSTGRES_URL
: PostgreSQL JDBC URL (e.g.,jdbc:postgresql://localhost:5432/twentyplots
).TWENTYPLOTS_POSTGRES_USERNAME
: PostgreSQL username.TWENTYPLOTS_POSTGRES_PASSWORD
: PostgreSQL password.TWENTYPLOTS_JWT_SECRET
: JWT secret key.TWENTYPLOTS_FRONTEND_URL
: Frontend URL (e.g.,http://localhost:3000
).TWENTYPLOTS_OPENROUTER_APIKEY
: OpenRouter API Key.TWENTYPLOTS_OPENAI_APIKEY
: OpenAI API Key.TWENTYPLOTS_OPENAI_MODEL
: OpenAI Model (e.g.,text-davinci-003
).
Deployment Configuration (for AWS ECR):
AWS_ACCOUNT_ID
: Your AWS account ID.AWS_REGION
: AWS region (default:us-east-2
).ECR_REPOSITORY
: ECR repository name.DOCKER_IMAGE_TAG
: Docker image tag (default:latest
).PLATFORM
: Build platform (default:linux/amd64
).ACTIVE_PROFILE
: Spring Boot active profile (dev
orprod
, default:prod
).
Create a .env
file in the root directory:
# General Configuration
TWENTYPLOTS_POSTGRES_URL=jdbc:postgresql://localhost:5432/twentyplots
TWENTYPLOTS_POSTGRES_USERNAME=your_db_username
TWENTYPLOTS_POSTGRES_PASSWORD=your_db_password
TWENTYPLOTS_JWT_SECRET=your_jwt_secret
TWENTYPLOTS_FRONTEND_URL=http://localhost:3000
TWENTYPLOTS_OPENROUTER_APIKEY=your_openrouter_apikey
TWENTYPLOTS_OPENAI_APIKEY=your_openai_apikey
TWENTYPLOTS_OPENAI_MODEL=gpt-4o-2024-11-20
# Deployment Configuration
AWS_ACCOUNT_ID=your_aws_account_id
AWS_REGION=us-east-2
ECR_REPOSITORY=twentyplots
DOCKER_IMAGE_TAG=latest
PLATFORM=linux/amd64
ACTIVE_PROFILE=prod
Note: Do not commit your .env
file to version control as it contains sensitive information.
Load the variables into your shell session:
export $(grep -v '^#' .env | xargs)
The cloud infrastructure is managed using Terraform.
-
Navigate to the cloud directory:
cd 20plots-cloud/
-
Initialize Terraform:
terraform init
-
Apply the configuration:
terraform apply
Terraform will prompt for variable values if not provided in a
terraform.tfvars
file or environment variables.
The server application is a Spring Boot project using OpenJDK 17.
To run the server locally, you can use the provided script dev-run-server.sh
.
-
Ensure that the frontend URL is set correctly:
The
dev-run-server.sh
script setsTWENTYPLOTS_FRONTEND_URL
tohttp://localhost:3000
before running the server. -
Run the development server script:
./scripts/dev-run-server.sh
This script will:
- Stop and remove any existing Docker container named
20plots-server-container
. - Clean and build the project using Gradle.
- Start the server application with the appropriate environment variables.
- Stop and remove any existing Docker container named
The client UI is a React application.
To run the client locally, use the provided script dev-run-ui.sh
.
-
Run the development UI script:
./scripts/dev-run-ui.sh
This script will:
- Stop and remove any existing Docker container named
20plots-ui-container
. - Create an
.env
file withREACT_APP_BACKEND_URL
set tohttp://localhost:8080
. - Build the React application.
- Start the development server.
- Stop and remove any existing Docker container named
The scripts
directory contains scripts for deploying and running the applications.
deploy-server.sh
: Builds and pushes the server Docker image to a container registry.deploy-ui.sh
: Builds and pushes the UI Docker image to a container registry.
These scripts use environment variables for configuration. Ensure the following variables are set:
AWS_ACCOUNT_ID
AWS_REGION
ECR_REPOSITORY
DOCKER_IMAGE_TAG
PLATFORM
ACTIVE_PROFILE
-
Set environment variables:
export AWS_ACCOUNT_ID=your_aws_account_id export AWS_REGION=us-east-2 export ECR_REPOSITORY=your_ecr_repository_name export DOCKER_IMAGE_TAG=latest export ACTIVE_PROFILE=prod
-
Deploy the server:
./scripts/deploy-server.sh
-
Deploy the UI:
./scripts/deploy-ui.sh
dev-run-server.sh
: Runs the server in development mode.dev-run-ui.sh
: Runs the UI in development mode.
These scripts simplify running the applications in a development environment without containerization.
init_psql.sh
: Initializes the PostgreSQL database.regkey.py
: Generates registration keys.run-server.sh
: Starts the server application.run-ui.sh
: Starts the client UI.stop-server.sh
: Stops the server application.stop-ui.sh
: Stops the client UI.
Once both the server and client are running, access the application at: http://localhost:3000
The Admin Panel provides administrative functionalities such as:
- Executing ad-hoc database queries.
- Sending custom AI queries to advanced GPT models.
These features are useful for database management and accessing the LLM via the API.
For prod mode, configure these secrets in the AWS secrets manager:
- twentyplots.admin.username
- twentyplots.admin.password
- twentyplots.admin.email
To access the Admin Panel in dev mode, you need to configure the admin username in the application source code before building it.
-
Edit the
AdminService
ClassOpen
AdminService.java
located at:20plots-server/src/main/java/com/sneakyghost/twentyplots/services/AdminService.java
-
Replace the Placeholder Username
- Locate the fetchSecretAdminName() method.
- Replace "your-admin-username" with your desired admin username.
Log in using the admin username you configured. You will see additional navigation options for the Admin Panel:
- Admin AI Page: Send custom prompts to AI models.
- Admin DB Page: Execute SQL queries directly against the database.
Note: Use these features with caution, as they can affect your database and application behavior.
-
Docker System Prune: The deployment scripts run
docker system prune -a -f
, which removes all unused containers, networks, images, and optionally, volumes. Use with caution, as this will delete all dangling resources. You may comment out or remove this line if unnecessary. -
AWS ECR Authentication: The deployment scripts use AWS CLI for authentication. Ensure you have the AWS CLI installed and configured with the necessary permissions.
-
Platform Compatibility: Scripts are written for Unix-like systems.
-
External Configuration: For production environments, consider using externalized configuration files or environment variables instead of modifying application properties within the scripts.
Note: This project is not under active development. I may review and accept pull requests for critical bug fixes, security issues, or particularly valuable improvements, but I'm not actively adding new features or committing to regular maintenance.
If you still wish to contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
- Commit your changes with clear messages.
- Push to your fork:
git push origin feature/your-feature-name
- Submit a pull request detailing your changes.
I appreciate any contributions that address serious bugs or improve stability/security. Please understand that response times and acceptance of non-critical contributions may be limited.