Experimental web app for turning plain text into LaTeX documents. The project powers the live demo at AITexGen.com. It mixes a React/TypeScript frontend with an Express backend that talks to several AI providers. The server can compile the resulting LaTeX to PDF using Tectonic and falls back to an HTML preview when compilation fails.
- Install Node 20+ and PostgreSQL.
npm install
(requires internet)- Copy
.env.example
to.env
and fill in your API keys. npm run db:push
to create tables.npm run dev
to start the server and frontend.
server/
– Express app and servicesclient/
– React frontendshared/
– Database schema and validation helpersscripts/
– Automation and microservices
npm test
uses Node’s built‑in runner. Tests require the dependencies from npm install
and skip if tools like Stripe or Tectonic are unavailable.
The LaTeX compiler includes a clever fallback. When Tectonic isn’t available or fails, it generates a lightweight HTML preview so users still see the result: // Check if Tectonic is available in this environment const tectonicAvailable = await isTectonicAvailable();
// If we're in Railway deployment and Tectonic isn't available, use fallback mechanism if (isRailwayDeployment && !tectonicAvailable) { debugLog('[LATEX DEBUG] Running in Railway environment with Tectonic unavailable, using fallback');
// Try backup PDF creation method first
const backupPdf = await createTectonicBackupPDF(latexContent);
if (backupPdf) {
debugLog('\[LATEX DEBUG\] Successfully created PDF using backup method');
return {
success: true,
pdf: backupPdf
};
}
// If backup PDF creation fails, generate HTML preview
debugLog('\[LATEX DEBUG\] Backup PDF creation failed, generating HTML preview');
const htmlPreview = await generateHTMLPreview(latexContent);
return {
success: true,
pdf: htmlPreview,
isHtml: true
};
}
// Create temporary directory const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'latex-'));
See more in `server/utils/tectonic.ts`.
## Architecture
More notes and a simple diagram live in [`docs/architecture.md`](docs/architecture.md).