Nginx config, working deploy, basic theme, repo cleanup

This commit is contained in:
Théophile Gervreau-Mercier
2026-02-05 17:33:10 +01:00
parent 2cb5436647
commit f23fbb481b
30 changed files with 4536 additions and 760 deletions

View File

@@ -1,244 +1,222 @@
# Post-ERG Thesis Database Schema
# Database Documentation
SQLite database schema for managing final thesis projects (TFE) and doctoral theses at ERG.
Complete documentation for the Post-ERG thesis database.
## Overview
## 📚 Available Documentation
This schema supports all requirements from the technical specifications (`posterg_fiche-technique.md`):
### 1. **[DATABASE_SPECIFICATION.md](DATABASE_SPECIFICATION.md)** ⭐
**Complete technical specification** - 25KB comprehensive document
- Multiple metadata categories (orientation, AP, finality, languages, formats, keywords)
- Multiple authors and supervisors per thesis
- Access control (Libre/Interne/Interdit)
- Licensing management
- File uploads (main TFE, annexes, written parts)
- Jury notes and points
- Publication workflow (submission → defense → publication)
- Editable static pages (charte, about, licenses, contact)
- Distinction between TFEs and doctoral theses
**Contents:**
- Complete table definitions with all columns
- Entity relationship diagrams
- Junction table specifications
- Lookup table values
- Business rules and workflows
- Sample queries and use cases
- Instructions for requesting schema changes
## Database Structure
**Use when:** You need complete technical details about the database structure.
### Core Tables
---
**`theses`** - Main thesis information
- Basic metadata (title, subtitle, year, identifier)
- Academic details (orientation, AP program, finality)
- Content (synopsis, jury notes, duration/size)
- Access control and licensing
- Publication workflow status
### 2. **[QUICK_SCHEMA_REFERENCE.md](QUICK_SCHEMA_REFERENCE.md)** 🚀
**Quick reference guide** - 5KB at-a-glance reference
**`authors`** - Student/author information
- Name and contact email
**Contents:**
- Table summary
- Key relationships diagram
- Core fields reference
- Predefined lookup values
- Common SQL queries
- Constraint summary
**`supervisors`** - Thesis promoters
- Name of supervisor/promoter
**Use when:** You need quick lookup or common query examples.
**`thesis_files`** - Uploaded files
- Main TFE, annexes, written parts
- File metadata (path, size, MIME type)
---
**`pages`** - Static content pages
- Charte, about, licenses, contact pages
- Easily editable content
### 3. **[schema.sql](schema.sql)** 💾
**The actual SQL schema** - Executable SQL file
### Reference Tables (Predefined Lists)
**Contents:**
- Complete CREATE TABLE statements
- Indexes and triggers
- Predefined data (orientations, AP programs, etc.)
- Views for common queries
- `orientations` - Arts Numériques, Dessin, Cinéma d'animation, etc.
- `ap_programs` - Narration Spéculative, DPM, APS, LIENS
- `finality_types` - Approfondi, Enseignement, Spécialisé
- `languages` - Français, Anglais, etc. (expandable)
- `format_types` - Site web, Audio, Vidéo, Performance, etc.
- `keywords` - Dynamic, expandable keyword list (max 10 per thesis)
- `access_types` - Libre, Interne, Interdit
- `license_types` - To be defined
**Use when:** Setting up or resetting the database.
### Junction Tables (Many-to-Many)
---
- `thesis_authors` - Links theses to authors
- `thesis_supervisors` - Links theses to supervisors
- `thesis_languages` - Multiple languages per thesis
- `thesis_formats` - Multiple formats per thesis
- `thesis_keywords` - Max 10 keywords per thesis
## 🚀 Quick Start
## Key Features
### View Database Schema
```bash
# Read the quick reference
cat database/QUICK_SCHEMA_REFERENCE.md
### 1. Flexible Metadata
- Multiple authors, supervisors, languages, formats, and keywords per thesis
- Predefined lists with ability to add new entries
- Proper normalization to avoid data duplication
### 2. Access Control
Three levels of access as specified:
- **Libre**: Freely accessible online and in library
- **Interne**: Physical access only, descriptive note online
- **Interdit**: No physical/online access, descriptive note only
**Important**: Access can be restricted but never opened (as per specs)
### 3. Publication Workflow
The schema tracks the complete lifecycle:
1. **Submission** (`submitted_at`) - Student submits TFE
2. **Defense** (`defense_date`) - Soutenance takes place
3. **Jury Review** (`jury_note_added`, `jury_points`, `context_note`)
4. **Publication** (`published_at`, `is_published = 1`)
**Important**: TFEs are NOT published immediately upon submission. They must wait for:
- Defense to occur
- Jury to add optional context note (max 150 words)
- Jury points to be recorded
### 4. File Management
Support for multiple file types per thesis:
- Main TFE work
- Annexes
- Written part
- Other supporting files
### 5. Views for Easy Querying
**`v_theses_full`** - Complete thesis information with all related data
- Joins all tables
- Concatenates multiple values (authors, supervisors, keywords, etc.)
- Use for backend/admin interfaces
**`v_theses_public`** - Only published theses
- Filtered to `is_published = 1`
- Use for public-facing website
## Usage
# Or full specification
cat database/DATABASE_SPECIFICATION.md
```
### Initialize Database
```bash
sqlite3 posterg.db < schema.sql
# Create test database from schema
just init-test-db
# Create with sample data
just create-fixtures
```
### Example Queries
### Query Database
```bash
# Open SQLite prompt
just query-db
#### Get all published theses from 2025
```sql
SELECT * FROM v_theses_public WHERE year = 2025;
# Show specific thesis
just show-thesis 42
```
#### Get theses by orientation
```sql
SELECT * FROM v_theses_full
WHERE orientation = 'Vidéographie';
## 📝 Making Schema Changes
### Step 1: Document Your Request
Format:
```
**Table:** [table_name]
**Change Type:** [add/modify/remove]
**What:** [description]
**Why:** [reason/use case]
**Example Data:** [samples]
```
#### Get theses with specific keyword
```sql
SELECT t.* FROM v_theses_full t
JOIN thesis_keywords tk ON t.id = tk.thesis_id
JOIN keywords k ON tk.keyword_id = k.id
WHERE k.keyword = 'performance';
### Step 2: Specify Details
For **new columns**:
- Column name
- Data type (TEXT, INTEGER, BOOLEAN, DATETIME)
- NULL/NOT NULL
- Default value
- Indexes needed?
For **new tables**:
- Table name
- All columns
- Relationships to existing tables
- Sample data
### Step 3: Provide Context
Include:
- Use case scenario
- Who will use it?
- How will it be displayed?
- Any constraints?
### Example Request
```
**Table:** theses
**Change Type:** add column
**What:** Add column to track if thesis won an award
**Why:** Need to highlight award-winning theses on homepage
**Column Name:** has_award
**Data Type:** BOOLEAN
**Default:** 0 (false)
**Example:** 1 for "Prix du Jury 2025" winner
```
#### Get theses awaiting publication (submitted but not published)
```sql
SELECT * FROM theses
WHERE submitted_at IS NOT NULL
AND is_published = 0;
## 🗂️ Database Structure Overview
```
┌─────────────┐
│ theses │ ◄── Main table (500+ records/year)
└──────┬──────┘
├──► authors (via thesis_authors)
├──► supervisors (via thesis_supervisors)
├──► keywords (via thesis_keywords)
├──► languages (via thesis_languages)
├──► formats (via thesis_formats)
├──► thesis_files (attachments)
└──► Lookup tables:
• orientations
• ap_programs
• finality_types
• access_types
• license_types
```
#### Update access type (can only restrict, not open)
```sql
-- Allowed: from Libre to Interne
UPDATE theses SET access_type_id = 2 WHERE id = 1;
## 📊 Key Statistics
-- Not allowed per specs: from Interdit to Libre
-- This should be enforced in application logic
- **Core tables:** 3 (theses, authors, supervisors)
- **Junction tables:** 5 (many-to-many relationships)
- **Lookup tables:** 7 (predefined values)
- **Support tables:** 2 (files, pages)
- **Views:** 2 (full data, public only)
- **Indexes:** 11 (for performance)
- **Triggers:** 4 (auto-update timestamps)
## 🔍 Common Scenarios
### Scenario 1: Student Submits Thesis
1. Create record in `theses` (is_published=0)
2. Add author to `authors`, link via `thesis_authors`
3. Add supervisor(s) to `supervisors`, link via `thesis_supervisors`
4. Set `orientation_id`, `ap_program_id`, `finality_id`
5. Upload file to `thesis_files`
6. Add keywords via `thesis_keywords`
7. Set `submitted_at` timestamp
### Scenario 2: Admin Publishes Thesis
1. Verify all required fields present
2. Set `defense_date`
3. Set `jury_points`
4. Optional: add `context_note`
5. Set `is_published = 1`
6. Set `published_at = CURRENT_TIMESTAMP`
### Scenario 3: Public User Searches
Query `v_theses_public` view with filters:
- By year
- By orientation
- By keyword
- By author name
- Full-text search in title/synopsis
## 🛠️ Development Workflow
### Local Development
1. Use `test.db` for development
2. Create via `just init-test-db`
3. Populate with `just create-fixtures`
4. Test queries before deployment
### Schema Changes
1. Update `schema.sql`
2. Update `DATABASE_SPECIFICATION.md`
3. Test on `test.db`
4. Deploy to production (manual migration)
### Testing
```bash
# Run tests on local database
just test-public-all
# Check database stats
just stats-public
```
## Data Import Notes
## 📞 Need Help?
Based on `Database_TFE_test.csv`:
1. **Quick lookup** → Read `QUICK_SCHEMA_REFERENCE.md`
2. **Complete details** → Read `DATABASE_SPECIFICATION.md`
3. **Schema changes** → Follow format in this README
4. **SQL examples** → Check `QUICK_SCHEMA_REFERENCE.md`
### Current CSV Structure
- Identifiant (e.g., "2025-002")
- Titre, Sous-titre
- Auteur·ice(s) - comma-separated if multiple
- Contact - email
- Promoteur·ice(s) - comma-separated if multiple
- Format - comma-separated if multiple
- Année
- AP - abbreviation (DPM, LIENS, etc.)
- Orientation - abbreviation (SC, VI, CA, etc.)
- Finalité
- Mots-clés - comma-separated, max 10
- Synopsis
- Contexte - jury context note
- Remarques - internal notes
- Langue - language(s)
- Autorisation - access type
- License - license type
- taille - duration/size info
- Points sur 20 - jury points
- lien BAIU - institutional repository link
## 🔗 Related Documentation
### Import Considerations
1. **Parse comma-separated values** for:
- Authors (split and create entries in `authors` table)
- Supervisors (split and create entries in `supervisors` table)
- Formats (map to `format_types`)
- Keywords (split and create/link in `keywords`)
- Languages (split and map to `languages`)
2. **Map abbreviations**:
- Orientations: SC → Sculpture, VI → Vidéographie, CA → Cinéma d'animation, etc.
- AP: DPM, LIENS, APS (exact match)
3. **Handle missing data**:
- Some fields in CSV are empty (AP, Orientation for some entries)
- Use NULL in database
4. **Parse duration/size**:
- Examples: "128 pages", "78 pages + ?? minutes", "68 minutes"
- Extract numeric values for `duration_pages` and `duration_minutes`
- Store original string in `file_size_info`
## Schema Design Decisions
### Why SQLite?
- Self-contained, serverless
- Easy to backup (single file)
- Good performance for this use case
- Simple to integrate with various tools
### Normalization Level
- 3rd Normal Form (3NF) for most tables
- Denormalized views for read performance
- Balance between flexibility and simplicity
### Extensibility
- New languages can be added via `languages` table
- Keywords are dynamic and grow with content
- License types can be defined later
- Static pages can be added via `pages` table
### Constraints
- CASCADE deletes on junction tables
- UNIQUE constraints on lookup table names
- NOT NULL on critical fields
- Automatic timestamps via triggers
## Important Business Rules
1. **No immediate publication**: TFEs must go through defense before publication
2. **Access restriction is one-way**: Can restrict but not open access
3. **Max 10 keywords** per thesis (enforce in application)
4. **Jury context note max 150 words** (enforce in application)
5. **Synopsis ~200 words** (guideline, not hard limit)
6. **Multiple selections allowed** for: languages, formats, authors, supervisors, keywords
7. **Doctoral theses**: Use `is_doctoral = 1` to distinguish from TFEs
## Next Steps
1. Create import script to load CSV data
2. Define license types
3. Build backend API for CRUD operations
4. Implement authorization checks
5. Create admin interface for easy editing
6. Build public-facing website using views
- [Deployment Guide](../nginx/DEPLOYMENT_COMPLETE.md)
- [Repository Structure](../REPOSITORY_STRUCTURE_ANALYSIS.md)
- [Test Database Guide](../nginx/TEST_DATABASE_SETUP.md)