A full-stack application for building and managing synthetic personas using Google Gemini AI. The app allows users to create, chat with, and simulate interactions with AI-powered personas.
The application follows an MVC (Model-View-Controller) architecture:
- Backend: Express.js + TypeScript with PostgreSQL database
- Frontend: React + TypeScript with Vite
- Database: PostgreSQL with proper user isolation
- Authentication: JWT-based authentication with password hashing
├── backend/ # Backend API server
│ ├── src/
│ │ ├── config/ # Database configuration
│ │ ├── controllers/ # Request handlers (MVC Controllers)
│ │ ├── services/ # Business logic layer
│ │ ├── models/ # Database models/types
│ │ ├── routes/ # API route definitions
│ │ ├── middleware/ # Auth & error handling
│ │ ├── utils/ # Helper functions
│ │ └── migrations/ # Database schema
│ └── package.json
│
├── src/ # Frontend application
│ ├── views/ # Page components (MVC Views)
│ ├── components/ # Reusable UI components
│ ├── hooks/ # Custom React hooks (MVC Controllers)
│ ├── services/ # API client services
│ ├── models/ # Type definitions
│ ├── context/ # React context providers
│ └── utils/ # Helper functions
│
└── templates/ # Gemini AI templates for persona generation
- Node.js 18+ and npm
- PostgreSQL 12+
- Google Gemini API key
Create a PostgreSQL database:
createdb persona_builderOr using psql:
CREATE DATABASE persona_builder;cd backend
npm installCreate a .env file in the backend/ directory:
DATABASE_URL=postgresql://username:password@localhost:5432/persona_builder
DB_HOST=localhost
DB_PORT=5432
DB_NAME=persona_builder
DB_USER=your_username
DB_PASSWORD=your_password
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=7d
PORT=3001
NODE_ENV=development
CORS_ORIGIN=http://localhost:3000
GEMINI_API_KEY=your-gemini-api-keyRun database migrations:
npm run migrateStart the backend server:
npm run devThe backend will run on http://localhost:3001
# From project root
npm installCreate a .env file in the project root:
VITE_API_URL=http://localhost:3001/api
VITE_GEMINI_API_KEY=your-gemini-api-keyStart the development server:
npm run devThe frontend will run on http://localhost:3000
POST /api/auth/register- Register a new userPOST /api/auth/login- Login user
GET /api/personas- Get all personas for current userGET /api/personas/:id- Get persona by IDPOST /api/personas- Create new personaPUT /api/personas/:id- Update personaDELETE /api/personas/:id- Delete personaGET /api/personas/:personaId/files- Get persona filesPOST /api/personas/:personaId/files- Create persona file
GET /api/chat/sessions- Get all chat sessionsGET /api/chat/sessions/:id- Get chat session by IDPOST /api/chat/sessions- Create new chat sessionPUT /api/chat/sessions/:id- Update chat sessionDELETE /api/chat/sessions/:id- Delete chat sessionGET /api/chat/sessions/:sessionId/personas- Get session personasGET /api/chat/sessions/:sessionId/messages- Get session messagesPOST /api/chat/sessions/:sessionId/messages- Create message
GET /api/simulations- Get all simulation sessionsGET /api/simulations/:id- Get simulation session by IDPOST /api/simulations- Create simulation sessionPUT /api/simulations/:id- Update simulation sessionDELETE /api/simulations/:id- Delete simulation session
All endpoints (except auth) require authentication via JWT token in the Authorization: Bearer <token> header.
- User Authentication: Secure registration and login with JWT tokens
- Persona Management: Create, view, edit, and delete synthetic personas
- Chat Interface: Chat with one or multiple personas simultaneously
- Simulation Mode: Test personas in different scenarios (web page, marketing, sales pitch, investor pitch)
- Persona Files: Store and view blueprint files for each persona
- User Isolation: All data is scoped to the authenticated user
cd backend
npm run dev # Start with hot reload
npm run build # Build for production
npm start # Run production buildnpm run dev # Start Vite dev server
npm run build # Build for production
npm run preview # Preview production buildThe database includes the following tables:
users- User accountspersonas- Persona definitionspersona_files- Files associated with personaschat_sessions- Chat conversation sessionschat_session_personas- Junction table for session-persona relationshipsmessages- Chat messagessimulation_sessions- Simulation sessions
All tables include proper foreign key constraints and indexes for performance.
Last updated: February 2025
- Passwords are hashed using bcrypt
- JWT tokens for authentication
- User data isolation at the database level
- CORS configuration for API security
- Input validation on all endpoints
Private project - All rights reserved