GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — CharAI/frontend at main · uiedu/CharAI

Expand file tree

/

frontend

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

frontend

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
public
public
 
 
src
src
 
 
tests
tests
 
 
.env.development
.env.development
 
 
.gitignore
.gitignore
 
 
CaddyCommands.md
CaddyCommands.md
 
 
Caddyfile
Caddyfile
 
 
Dockerfile
Dockerfile
 
 
README.md
README.md
 
 
eslint.config.js
eslint.config.js
 
 
index.html
index.html
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
pipeline.sh
pipeline.sh
 
 
tsconfig.app.json
tsconfig.app.json
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.node.json
tsconfig.node.json
 
 
vite.config.ts
vite.config.ts
 
 

README.md

Outline

CharAI Frontend Setup

This guide outlines how to initialize and manage the CharAI frontend using Vite, React, TypeScript, and Material UI.


Recreate Project from package.json

# Install dependencies
npm install
# or if using yarn
yarn install

# Start development server
npm run dev

Initialization (New Project)

# Create new Vite project with React and TypeScript
npm create vite@latest charai-frontend -- --template react-ts

# Navigate to project directory
cd charai-frontend

# Install core dependencies
npm install   # Windows/Linux/macOS: same command

Development Server

# Start the development server
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

Project Structure

frontend/
├── src/
│   ├── components/        # Reusable UI components (Header, ProtectedRoute, PublicRoute, AppRoutes)
│   ├── pages/            # Route-level components (LoginPage, SignupPage, HomePage, App)
│   ├── services/         # API client and auth service (authService.ts)
│   ├── contexts/         # React context for state management (AuthContext)
│   ├── types/            # TypeScript type definitions (auth.ts)
│   ├── utils/            # Utility functions
│   ├── App.tsx           # Root component
│   ├── main.tsx          # Entry point
│   └── index.css         # Global styles
├── public/               # Static assets
├── index.html            # HTML template
├── package.json          # Dependencies and scripts
├── tsconfig.json         # TypeScript configuration
├── vite.config.ts        # Vite configuration
└── README.md             # This file

Authentication

The frontend integrates with Django REST Framework using TokenAuthentication and SessionAuthentication:

  • Token Storage: Auth tokens are stored in localStorage under the key authToken
  • Session Support: Requests include credentials: 'include' to support session-based auth
  • Protected Routes: Routes are guarded by ProtectedRoute and PublicRoute components
  • Auth Context: Centralized auth state via AuthContext (provides login, register, logout, checkAuth, isAuthenticated, user, isLoading)
  • Error Handling: Errors from auth attempts are logged to console only; no UI error messages are displayed

Authentication Flow

  1. User submits login/signup form
  2. Frontend calls authService.login() or authService.register()
  3. Backend validates and returns token (+ user data)
  4. Frontend stores token locally
  5. Subsequent requests include Authorization: Token <token> header
  6. On logout, token is cleared and user is redirected to login

Key Files

  • src/services/authService.ts - API calls and token management
  • src/contexts/AuthContext.tsx - Auth state and methods
  • src/types/auth.ts - TypeScript types for auth
  • src/components/ProtectedRoute.tsx - Guards authenticated pages
  • src/components/PublicRoute.tsx - Prevents logged-in users from seeing login/signup
  • src/pages/LoginPage.tsx - Login form
  • src/pages/SignupPage.tsx - Registration form
  • src/pages/HomePage.tsx - Protected home page (shown only to authenticated users)

TypeScript Compilation & Linting

# Type check and build
npm run build

# Lint the codebase
npm run lint

The following scripts are available in package.json:

{
  "scripts": {
    "dev": "vite",
    "build": "tsc -b && vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  }
}

Freeze Dependencies

To capture current dependencies for other developers:

# Create package.json.lock (npm)
npm install

# or yarn.lock (yarn)
yarn install

Commit both package.json and the lock file to version control.


Summary

  • Package manager: npm
  • Framework: React 18+ with TypeScript
  • UI Library: Material UI (MUI)
  • Routing: React Router v6
  • Package manager: npm
  • Project root: src/
  • Main commands:
    • npm run dev - start development server
    • npm run build - build for production and type check
    • npm run preview - preview production build
    • npm run lint - lint codebase
  • Configuration:
    • TypeScript: tsconfig.json
    • Vite: vite.config.ts
    • Environment: .env

Getting Started

  1. Install dependencies:

    npm install
  2. Ensure backend is running:

    # In the backend directory
    python manage.py runserver
  3. Start the dev server:

    npm run dev
  4. Open the app:

    • Navigate to configured frontend server URL
    • Sign up or log in to see the protected home page

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.